This is a backend server boilerplate of the fullstack series
nextjs-admin-jwt-boilerplate, nextjs-client-jwt-boilerplate
It uses jwt token to authenticate users. The refresh token will be stored in the clients' browser.
This project can be used with serverless (Using serverless is not mandatory!
). However, when deployed with serverless, some functions that worked with no problem in the local environment might have problems in the severless environment. So keep in mind to check whether your functions work even in the serverless environment when you deploy.
For instance, serverless does not support relative
imports. All imports from another file should be done in a absolute
way. So you cannot use src/file.ts
to import a function. You should instead find its path relative to the current file and write something like ../../file.ts
This is the backend framework for my
fullstack
boilerplate. If you are interested in getting to know the client framework and admin framework, check out the below repositories also!
For Client: nextjs-client-jwt-boilerplate
For Admin: nextjs-admin-jwt-boilerplate
$ yarn
or
$ npm install
- This project uses Prisma for ORM, so some knowledge on prisma is required. Prisma is well documented on Prisma. Take a look on the prisma document before you start this project.
- If you want to deploy your serverless on a real server, you need to have a VPC configured in AWS. then you need to add information on serverless environment variables (DATABASE_URL, SECURITY_GROUP_ID, PRIVATE_SUBNET, ..)
- This boilerplate project assumes that you are using gmail to send users email. If you want to send email through gmail, it is recommeded that you get a gmail service auth password through google. How to setup gmail service auth password
- You must fill out DATABASE_URL, CLIENT_URL, JWT_ACCESS_TOKEN_SECRET, JWT_ACCESS_TOKEN_EXPIRATION_TIME, JWT_REFRESH_TOKEN_SECRET, JWT_REFRESH_TOKEN_EXPIRATION_TIME.
- Install MYSQL workbench if you do not have one. https://www.mysql.com/products/workbench/.
- After installing mysql workbench, you should create a schema named
nestjs-test
. If you want to name your schema with a different name, you are free to do so. However, remember that you should also change the local env DATABASE_URL too!
- If you see env.example you can see that DATABASE_URL is
mysql://root:root1234@localhost:3306/nestjs-test?schema=public
the root:root1234 is username:password, thus username isroot
and password isroot1234
. In mysql workbench, set your username toroot
and your password toroot1234
. Or, if you want to customize it write your own username and password, but do not forget to modify the DATABASE_URL accordingly.
- Run
prisma migrate dev
. This will create tables in the localhost DB.
-
You must have subnets, security group id, and RDS for serverless to use your aws account.
-
The RDS database url should be remembered