npm i
npm run start
This project uses jest and supertest for testing.
npm run test
Run all testnpm run test:int
Run Integration Testsnpm run test:unit
Run unit tests
- Make sure you have the aws cli configured.
- Create IAM user for serverless frawework. And create a policy for it using the least previlege principle. Learn more about this is here.
- Generate AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
- Configure aws cli to use the recently created keys or export them inline as follows:
export AWS_ACCESS_KEY_ID=<your-key-here>
export AWS_SECRET_ACCESS_KEY=<your-secret-key-here>
export AWS_DEFAULT_REGION=us-west-2
- run
npm run build
- run
serverless deploy
or
- run
npm run deploy
Lint the project by running npm run lint
small fixes are done automaticallly.
- This API is using
typescript
. - This API is usign
mongodb
library to communicate with the database. - The API code is organized by modules. This is means each endpoint will have its own sufolder inside the
src/app
folder. - It is intented that each module has the following files:
- Routes -> Middleware(optional) -> Controller -> Service -> Entity.
- Integration tests use in memory db, see
src/common/tests/TestFactory.ts
- This project uses serverless framework to provision and deploy, instead of Terradorm or Cloudformation to provision and a proper pipeline to deploy.
- This API runs using Lambda for computing instead of ECS or EC2. Colds starts can be solved by using Provisioned Concurrency.
- Basic authentication is implemented.
- This api has a basic token based auth method using the fixed token
getir-challenge
. - This api has a basic pagination implemented the default is 100 rows per page, it can be modified trough the query string parameter
?limit=10
- POST https://{api_url}/v1/records?limit=100 (passing the limit in this way for a POST request feels strange for me , i would have used GET instead)
- POST https://{api_url}/v1/records
- GET https://{api_url}/v1
- GET https://{api_url}/v1/records -> 404
{
"startDate": "2016-01-26",
"endDate": "2018-02-02",
"minCount": 0,
"maxCount": 100
}
- Delivering a Working RESTful API.
- Clean and Production Ready Code
- Error Handling
- Comments and Documentation
- Unit and/or Integration Tests (Jest is preferable but Mocha also works)
- Avoid Over Engineering
- Set up
- Connect to DB
- Build Service, Repo ( modular app )
- Tests
- Deploy
- Pagination
- Authentication