Typescript Express Boilerplate
This boilerplate is a generic “template” for a web application based on following modules:
Type | Module |
---|---|
![]() |
ExpressJS 4 |
![]() |
TypeORM |
![]() |
Winston |
![]() |
|
![]() |
|
![]() |
|
![]() |
by faudas |
Made in Italy
$ git clone https://github.com/d4rkstar/ts-express-boilerplate.git my-awesome-project
$ cd my-awesome-project
$ yarn install
$ yarn run build
If you need, create a database
Copy .env.example to .env
Edit .env file and put required variables
Migrate database
To run tests
$ yarn run test
$ yarn run start
Before start coding, ensure to:
git init .
inside the project folder and adding files with git add .
git remote set-url origin <url>
publish.sh
script command:
$ ./publish.sh "my-awesome-project" "My Awesome Project API Endpoint test" "Me"
File package.json was updated!
💥 Removing CircleCI original dir
💥 Removing Art original dir
🖋️ Generating new README.md
🔥 Republish Completed!
If you need to use database and typeorm:
If you don’t need to use database and typeorm:
To add new routes and routers, check the App::mountRoutes
method.
It’s quite simple to add new routes!
$ docker build -t ts-express-boilerplate .
$ docker run -d -p 3000:3000 --name ts-express-boilerplate ts-express-boilerplate:latest
Create an entity
$ yarn run typeorm entity:create src/entities/User
and modify at your needs. Then generate migration for this Entity:
$ yarn run typeorm migration:generate -d dist/Datasource.js src/migrations/use
Finally run migrations:
$ yarn run migrate-dev
Info: migrate-dev will build js source before run migrations. If you need to run migrations in prod (!!), you can
consider the migrate script.
Adjust datasources at your needs.
I suggest reading this useful article:
Using ESLint and Prettier in a TypeScript Project
To activate ESlint in Webstorm, follow this link:
To use ESlint from command line:
$ eslint --fix --ignore-path .eslintignore src/*.ts