Basic Node.js REST API with CRUD operations
The project follows the following directory structure:
src/
: This is where your application code lives.auth/
: Authentication related code.config/
: Configuration files for your application.controllers/
: Controllers handle the logic of routes.middleware/
: Middleware functions.models/
: Mongoose models.routes/
: Application routes.services/
: Services encapsulate business logic.utils/
: Utility functions that can be reused throughout the app.
- Clone the repository:
git clone https://github.com/Niraj-Dilshan/twc-test-api
- Navigate to the project directory:
cd twc-test-api
- Install dependencies:
npm install
- Set up the .env file:
cp .env.example .env
- Update the .env file with the following information:
PORT=portnumber MONGODB_URI=mongodb://localhost/db SECRET_KEY=SecretKey
- Run the project locally:
npm start
- Access your application at http://localhost:3000 (replace "portnumber" with the port you specified).