Responsible for provide data to the web and mobile front-ends. Permit to register orphanages. The app has validation, also a simple versioning was made.
Easy peasy lemon squeezy:
$ yarn
Or:
$ npm install
Was installed and configured the
eslintandprettierto keep the code clean and patterned.
The application use just one database: SQLite. For the fastest setup is recommended to use docker-compose, you just need to up all services:
$ docker-compose up -d
In this file you may configure your app's port and a url. Rename the .env.example in the root directory to .env then just update with your settings.
| key | description | default |
|---|---|---|
| APP_PORT | Port number where the app will run. | 3333 |
| BASE_URL | App's url. | http://localhost:3333 |
Store the orphanages. For more information to how to setup your database see:
You can find the application's
ormconfig.jsonfile in the root folder.
Remember to run the database migrations:
$ yarn ts-node-dev ./node_modules/typeorm/cli.js migration:run -- -d ./src/database/datasource.ts
Or:
$ yarn typeorm migration:run -- -d ./src/database/datasource.ts
See more information on TypeORM Migrations.
To start up the app run:
$ yarn dev:server
Or:
npm run dev:server
A simple versioning was made. Just remember to set after the host the /v1/ string to your requests.
GET http://localhost:3333/v1/orphanages
| route | HTTP Method | params | description |
|---|---|---|---|
/orphanages |
GET | - | Lists orphanages. |
/orphanages/:id |
GET | :id of the orphanage. |
Return one orphanage. |
/orphanages |
POST | Body with new orphanage form data (See insomnia file for good example). | Create a new orphanage. |
POST /orphanages
Request body:
{
"name": "Hackett, Becker and Fadel",
"latitude": -85.8713,
"longitude": -73.3957,
"about": "Adipisci cupiditate illo rerum sunt tempore. Non voluptate laborum enim hic tenetur perspiciatis sint. Quo totam recusandae dolores et ullam commodi. Ut consectetur saepe id voluptatem et quidem. Dolor neque consequuntur ipsa. Placeat sit aut nostrum similique dolorem voluptatem et velit enim.",
"instructions": "Venha visitar",
"opening_hours": "Das 8h às 18h",
"open_on_weekends": true,
"images": <file(s)>
}
Jest was the choice to test the app, to run:
$ yarn test
Or:
$ npm run test
You can see the coverage report inside tests/coverage. They are automatically created after the tests run.