Skip to content

Safe Web Service REST API within NodeJS platform, using raw Javascript and MongoDB.

Notifications You must be signed in to change notification settings

higorasilverio/NodeJS-RestAPI-DM124

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS REST API

REST API with Questions, Answers, and Users entities

Developed by: Higor Silvério

Entities

Question entity fields: id, status, description, options (nullable), creationDate and modifiedDate

Answer entity fields: id, key, name, answer, questionId, creationDate and modifiedDate

User entity fields: id, key, name, answer, questionId, creationDate and modifiedDate


Methods

For Answers and Questions

POST /api/answers or /api/questions - Creates new answer/question (authenticated)

GET /api/answer or /api/questions - Gets all answers/questions (authenticated)

GET /api/answer/:answerID or /api/questions/:questionID - Gets an answer/question (authenticated)

PATCH /api/answer/:answerID or /api/questions/:questionID - Updates an answer/question (admin only)

DELETE /api/answer/:answerID or /api/questions/:questionID - Deletes an answer/question (admin only)

For Users

POST /users - Registers new user (admin only)

GET /users/:userId - Retrieves user's information (admin only)

PATCH /users/:userId - Updates user's role (admin only)

DELETE /users/:userId - Deletes user (admin only)

For Authentication

POST /login - Returns token for API usage (anyone)

For Swagger Documentation

GET /documentation - On browser, shows API documentation (anyone)


Running

To work properly, it requires a .env file with three simple variables

DB_HOST=yourMongoDbHostConnectionString

JWT_SECRET=yourJwtSecretString

BCRYPT_SALT=yourBcryptSaltNumber

At the terminal, run npm install , to install all de dependencies, and then npm start , to run the application.

Authentication with OAuth2 support

Uses MongoDB as standard database (strategy design pattern allows other dabase structure)

About

Safe Web Service REST API within NodeJS platform, using raw Javascript and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages