jackyef / vercel-next-serverless

Home Page:https://vercel-next-serverless.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vercel Next.js + Serverless Example Project codecov

Example PWA project leveraging Next.js for frontend, with vercel serverless function for APIs + free MongoDB Atlas cluster. The project uses:

  1. HipoLabs Universities List API
  2. Google sign-in
  3. Chakra UI
  4. Next.js
  5. Codecov

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  1. NodeJS >= 10 -- Official download
  2. Yarn >= 1.16.0 -- Official download

Installing

  1. Create an .env file based on the .env.example file

  2. For GOOGLE_OAUTH_ID and GOOGLE_OAUTH_SECRET, follow [Google oAuth docs] to get your own Google oAuth AppId and secret. This is how the values look like:

    GOOGLE_OAUTH_SECRET=tfmG-_kIcxqn2drkMMSsdLH
    GOOGLE_OAUTH_ID=3459784788234-va9877zx89asd8as8d8asdg.apps.googleusercontent.com
    
  3. For JWT_SECRET you can generate a random, secure string. This is used for signing JWT by next-auth

  4. For MONGO_CONNECTION_STRING, you can get one from free using MongoDB Atlas. This is how the values look like:

    MONGO_CONNECTION_STRING=mongodb+srv://root:password@cluster0.d7sa9s.mongodb.net/dbname?retryWrites=true&w=majority
    
  5. Install dependencies using yarn

    yarn install
  6. Start development server

    yarn dev

Running the tests

The tests are run using jest. Simply run yarn test to run the tests.

To get test coverage, run yarn test:coverage

Deployment

There are many ways to deploy to vercel as documented in their docs

Remember to populate the environment variables for your vercel deployment as well! Refer to the .env.example file for all keys and values.

About

https://vercel-next-serverless.vercel.app


Languages

Language:TypeScript 88.5%Language:JavaScript 11.5%