Giter Club home page Giter Club logo

nodejs-authentication-backend's Introduction

Node.js Authentication Backend Application

A user authentication backend developed in a straightforward manner to gain practical knowledge of JWT-based authentication.

Description

This project was developed to serve as a mini-reference for the technologies implemented throughout its development. Many of them were implemented in a simple way in the code and can be improved by contributors from the community.

Note: Do not use 100% of the logic from this project for larger applications. Evaluate whether the logic within this project aligns with what you seek to address, and always strive to improve and enhance everything within your reach, rather than simply copying and pasting.

Setting up the Project on Your Machine

Command to clone the project to your machine.

git clone https://github.com/Marlinsk/node-authentication-backend.git

After cloning the project, before installing the application's dependencies, create a .env file outside the src folder and add the following variables.

DATABASE_URL="file:./dev.db"
JWT_SECRET="your key"

Note: The value of the JWT_SECRET variable can be any, whether it's a hash or a set of characters.

Installing Application Dependencies

Install the dependencies using the npm command.

npm i

๐Ÿš€ Running the Application

To run the application locally in dev mode using the npm command, execute the following command.

npm run dev

If everything is fine, you will see the following message in the terminal: Server starting ๐Ÿš€ http://localhost:5500.

๐Ÿš Application's HTTP Routes

Description of the functionality of each HTTP route in the backend.

GET List:

List all user accounts.

/

GET Get by ID:

Retrieve a user from the database using their ID. To make the request, include the user's ID in the URL of the request.

/:id

POST Create User:

Create a user account.

/

To create a user using Postman or another HTTP request tool, copy the example below and make the request to create the user.

Example request body:

{
    "name": "Andre Haskell",
    "username": "haskell",
    "email": "[email protected]",
    "password": "095wtjih0-o0r8tg9ubgj"
}

PUT Edit User:

Edit user account details.

/:id

To edit a user using Postman or another HTTP request tool, include the ID in the request body along with the modified data.

Example request body:

{
    "id": "consulte no banco",
    "name": "Andre Haskell",
    "username": "haskell",
    "email": "[email protected]",
    "password": "095wtjih0-o0r8tg9ubgj"
}

DELETE Delete a User:

Delete a user record from the database. To make the request, include the user's ID in the request URL.

/:id

POST Login:

Perform user login by passing the email and password in the request body.

/login

Example request body:

{
    "email": "[email protected]",
    "password": "095wtjih0-o0r8tg9ubgj"
}

๐Ÿฆ Accessing the Database Editor

The database can be accessed using any database management tool. Prisma makes the task of accessing the database to modify its data simple. Just type the following npm command to access it via the web.

npx prisma studio

nodejs-authentication-backend's People

Contributors

marlinsk avatar

Watchers

 avatar  avatar

Forkers

olafi-moon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.