Skip to content

yarapolana/nodejs-auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗃NodeJS Authentication Challenge

This is my second NodeJS server and a code challenge from a class in Rocketseat's Bootcamp. The challenge involves creating a REST API server with an authentication service from scratch with nodejs. Read Description

🚀Description

Build an authentication service from scratch using Express, Nodemon, Sequelize, Jsonwebtoken, Yup and Postgres. In this application I used linting standards with ESLint + Prettier + EditorConfig.

Routes

  • GET /: This is a test route you can send as response an OK message.

  • POST /users: This route creates a new user and must receive name, email and password in the body. You must validate the user where you state that all fields are required, email must be an email and password has a minimum of 8 characters.

  • POST /sessions/: This route logs the user into the application and receives email and password as mandatory fields.

  • PUT /users: This route updates the authenticated user and receives any of the following name, email or password in the body.

Middleware & Security

On loging in and creating a user uncrypt their password using JWT to create an encrypted token. Create a middleware that validades if a user is authenticated, use JWT to decode the user's token.

Result

To run the application first install dependencies

yarn or npm install

This application uses Postgres so make sure to have that running (with Docker recommended) then run the application

yarn dev

Your code should be up and running here

http://localhost:3333


Check out the continuation of this challenge here.


License:

This project is made available under the MIT LICENSE.

Authors: