This repository contains a basic Express API setup with user authentication and CRUD operations. The project is structured using a controller-service-model pattern and includes utilities for handling authentication and logging.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js
- MongoDB
- Clone the repository:
git clone https://github.com/sano0007/node-express-api.git
cd node-express-api
- Install dependencies:
npm install
- Create a
.env
file in the root directory of your project, and add your MongoDB connection string and other configurations:
MONGODB_URI=mongodb://localhost:27017/your-database
...
- Start the development server:
npm start
- Register: Send a POST request with
email
,username
, andpassword
to/auth/register
. - Login: Send a POST request with
email
andpassword
to/auth/login
.
- Get All Users: Send a GET request to
/users
. - Update User: Send a POST request with user data to
/users/update/:id
. - Delete User: Send a DELETE request to
/users/:id
.
Currently, there are no tests specified in the project. You can add your tests and update the test
script in
the package.json
file.
"scripts": {
"test": "your-test-script"
}