This is a Koa simple application used for testing purposes that exposes few endpoints.
- Fork the public repository https://github.com/GanazHQ/SimpleAPI.git
- Have Node 16.x.x installed locally
- Have a Rest client installed locally, preferably Postman to quickly test the endpoints
- You must know that this project has Jest configured by default, but you are able to use any other testing framework
Once you have the public repository locally, go to the SimpleApi
directory.
- Install dependencies:
yarn
- Build:
yarn build
- Start the application:
yarn start
- Two endpoints will be available once the app is started:
GET
method:http://localhost:9999/api/foo/X
whereX
can be any numberPOST
method:http://localhost:9999/api/foo
where the body must be like{ id: X }
andX
can be any number
- The application is ready to use
Jest
framework for your test cases
- GET
http://localhost:9999/api/foo/X
- If
X
is divisible by 2, it returns200
code withOK
message - If
X
is not a number, it returns400
code withERROR: Value X is not a number
message - Otherwise, it returns
501
error code
- If
- POST
http://localhost:9999/api/foo
- If body
{ id: 1 }
, it returns200
code withbar
message - If body
{ id: 2 }
, it returns200
code withbass
message - If body
{ id: anynumber }
, it returns200
code withunmatched
message - If body does not contain property
id
, it returns400
code withERROR: JSON body must contain id property
message
- If body