This project is a Node.js microservice built using Express.js, which provides authentication and assignment management functionalities. The service uses SQLite as its database and is containerized using Docker.
my_project/
├── src/
│ ├── routes/
│ │ ├── auth.js
│ │ └── assignments.js
│ ├── models/
│ │ └── database.js
│ ├── middleware/
│ │ └── authenticateToken.js
│ └── app.js
├── db/
│ └── sqlite.db
├── .env
├── Dockerfile
├── package.json
└── README.md
Ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
-
Install the dependencies:
npm install
-
Set up the environment variables:
Create a
.env
file in the root of the project and add your environment variables:PORT=3000 JWT_SECRET=your_jwt_secret
-
Initialize the SQLite database:
If your project includes a database setup script, run it. Otherwise, ensure
sqlite.db
is in thedb
folder and structured correctly.
-
Start the server:
npm start
-
The application will be available at
http://localhost:3000
.
-
Build the Docker image:
docker build -t my_microservice .
-
Run the Docker container:
docker run -p 3000:3000 my_microservice
-
Access the application at
http://localhost:3000
.
- POST /api/auth/login: Authenticates a user and returns a JWT.
- POST /api/assignments: Creates a new assignment.
- GET /api/assignments: Retrieves all assignments.
- PUT /api/assignments/:id: Updates an assignment by ID.
- DELETE /api/assignments/:id: Deletes an assignment by ID.