Task was done using node.js with express.js. It was written using TypeScript. Sequelize was used to communicate with database, and give database was PostgreSQL.
Used recommended es-lint rules for typescript.
Docker image was created and pushed to Docker Hub
vlatkovicb/farm-simulator:1.6
To create a cointainer run
docker compose up
In case image is not being pulled from docker hub use:
docker build -t vlatkovicb/farm-simulator:1.6 .
In order to use API you need to create couple of buildings and assign units to them.
Available routes are forwarded to http://localhost:8080/
Methpd | Route |
---|---|
GET | /unit |
GET | /building |
POST | /unit |
POST | /building |
PUT | /unit/feed/{id} |
Retrives all units.
Create a unit. Send json in format of:
{
"name": "Unit name",
"buildingId": 1
}
Retrives all buildings.
Create a building. Send json in format of:
{
"name": "Building name",
}
Feed a single unit with a given id (unitId).