OptiStaff API provides a Smart Dynamic Scheduler, streamlining the task of building and managing schedules, onboarding the new staff, and more.
Link to our client app repo:
https://github.com/andyccxu/w4156-project-frontend
npm install
- express: Manages the server and routes.
- mongoose: Interface for MongoDB connection and schema definition.
- dotenv: Loads environment variables from a .env file.
- nodemon: Automatically restarts the node application when file changes in the directory are detected.
- cors: Enables Cross-Origin Resource Sharing, allowing API access from different domains.
- bcryptjs: Securely hashes passwords before storage.
- morgan: Logs HTTP requests and errors, helping with debugging.
- jsonwebtoken: Facilitates authentication via JSON Web Tokens.
- jest: Delightful JavaScript testing framework.
- node-mock-https: Mock out responses from the https module, useful for testing HTTP calls without making actual external requests.
We use Twilio to send SMS messages for the notification feature. User of our service needs to obtain credentials for their own Twilio account and add them to our config file.
Append the following lines to config/config.env
. Replace values with your own Twilio acccount information.
TWILIO_ACCOUNT_SID=<your_twilio_id>
TWILIO_AUTH_TOKEN=<your_auth_token>
TWILIO_PHONE_NUMBER=<your_phone_number>
node server.js
Use Ctrl + C
We use ESLint as our style checker and static analysis bug finder.
To run the tool for static analysis, run
npm run lint
The style check report is located at reports/style-check-report.html
.
To run the unit tests using Jest, simply use the following command:
npm test
The unit test report is located at reports/unittest-report.html
.
The coverage report is located at reports/coverage/index.html
.
We use Postman for API testing. It offers a comprehensive suite to test, develop, and document APIs.
To go to our Postman Workspace, please follow this link.
Before using any other endpoint, user must create an account by signing up, then obtain the auth token via login and use the appropriate bearer token in subsequent requests. Each user acts as a manager of the facility and thus can have at most one facility at any time.
- Description: Signup a new user.
- Request Body:
name: string
email: string
password: string
- Response Codes:
201: User registered successfully
400: User already exists or other error
- Description: Login a user and retrieve an authentication token.
- Request Body:
email: string
password: string
- Response Codes:
200: Logged in successfully
400: Email or password is incorrect or other error
- Description: Retrieve the user's facility from the database.
- Response Codes:
200: Success
500: Internal Server Error
- Description: Create a new facility with the specified details.
- Request Body:
facilityName: string
facilityType: string
operatingHours: string
numberEmployees: int
numberShifts: int
numberDays: int
- Response Codes:
201: Success
400: User already manages a facility
- Description: Update the details of the user's facility.
- Request Body (any of the following optional):
facilityName: string
facilityType: string
operatingHours: string
numberEmployees: int
numberShifts: int
numberDays: int
- Response Codes:
200: Success
404: No facility managed by this user
- Description: Delete user's facility.
- Response Codes:
204: Success
404: No facility managed by this user
- Description: Retrieves all user's employees from the database.
- Response Codes:
200: Success
404: No facility managed by this user
- Description: Retrieves a specific employee by ID from the database.
- Request Parameters:
id: string
- Response Codes:
200: Success
404: Cannot find the employee
-
Description: Adds an employee to the facility with the specified details.
-
Request Body:
name: string
email: string
phoneNumber: string
address: string
(optional)skillLevel: string
(optional)
-
Response Codes:
201: Success
400: User does not manage a facility
- Description: Updates the details of a specific employee by ID.
- Request Parameters:
id: string
- Request Body (any of the following optional):
name: string
email: string
phoneNumber: string
address: string
skillLevel: string
- Response Codes:
200: Success
404: Cannot find the employee
- Description: Deletes an employee by ID from the database.
- Request Parameters:
id: string
- Response Codes:
204: Success
404: Cannot find the employee
- Description: Retrieve all shifting schedules from the database.
- Response Codes:
200: Success
500: Internal Server Error
- Description: Retrieve a specific shifting schedule by ID from the database.
- Request Parameters:
id: string
- Response Codes:
200: Success
404: Schedule Not Found
- Description: Create a new schedule for a specific facility.
- Request Body:
facility: string
(The facility ID for which the schedule is being created)
- Response Codes:
201: Success
400: Invalid Input
- Description: Update the shift hours of a specific schedule by ID.
- Request Parameters:
id: string
- Response Codes:
200: Success
400: Invalid input
500: Internal Server Error
- Description: Delete a specific schedule by ID from the database.
- Request Parameters:
id: string
- Response Codes:
204: Success
404: Schedule Not Found
500: Internal Server Error
- Description: Retrieve all notifications from the database.
- Response Codes:
200: Success
500: Internal Server Error
- Description: Retrieve a specific notification by ID from the database.
- Request Parameters:
id: string
- Response Codes:
200: Success
404: Notification Not Found
- Description: Create a new notification with the specified title and content.
- Request Body:
employeeId: string
message: string
manager: string
- Response Codes:
201: Success
400: Invalid Input
- Description: Delete a specific notification by ID from the database.
- Request Parameters:
id: string
- Response Codes:
204: Success
404: Notification Not Found
500: Internal Server Error