- User Authentication: Login and logout functionality using JWT.
- Password Security: Passwords are securely hashed using bcrypt
- Database Management: MySQL integration with Sequelize ORM.
- Data Seeding: Generates and manages data with Sequelize seeders.
- config/config.json constain db config data
- models/ contain tables and database setup code
- seeders/ contain code for populating database
-
app.jsis the entry point -
run
npm install -
Create a MySQL database
-
Connect the database to app by updating
config/config.jsonaccording to your database -
Update .env file
-
run
npm run devto run the app using nodemon or
node app.jsto run the app simply. This will create the tables required
-
In another terminal, again in root of the app run
npx sequelize-cli db:seed:all -
To remove all data from db run
npx sequelize-cli db:seed:undo:all -
note : Do not populate the data again after depopulating it. Drop the tables and restart the app. Then populate the tables again. The logic for data populating is in the file
seeders/...-demo-users.js
-
In all calls that make use of req.body keep the json for the api request as follows-
{ "myNumber" : "1111", "myPassword" : "111", "myName" : "admin", "myEmail" : "admin@gmail.com" }Enter values as per your wish
- Hit
POST /api/user/register - email in json is optional, rest are required
- Hit
POST /api/user/login - phone number and password are required
- login valid for 1 hour, after which you have to log in again
- Hitting this API with correct phone number and password will generate a token
- Add this token to header. Without the token you can't access the following APIs
- Hit
POST /api/spam - phone number is required
- Hit
GET /api/search/name/:query - :query being the name (eg,john)
-
Hit
GET /api/search/phone/:number -
:number replaces with number (eg,888888)
-
I have also mentioned the steps in step.txt file