A Dev Container Template for TypeScript and Express.js
Learn how to create a template for a development container for TypeScript and Express.js. Plus a bonus for your npm-based projects!
In previous articles I have described how to set up a dev container for TypeScript (see “Creating a Dev Container for TypeScript and VS Code”, “TypeScript Dev Container Revisited: The February 2023 Edition”). The result is a template repository on github that makes it easy to create and start up a dev container with the basic dev tools preinstalled that you may need.
In this article I will take the concept one step further. This time, I will add everything needed to get a basic express.js application running. This will also serve as a building block to build an OpenID Connect (OIDC) example in a future article.
The usual pre-requisites for this article are:
- VS Code
- VS Code Extension “Remote Development”
- Git CLI
- Docker Desktop
As always, the entire source code for this article is available under the generous MIT license at https://github.com/RimuTec/dev-container-express.js-2023
At the end of this article, we will have a new template that we can then use as a starting point for express.js based apps, either for a micro service or for serving a web application.
Also, as a bonus, I’ll share a technique for keeping npm packages up-to-date with the option to automate it.
Let us get started!
Using the TypeScript Dev Container Template
To get started quickly, I will not set up the dev container from scratch. Instead, I will use a template to create the initial source code. In this case I am going to use the template at https://github.com/RimuTec/dev-container-typescript This gives me most of the boilerplate code and requires just a few small adjustments before we can get to the meaty bits.
Go to the template repo on github, click on “Use this template” and then “Create a new repository”: