Skip to content

sahil19-19/SPAM-APP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Features

  • 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.

Structure of App

  • config/config.json constain db config data
  • models/ contain tables and database setup code
  • seeders/ contain code for populating database

Running the app

  • app.js is the entry point

  • run

    npm install
    
  • Create a MySQL database

  • Connect the database to app by updating config/config.json according to your database

  • Update .env file

  • run

    npm run dev
    

    to run the app using nodemon or

    node app.js
    

    to run the app simply. This will create the tables required

Populating database

  • 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

API Calls

  • 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

Registering user

  • Hit POST /api/user/register
  • email in json is optional, rest are required

Logging In

  • 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

To flag a number as spam

  • Hit POST /api/spam
  • phone number is required

To search using a name

  • Hit GET /api/search/name/:query
  • :query being the name (eg,john)

To search using a phone number

  • Hit GET /api/search/phone/:number

  • :number replaces with number (eg,888888)

  • I have also mentioned the steps in step.txt file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors