This project is a Node.js-based RESTful API that provides CRUD operations for managing data.
- Clone the repository:
git clone https://github.com:faridvatani/node-restful-api.git
- Navigate to the project directory:
cd node-restful-api
- Install dependencies:
yarn install
To start the server, run the following command:
yarn start
The API will be accessible at http://localhost:8080/api
. You can use a tool like Postman to test the API.
You can import the Postman collection from the postman
directory to test the API.
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Log in a userPOST /api/auth/logout
: Log out a userGET /api/users
: Get all usersGET /api/users/:id
: Get a specific user by IDPOST /api/users
: Create a new userPUT /api/users/:id
: Update a user by IDDELETE /api/users/:id
: Delete a user by ID
Create a .env
file in the root directory and add the following environment variables:
NODE_ENV=
PORT=
CORS_ORIGIN=
MONGO_URL=
SECRET_KEY=
.env
.example.env
.gitignore
nodemon.json
package.json
README.md
postman/
src/
app.ts
config/
database.ts
controllers/
auth.controller.ts
user.controller.ts
helpers/
index.ts
middleware/
index.ts
models/
user.model.ts
routes/
auth.routes.ts
index.ts
user.routes.ts
services/
user.service.ts
utils/
safeAssign.ts
tsconfig.json
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.