Skip to content

KjellKod/SimpleAPI

 
 

Repository files navigation

Simple API

This is a Koa simple application used for testing purposes that exposes few endpoints.

First, You must

  1. Fork the public repository https://github.com/GanazHQ/SimpleAPI.git
  2. Have Node 16.x.x installed locally
  3. Have a Rest client installed locally, preferably Postman to quickly test the endpoints
  4. You must know that this project has Jest configured by default, but you are able to use any other testing framework

Steps to run the application

Once you have the public repository locally, go to the SimpleApi directory.

  1. Install dependencies: yarn
  2. Build: yarn build
  3. Start the application: yarn start
  4. Two endpoints will be available once the app is started:
    1. GET method: http://localhost:9999/api/foo/X where X can be any number
    2. POST method: http://localhost:9999/api/foo where the body must be like { id: X } and X can be any number
  5. The application is ready to use Jest framework for your test cases

What the endpoints do

  1. GET http://localhost:9999/api/foo/X
    1. If X is divisible by 2, it returns 200 code with OK message
    2. If X is not a number, it returns 400 code with ERROR: Value X is not a number message
    3. Otherwise, it returns 501 error code
  2. POST http://localhost:9999/api/foo
    1. If body { id: 1 }, it returns 200 code with bar message
    2. If body { id: 2 }, it returns 200 code with bass message
    3. If body { id: anynumber }, it returns 200 code with unmatched message
    4. If body does not contain property id, it returns 400 code with ERROR: JSON body must contain id property message

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 61.1%
  • TypeScript 37.1%
  • Shell 1.8%