If you want to get clear Idea of this API docuemntation please refer to this link for the wireframe
S.No | Reason | Status Code |
1. | All Okay | 200 |
2. | Created | 201 |
3. | No Content | 204 |
4. | Not Modified | 304 |
5. | Bad Request | 400 |
6. | Unauthorized Access | 401 |
7. | Forbidden | 403 |
8. | Content Not Found | 404 |
9. | Internal Server Error | 500 |
So what are the basic requirements before using these API's are given below:
- You have the Environment in your laptope of any Scripting Language like Node JS (mostly preffered), Python(can go with flask and Django), .Net and many more.
- You have to install any database here whether it is an SQL(MongoDB), No SQL(mySql, Orcale Server) or GraphQL.
- Database can also be hosted on the Online Platforms also like GCP, AWS, Microsoft Azure, M-Lab, MongoDB Atlas.
- Now to test the API's there is a need of the API development environment, and flexibly integrates with the software development cycle like Postman.
- For Node Js Click me
- For MongoDB Click me
- For Python Flask
- For GCP Click me
- For Heroku Cick Me
- For Postman Click me(For API Environmnet)
So for now we are in designing phase So we consider our base URL for the API's as
https://localhost:3000/
and It will be cover with the Role based Access control with the help of express js and we also shown below in the Authentication
I used express-session to manage sessions to authenticate. We have isUserLoggedIn, isUserLoggedOut middleware function which checks if the user is authenticated or not. The session token is stored in the database using connect-mongo package and is deleted when the user logout
async function isUserLoggedIn (req, res, next) {
try {
if (!(req.session && req.session.user)) {
return res.status(401).send({
error: "Unauthorized Access!"
});
}else {
const user = await User.findOne({ _id : req.session.user._id })
if(user) {
next();
} else {
req.session.user = null;
return res.status(401).send({
error: "Unauthorized Access!"
});
}
}
} catch(e) {
res.status(400).send({
error: e
})
}
}
// Function to check whether the user is logged out
function isUserLoggedOut (req, res, next) {
if (req.session && req.session.user) {
return res.status(200).send({
message: "User already Logged In!"
});
}
next();
}
module.exports = {
isUserLoggedIn,
isUserLoggedOut
}
S.No. | Route | Method | Parameters | Description |
---|---|---|---|---|
1. | /mech/login | POST |
|
For Login into the System |
2. | /customer/:id | GET |
|
Getting all the details of customers |
3. | /mech/:id | GET |
|
All the details So can see his dashboard |
4. | /customer/:id | PUT |
|
For updating the customers Schema's after finishing the Work. |
S.No. | Route | Method | Parameters | Description |
---|---|---|---|---|
1. | /client/register | POST |
|
Creating a new Client. |
2. | /client/:id | PUT/GET |
|
Fixing the meeting and chat also.Apart from this Finance can also Set notes to a particular Client. |
3. | /mech/:id | PUT/GET |
|
So that finance team can update the Accounts of the Technician. |
4. | /dataAnyaltics | GET |
|
This will directly come from the database so that any FrontEnd Framework like React Js and Angular JS can be used to make the Graphs |
5. | /client/:id | PATCH |
|
For getting more details and set additional features to the Client. |
S.No. | Route | Method | Parameters | Description |
---|---|---|---|---|
1. | /mech/:id | GET |
|
To check the Attendance of techanician |
2. | /emp/:id | GET |
|
To check the Attendance of Employees and also the othr features from this only(ex:birthday). |
3. | /hr/message/:id | POST |
|
Messaging feature between different departments. |
4. | /hr/:id | GET |
|
getting diffeent query and solved them. |
*this is not mandatory parameters to pass into the API's
S.No. | Route | Method | Parameters | Description |
---|---|---|---|---|
1. | /mech/:id | GET |
|
Getting the status of the Technician. |
2. | /fleet/:hotspot | GET |
|
Getting all the maps details from the API. |
3. | /fleet/message/:id | POST/PUT |
|
Messaging feature between different departments and getting hostory also. |
This api can be hosted on platform like heroku, aws, and others. MongoDB Atlas or Matlab can be used for remote database. For instance, the application can be deployed on Heroku by creating and registering an account. Following, create a new app and choose a deployment method (terminal or github) and follow the instruction there. Remote database can be created using Mongodb Atlas or Matlab. For Mongodb Atlas, you need to just to create your account and make a new cluster and link the cluster to your application through a URL. Following the given steps, you would have a remote application up and running.