Simple NodeJS Rest API using JWT authentication and sequelize as ORM for SQLite db
PS: Postman request collection can be found in the folder postman
Used technolgies: Nodejs, JWT Auth, Sequelize(ORM), Sqlite
- Global error handling
- General Logs
- Request logs
- Audit table
-
npm install --force
-
This repository comes with a pre configured database
-
Run this only if you need to recreate the db, don't forget to delet ethe database.sqlite3
npx sequelize db:migrate
andnpx sequelize db:seed:all
-
npm start
to start server on localhost:3000
- POST
/api/user/register
- Request body
{ "username": "administrator", "email": "[email protected]", "password": "admin123" }`
- POST
/api/user/login
- Request body
{ "email": "[email protected]", "password": "admin123" }
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXhwIjoxNjUzNzA0MzQ3LCJpYXQiOjE2NTM3MDM3NDd9.MiycyMr-FcFAhrJJZetXWgzCzYqvMKaQFZdYGIxEJPE
- GET
/api/movies
- GET
/api/movies/:id
- POST
/api/movies
- Request body
{
"title": "Movies test",
"originalTitle": "Test of my movie",
"description": "This is an example of update"
}
- PUT
/api/movies
- Request body
{
"id": 4,
"title": "Spider man 3",
"releaseYear": 2018
}
- DELETE
/api/movies/:id
PS: This repository comes with a pre configured database, so you don't need to run the sql bellow...
CREATE TABLE `Users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `username` VARCHAR(255), `email` VARCHAR(255), `password` TEXT, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
CREATE TABLE `Movies` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `description` VARCHAR(255), `title` VARCHAR(255), `originalTitle` VARCHAR(255), `releaseYear` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
CREATE TABLE `Audits` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `updatedTable` VARCHAR(255) NOT NULL, `action` VARCHAR(255) NOT NULL, `pkValue` VARCHAR(255) NOT NULL, `updatedBy` INTEGER NOT NULL, `updatedAt` DATETIME NOT NULL, `createdAt` DATETIME NOT NULL);