Skip to content

Metyou42/user-role

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Role

Opportunities

  • Registration, login, change, delete, get self, get all - user
  • Get, add role
  • Bearer auth

Tech

App uses a number of open source projects to work properly:

Installation

  1. The server use Mysql, so you need to install MySQL
  2. The server is written in Node.js v14+, so you need to install nodejs
  3. Create new database in MySQL
  4. Clone repository in your directory
git clone https://github.com/Metyou42/user-role
cd user-role
  1. Create configuration file as name .env in app directory with this lines
PORT={Port for start app}
SECRET={JWT secret, can by any words}
DB_NAME={Name of your database in MySQL}
USER_NAME={User name for connect to database}
PASSWORD={Password for connect to database}
  1. Install the dependencies and devDependencies and start the server
npm i
npm run start
  1. Go to /api/docs for view API

API guide

All request besides Registration and Login must have token

Authorization: Bearer eyJhbGciOiJIUzI...

User

Api Key Description
GET /api/user Return a list of useres
GET /api/user/me Return a user self
POST /api/user/registration Create new user, return token, body - {"name":"{username}"}
POST /api/user/login Login user, return token, body - {"name":"{username}"}
PUT /api/user Change info about user, return new token, body - {"name":"{username}", "roles": [{Existing roles name]}
DELETE /api/user Delete user

Role

Api Key Description
GET /api/role Return a list of roles with users
POST /api/role Create new role, body - {"role":"{role name}"}

Used technology

  • Node.js/Express
  • MySQL
  • sequelize
  • mysql2
  • jsonwebtoken
  • dotenv
  • swagger-jsdoc
  • swagger-ui-express

About

REST API User with role

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published