Skip to content

giaungo/marvel-node-express-openapi-swagger-redis-jest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play MARVEL Characters API with NodeJS, ExpressJS, Open API, Swagger, Redis and Jest

Requirements

Environment variables

  • Create .env file at the project root directory
SERVER_PORT=8080

REDIS_PORT=6379
REDIS_HOST=localhost
REDIS_TIMEOUT=2000
REDIS_KEY_PREFIX=giaunv-
REDIS_TTL_MARVEL=3600

MARVEL_PUBLIC_KEY=
MARVEL_PRIVATE_KEY=
MARVEL_BASE_URL=https://gateway.marvel.com
  • Obtain MARVEL Developer API private + public keys and fill the value to MARVEL_PUBLIC_KEY and MARVEL_PRIVATE_KEY

Run the application

  • Redis server has to be started before the application server, can be started with redis-server command

  • Start the application server with npm start command at the project root directory, the script is configured inside package.json

Open API with Swagger

  • Open API documentation is defined in open-api-doc.js file, the UI is provided by swagger-ui-express module

  • Once the server started, you can explore the Open API at http://localhost:8080/api-docs or http://localhost:8080

Run tests with coverage

  • Run unit tests with npm test command at the project root directory, the script is configured inside package.json

  • This project only implements unit test cases for marvel/marvel-controller.js file as others are config files

  • Unit tests are implemented with Jest https://jestjs.io/ in tests/marvel-controller.test.js file, all test cases are passed with 100% coverage

----------------------|---------|----------|---------|---------|-------------------
File                  | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------------------|---------|----------|---------|---------|-------------------
All files             |     100 |      100 |     100 |     100 |                   
 marvel-controller.js |     100 |      100 |     100 |     100 |                   
----------------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total

About

Play MARVEL Characters API with NodeJS, ExpressJS, Open API, Swagger, Redis and Jest

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published