A highly scalable and a focus on performance and best practices boilerplate code for Nodejs and TypeScript based web applications.
Start a new application in seconds!
Features
-
Quick scaffolding
Create actions, routes, and models - right from the CLI using Plop micro-generator framework.
-
TypeScript
The best way to write modern applications. Code is easier to understand. It is now way more difficult to write invalid code as was the case in dynamically typed languages
-
Dependency injection
DI is a central part of any nontrivial application today and is the core of this project.
-
Static code analysis
Focus on writing code, not formatting! Code formatter and linter keeps the code clean which makes work and communication with other developers more effective!
Note If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.
Don't forget to star or fork this if you liked it.
Configuration
After checkout of a repository, please perform the following steps in exact sequence:
-
Copy docker-compose.override
$ cp docker-compose.override.yml.dist docker-compose.override.yml
-
Create
.env
file from.env.dist
$ cp .env.dist .env
Remember to fill up required values in
.env
-
Run
npm i
-
Run
npm run docker-build
-
Run watch -
npm run watch
Dev setup
This app is fully dockerized, so in order to use it you have to have docker and docker-compose installed. What's more you need to have npm in order to run npm scripts.
-
In order to run the whole app type:
npm run start
-
In order to watch files for dev purpose type:
npm run watch
-
If you need to close all containers run:
npm run down
-
To get into Docker container's shell:
npm run shell
Code generation
We're using Plop for routes, models, actions, graphql (queries and mutations), commands and handlers generation.
npm run plop
Code style
We're using Prettier and ESLint to keep code clean. In order to reformat/check code run:
npm run lint
npm run format
Database migrations
Migrations should be stored inside migrations directory.
Easiest way to create a migration is to generate it from entity/ies:
npm run generate-migration
This should generate a migration for all connected entities.
Adminer setup
Adminer is configured in docker-compose.override.yml
and should work out of the box on port 8080. To login to adminer use the following values:
Database type: postgres
Server: postgres
User: postgres
Password: password
Database: app
Of course, if any of this is changed via configuration or otherwise, then these changes must be reflected here as well.
GraphQL
Boilerplate has GraphQL support. Apollo server runs as a middleware and should be available locally under:
http://localhost:1337/graphql
To add new query/mutation run relevant plop
commands and then:
- Modify
schema.gql
undergraphql/schema.gql
- Run codegen:
npm run generate-schema
- Restart watcher / API
Debugging
VS Code
There is launch.json
configuration inside editors/vsc
directory. Just copy it and create new debugger to make it work with vsc :)
Tests
There are two types of tests:
- integration:
npm run integration
- units:
npm run units
Issues:
If you notice any issues while using, let as know on github. Security issues, please sent on email
You may also like our other projects:
About us:
License
This project is licensed under the terms of the MIT license.