Skip to content

A template to start the development of a server with inside the management of users, authentication and connection with MongoDB using Nestjs.

Notifications You must be signed in to change notification settings

GianGuaz256/NestServerBasic

Repository files navigation

Nest.js server w/ Authentication

Nest Logo

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.

Installation

$ git clone https://github.com/GianGuaz256/NestServerBasic.git
$ cd ./NestServerBasic
$ npm install

Create .env file

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

Create a MongoDB Cluster

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.

Endpoint

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

Run application

Developer mode (like nodemon):

$ npm run dev

Stay in touch

Author: Guazzo Gianmarco


About

A template to start the development of a server with inside the management of users, authentication and connection with MongoDB using Nestjs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published