- Heroku app: https://meli-search-api.herokuapp.com/
Requirements:
- Node v12.16.1
- Clone the project:
git clone [email protected]:rjpizarro/meli-search-API.git
- Install dependencies:
npm install
- Configure
.env
file:- rename
.env.example
to.env
- rename
- Run:
npm start
meli-search-API
├── .env
├── babel.config.js
├── envConfig.js
├── jest.config.js
├── package.json
├── tsconfig.json
├── build
├── node_modules
└── src
├── app.ts
└── api
├── controllers
│ └── items
├── middlewares
├── routes
└── services
└── items
At the project root level you will find all the config files for typescript and babel. There is also an envConfig
that get the data from the .env
and configure the keys to be used easily in the rest of the files.
Folders like build
and node_modules
are generated after transpile or when installing a dependency, respectively
Creates the express app and configures the main routes.
This folder contain all the API logic organized in:
- controllers: It processes each request and returns a response. It should exist only one controller per file. As a rule, a controller only can access data through Services.
- services: Are in charge to access the data. Should tackle only one task (find, update, delete, etc). A service can't import another service. It is the controller's scope to use more than one service to get all the data required.
- routes: It defines the resources for the RestAPI. It uses controllers for each route and adds middlewares when needed.
- middlewares: It contains express middlewares for tasks like error handling, etc.
Search an item using https://api.mercadolibre.com/sites/MLA/search?q=
Params:
- q: String. Query value to search
- limit: Number. Limit the results quantity
Response:
{
"author": {
"name": String,
"lastname": String
},
"categories": [String],
"items": [{
"id": String,
"title": String,
"price": {
"currency": String,
"amount": Number,
"decimals": Number
},
"picture": String,
"condition": String,
"free_shipping": Boolean
}]
}
Retrieve an item with description by ID.
Response:
{
"author": {
"name": String,
"lastname": String
},
"item": {
"id": String,
"title": String,
"price": {
"currency": String,
"amount": Number,
"decimals": Number
},
"picture": String,
"condition": String,
"free_shipping": Boolean,
"sold_quantity": Number,
"description": String
}
}
Run the application with nodemon
and ts-node
Transpile typescript files into build
folder and run the output with node
Run jest
test suite.
For development purposes. It allows run one file.
Transpiles typescript files and creates the build
folder.