Overview: This documentation covers the [Project Name] project, a Node.js application using Express, MongoDB with Mongoose, and bcrypt for password hashing. It facilitates user signup, login, and user data retrieval.
Table of Contents:
Installation:
- Clone Repository:
git clone github.com/Mrinal-exe/backend-api
- Install Dependencies:
npm install
- Configure MongoDB:
- Ensure MongoDB is installed and running.
- Check configuration in
config/mongo.js.
- Run the Application:
npm start
Usage:
- The application exposes API endpoints for user-related operations.
- Use tools like Postman or curl for testing.
Project Structure:
index.js: Entry point.config/mongo.js: MongoDB configuration.model/user_model.js: User model definition.routes/routes.js: Express router for API routes.
Dependencies:
Configuration:
- Make a new file and name it
.envand definePORTandURI. - Set the MongoDB connection URL and Post.
Routes:
- GET
/getall
- Fetches all users from the database.
- POST
/signup
- Registers a new user by hashing the password and saving to the database.
- POST
/login
- Authenticates a user by comparing the provided password with the hashed password.
Models:
- User Model (
model/user_model.js): - Defines the structure of the user schema.