Agro DB is your platform to manage and organize agricultural equipment in a simple and agile way.
Use git clone to clone the repository. Then install the dependencies with npm.
git clone git@github.com:returndaniels/agro-db.git
cd agro-db
npm install
In the project directory you can run:
npm start
or npm run dev
/controllers
- Contains all the functions with the logic of the APIs.
/routes
- Contains all routes created using Express Router and what they do is exported from a controller file.
/models
- Contains all schema files.
/database
- Contains the mongodb database connection file.
/index.js
- This file is be the entry point of the Express application.
agro-db/
├── controllers/
├── routes/
├── models/
├── database/
└── index.js
agro-db@1.0.0 /agro-db
├── body-parser@1.19.2
├── cors@2.8.5
├── dotenv@16.0.0
├── express@4.17.3
├── http@0.0.1-security
├── mongodb@4.4.0
├── mongoose@6.2.2
└── nodemon@2.0.15
The project's architecture was based on a simple structure, very common in small projects made in Node.js. It has some traits similar to the MVC design pattern.
Server: https://agro-db-backend.herokuapp.com
This document is a brief manual that will serve as a basis for working on the Project - from the front-end in Node.js - in an independent professional way, maintaining the API standard described in it.
Endpoint: /tractors
This endpoint will be used to add tractors to the system. When using a tractor, the inserted data is returned in the Response json.
{
"name": "Trator Estreito 5EN",
"description": "Tranquilidade e confiança, válido...",
"imageUrl": null,
"modelYear": "2020",
"model": "John Deere 5EN"
}
{
"tractor": {
"name": "Trator Estreito 5EN",
"description": "Tranquilidade e confiança, válido...",
"imageUrl": "https://ik.imagekit.io/returndaniels/logo-agro-db_3-Tm1nl4m.jpg",
"modelYear": "2020",
"model": "John Deere 5EN"
}
}
{
"message": "Tractor name already exists."
}
Endpoint: /tractors
This endpoint will be used to search for all registered tractors.
[
{
"_id":"62127575baa8a55595ca4a7d",
"name":"Trator Estreito 5EN",
"model":"John Deere 5EN",
"modelYear":"2017-01-01T00:00:00.000Z",
"description":"Tranquilidade e confiança, válido...",
"imageUrl":"https://ik.imagekit.io/returndaniels/logo-agro-db_3-Tm1nl4m.jpg",
"createdAt":"2022-02-20T17:08:05.172Z",
"updatedAt":"2022-02-23T15:44:46.536Z",
"__v":0,
"value":null
}
]
Endpoint: /tractors
This endpoint will be used to remove a registered tractor.
{
"name": "Trator Estreito 5EN"
}
{
"message": "Bad request"
}
Endpoint: /tractors
This endpoint will be used to update a registered tractor.
{
"name": "Trator Estreito 5EN",
"data": {
"modelYear": "2021"
}
}
{
"message": "Updated",
"tractor": {
"_id": "62127575baa8a55595ca4a7d",
"name": "Trator Estreito 5EN",
"model": "John Deere 5EN",
"modelYear": "2021-01-01T00:00:00.000Z",
"description": "Tranquilidade e confiança, válido...",
"imageUrl": "https://ik.imagekit.io/returndaniels/logo-agro-db_3-Tm1nl4m.jpg",
"createdAt": "2022-02-20T17:08:05.172Z",
"updatedAt": "2022-02-23T22:16:49.333Z",
"__v": 0,
"value": null
}
}
{
"message": "Bad request"
}