DEV Community

Cover image for Nodejs Boilerplate with Typescript and Express
Shivam Singh
Shivam Singh

Posted on

Nodejs Boilerplate with Typescript and Express

Assume you wish to begin a new project in a safe and consistent development environment. In such situation, you may need to configure things like "linters," code style tools, test frameworks, git hooks, and so on. This blog includes all of the tedious configuration so you can focus on the fun part, coding.
The concept is comparable to scripts such as create-react-app.
I'll go over how to utilise and the tools included in this boilerplate shortly below.

embed The GitHub project contains more details :)

Starting a New Project

Install TypeScript Node and global TypeScript.



npm install -g typescript ts-node 


Enter fullscreen mode Exit fullscreen mode

Clone this repository



git@github.com:shivamsingh478/nodejs-typescript-express-boilerplate.git


Enter fullscreen mode Exit fullscreen mode

The cloned repository will look like this:-

Image description

Then Install all the dependdencies



npm install


Enter fullscreen mode Exit fullscreen mode

Run the Application



npm run start


Enter fullscreen mode Exit fullscreen mode

Build the Application



npm run build


Enter fullscreen mode Exit fullscreen mode

Tooling

These are the tools already configured on this boilerplate:

ESLint and Prettier assure proper code style and practises.
Commit, Husky, and Lint Staged Lint guarantees that no files are committed that do not adhere to project requirements.
Jest is a test framework that includes ts-jest for TypeScript.
Nodemon is used to reload the programme when it is modified.
Docker is used for local development, and it includes a Dockerfile that creates a minimal image with gcr.io/distroless/nodejs.

If you're interested in learning more, check out the source code at https://github.com/shivamsingh478/nodejs-typescript-express-boilerplate.

Thanks for reading, and I hope you enjoy :)

Top comments (0)