-
The Nursery System REST API is a backend API built with Node.js, Express.js, Mongoose, MongoDB, Multer, Bcrypt, and JWT. This API provides a secure and scalable solution for managing a nursery system.
-
It uses
Mongoose
for object modeling, allowing easy integration with other databases. -
Avatars of teachers can be uploaded using
Multer
, and stored inMongoDB
.
To get started with the Nursery System REST API, follow these steps:
- Clone the repository to your local machine.
git clone <Repo Link>
- Install the required dependencies by running
npm install
. - Create a
.env
file in the root directory of the project and set the following environment variables:port = 8081 DatabaseUrl = <your_database_uri> secretKey = <your_database_uri>
- Start the server by running
npm start
GET /child
: Retrieve a list of all children.GET /child/:id
: Retrieve a specific child record by ID.GET /child/:id/class
: Retrieve the class of a specific child by its ID.POST /child
: Create a new child record.PATCH /child/:id
: Update a specific child record by ID.DELETE /child/:id
: Delete a specific child record by ID.
GET /class
: Retrieve a list of all classes.GET /class/:id
: Retrieve a specific class record by ID.GET /class/:id/teacher
: Retrieve the supervisor of a specific class by its ID.GET /class/:id/child
: Retrieve a list of all children in a specific class by its ID.POST /class
: Create a new class record.PATCH /class/:id
: a specific class record by ID.DELETE /class/:id
: Delete a specific class by ID.
GET /teacher
: Retrieve a list of all teachers.GET /teacher/:id
: Retrieve a specific teacher record by ID.GET /teacher/supervisors
: Retrieve a list of all teachers that are supervisors.PATCH /teacher/:id
: Update a specific teacher by ID.DELETE /teacher/:id
: Delete a specific teacher by ID.
POST /register
: Register a new teacher in the system.
POST /login
: Login a teacher and receive an access token.
Note: All endpoints except for
POST /register
andPOST /login
require an access token in the Authorization header. The token can be obtained by logging in a teacher via the/login
endpoint.
JSON Web Token (JWT)
is used for authentication. Teachers can register, login, and receive an access token to access the protected endpoints.- All endpoints have a validation middleware using
Express-validator
. - Passwords are encrypted with
bcrypt
. - The admin account has full access to all endpoints and other teachers can only see the data of its own and the class it supervises.
This nursery system REST provides a robust set of endpoints for managing information about children, classes, and teachers. The includes authentication and authorization features to ensure that only authorized users can access specific endpoints. It's a great starting point for building a more extensive nursery management system.