A template to quickly develop servers with user management in an easy and effective way. The template manages the creation of users with connection to MongoDB, the management of refresh and access token for authentication and is easily customizable. Don't waste time developing authentication from scratch, use this template and start developing your server logic now.
$ git clone https://github.com/GianGuaz256/NestServerBasic.git
$ cd ./NestServerBasic
$ npm install
Create an .env file and add the following parameter in order to setup the script:
SERVER_PORT=8000
DB=<Your connection string to mongoDB>
JWT_SECRET=<Your random JWT Secret>
NODE_ENV=development
Go to MongoDB and create a free cluster. The cluster will give you the ability to create collections of records. Once connected follow these steps to connect your cluster to the application. The string to insert in the .env file is formed in this way:
mongodb+srv://dbAdmin:<password>@cluster0.b1k5c.mongodb.net
Once inserted in the file the link with the database is done.
This is a list of available endpoints:
Type | Endpoint | Description |
---|---|---|
@Get | /api/users | Get list of all users |
@Get | /api/users/:id | Get Specific User |
@Post | /api/auth/register | Create new user |
@Post | /api/auth/login | Login user |
@Post | /api/auth/refresh | Refresh token |
@Get | /api/auth/me | Get me |
Developer mode (like nodemon):
$ npm run dev
Author: Guazzo Gianmarco