/koa-typescript-boilerplate

Koa Typescript Boilerplate

Primary LanguageTypeScript

KOA Typescript Boilerplate

Description and Motivations

This project is intended to be a personal boilerplate, but also built for the community. It will help in further personal projects, having a good fork-able project.
As you will see, there is an example CRUD controller, but no ORM DB library is installed. This is because the project is intended to be the most flexible, allowing the dev to use the service as it may like the most.

Technologies

The boilerplate contains the following technologies:

Project structure

The structure allows the developer to split the code following the single-responsibility principle, so it contains folders for:

  • constants: the constants that can be created inside the project
  • controllers: folder for the various service controllers;
  • errors: list of errors of the application;
  • mocks: mocks that will be useful mainly for testing;
  • routes: list of routes files;
  • tests: this is the test folder and all the test files placed here will be run by Jest;
  • types: folder for the types declaration in the project;
  • validators: this folder contains validators written in Joi and fungible as middleware.

Development commands

If you use nvm, in order to use the right node version run:

nvm use

After this, install the dependencies with:

npm i

Run the server

To run the server, just execute:

npm start

Development server

To run the server in listening mode, run:

npm run dev

Test the application

To run the test suite, just run:

npm test

Build the application

To build the service, that will produce a /build folder as output, run:

npm build