A Dockerized Nodejs Express Boilerplate with TypeScript
Github Project: https://github.com/sidhantpanda/docker-express-typescript-boilerplate
Getting started with TypeScript for your next backend project? Or just want to play around with a TypeScript based Express server? This project’s for you!
Microsoft already has a starter repo. Why this?
There is Microsoft’s starter repo but it requires you to install a bunch of other stuff like MongoDB yourself. The Microsoft repo is a good reference repositories but lacks a lot of stuff when building production applications.
How to get started?
Simple, just run:
$ bash <(curl -s https://raw.githubusercontent.com/sidhantpanda/public/master/scripts/generate-express-ts-app.sh)
Or, if you don’t trust the shell script, clone the repo:
$ git clone git@github.com:sidhantpanda/docker-express-typescript-boilerplate.git your-app-name
Features
- You can spin up Mongo containers and run your Node project with
nodemon
with a single command, and spin them down when you are done. Just run the following command and see it happening:
$ npm run dev
Pressing Ctrl + c
will stop the server and remove all mongo containers. All the data in Mongo is persisted between the runs at data/dev/mongo
.
- This project also contains instructions to dockerize your application from the get go, so you get to learn Docker along with it, or experienced developers can directly start configuring the
Dockerfile
ordocker-compose.yml
files. - A custom middleware for easier
async/await
for your request handlers. This allows you to write less verbose and eliminate having to writetry-catch
blocks in your request handlers every time you want to write anasync
method. Justthrow
any error and the handler will catch it and pass it on to the Express error handler. - Sample mongoose model written in TypeScript. Lets you kick-start data modelling.
- Comes with a sample Open API 3.0 spec file so you can get started with API documentation directly.
- All configuration done through
.env
file. - ESLint + Prettier — Linting and formatting from the start
- Winston as the default logger to generate debug and error log files during application lifetime.
- Pre-configured Travis CI for that automation goodness.