Skip to content

hhimanshu/typescript-serverless-api-vercel

Repository files navigation

TypeScript Serverless APIs on Vercel

semantic-release

This directory is an example of creating serverless APIs in TypeScript and deploy on Vercel platform.

Features

  • Serverless functions written in TypeScript
  • Deployment on Vercel for main branch and pull requests
  • Tests support using Jest
  • CI setup using GitHub Actions to run tests on every push to GitHub (on every branch)
  • CI setup to run tests against Vercel Preview URLs and add them as check before PR could merge. See GitHub Action
  • CI Setup to create a new release using semantic-release
  • Ability to compute function (/address) and also to make API calls (/currency)

Available APIs

Local

http://localhost:3000/api/hello?name=<string>
http://localhost:3000/api/address?total=<number>&type=<addressType>
http://localhost:3000/api/currency
  • The value of number must be between 1 and 50(inclusive)
  • The valid values for addressTypes are city, zipCode

Some examples are

http://localhost:3000/api/hello?name=harit
http://localhost:3000/api/address?total=20&type=zipCode
http://localhost:3000/api/address?total=10&type=city
http://localhost:3000/api/currency

Production

Start Developing

  • Clone this repository (or better fork it so that you can make changes in your repo)
  • Run yarn start. This will kick-off vercel dev so that you can start developing your features
  • Run yarn test to run tests