This is the API based on Node.js which utilizes several libraries such as:
serverless
aws-sdk
dynamodb
- First of all, we need to make sure that all prerequisites are installed in order to run the server. Begin installing the following items:
-
After this components and tools are installed, we need to checkout the code from repository: https://github.com/chrisepm/andlar-api.
-
Go to the root folder which is where server.js and package.json file are, then download all dependencies included running the command:
npm install
This command should download and install all current dependencies:
aws-sdk 2.518.0 dynamoose 1.11.0 uuid 3.3.3 supertest 4.0.2
-
Finally, go to root folder and execute the command below to deploy the service.:
sls deploy
npm run test
-
If you want to deploy to dev environment, then:
sls deploy --stage dev
-
If you want to deploy to prod environment, then:
sls deploy --stage prod
The following examples can be executed using Postman tool as client.
Some of the GET
actions that are included in the API can be executed directly in a common browser such as Google Chrome.
Body content or parameters for all POST actions called from the client, should be in the form of json or x-www-form-urlencoded format.
The endpoints should be like this:
- POST - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author
- GET - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author
- GET - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author/{id}
- PUT - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author/{id}
- DELETE - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author/{id}
- POST - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/author/filter
- POST - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication
- GET - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication
- GET - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication/{id}
- PUT - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication/{id}
- DELETE - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication/{id}
- POST - https://qh5otqm0t4.execute-api.us-east-1.amazonaws.com/dev/publication/filter