Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brinobruno/agriculture-api
https://github.com/brinobruno/agriculture-api
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/brinobruno/agriculture-api
- Owner: brinobruno
- Created: 2024-01-16T22:44:50.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-02-06T19:28:30.000Z (11 months ago)
- Last Synced: 2025-01-06T18:18:52.145Z (9 days ago)
- Language: TypeScript
- Size: 217 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REST API - Brain agriculture
## Pre-requisites
- Node 18
- Yarn/NPM## Getting started
git clone https://github.com/brinobruno/agriculture-api
## Running the app with Docker
### Build images and run the containersdocker compose up -d --build
### Run migrations
Enter execute a command in running container (api container - check with docker ps -> CONTAINER ID)docker exec -it CONTAINER_ID /bin/bash
then:
yarn migration:run
### Seed database
Enter execute a command in running container (api container - check with docker ps -> CONTAINER ID)docker exec -it CONTAINER_ID /bin/bash
then:
yarn seed NUMBER_OF_PRODUCERS
## Running the app without Docker
Create database and add .env and...### Install dependencies
yarn### Run migrations
yarn migration:run### Seed database
yarn seed NUMBER_OF_PRODUCERS### Run the app
cd
yarn dev### Run the tests (after running migration on testing db)
yarn test## Docs (endpoints)
`GET /api/v1/docs` (Browser)### Producers
`POST /api/v1/producers``GET /api/v1/producers`
`GET /api/v1/producers:id`
`PUT /api/v1/producers:id`
`DELETE /api/v1/producers:id`
### Dashboard
`GET /api/v1/dashboard``GET /api/v1/dashboard/total-quantity`
`GET /api/v1/dashboard/total-hectares`
`GET /api/v1/dashboard/farms-by-state`
`GET /api/v1/dashboard/farms-by-crop`
`GET /api/v1/dashboard/land-usage-ratio`
## Troubleshooting
In case you have a postgres service already running, you may have database_port problems, in that case, run:sudo service postgresql stop
...or equivalent of stopping postgres service