jithinlal / seed-node-ts-express-docker-test

A node seed with typescript as the language with docker and test using jest inbuilt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation instructions

  • run npm install or yarn to install all the packages
  • run npm run dev to run the application in the development environment
  • run npm run build to build the app in a production setting
  • run npm start to start and run the API
  • in order to test the application code npm run test can be used. In case if any caching problems or tests not running completely just press a to run all the tests, and run the test command with -- --clearCache
  • and in order to get the coverage report of the test one can use npm run test:coverage
  • one can change the base url of the shortened service in the .env file

OPEN API SPECIFICATION has been followed to document the routes (this can be seen in the routes file with .yaml file and within route file as comments), but in order to build and host it one need another tools, which is not implemented, but one can easily do it with the following packages:

  • openapi-comment-parser (1.0.0)
  • swagger-ui-express (for front end hosting)

One can also use docusaurus which is considered modern

Database is not considered, but one can easily change up the implementation within the data-access folder and bring in database

Following packages are used for better development workflow:

  • prettier
  • commitlint
  • husky
  • eslint

And the following tools can be introduced to make the development much more easier;

  • docker

The following code piece can be implemented for better performance and optimization:

  • rate limiting - to secure the API calls from DDoS
  • a redis cache layer, to reduce the hit on the DB layer (if one is implemented later on)

Examples

Encode

  • curl -d '{"url": "https://www.example.com"}' -X POST -H 'Content-Type: application/json' http://localhost:3000/api/1.0/dev/url/encode
  • response : {url: "https://short.est/OCscMSicYJ"}

Decode

  • curl -d '{"url": "https://short.est/OCscMSicYJ"}' -X POST -H 'Content-Type: application/json' http://localhost:3000/api/1.0/dev/url/encode
  • response : {url: "https://www.example.com"}

About

A node seed with typescript as the language with docker and test using jest inbuilt


Languages

Language:TypeScript 97.9%Language:Shell 1.0%Language:Dockerfile 1.0%