Minimal express app written in typescript that includes npm scripts to lint, compile and copy assets to dist directory and the ability to run the app in the vscode debugger.
npm install
npm start
Browse to http://localhost:3000 and http://localhost:3000/users/:user
- Create vscode debug config .vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "npm run debug:start",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug:start"
],
"port": 9229,
"outputCapture": "std"
}
]
}
- Set a breakpoint in the top of ./src/app.ts
- Click run
- Select "npm run debug:start" from the dropdown
- Click play
I got a lot of information for this setup from several different articles:
General express / typescript articles:
Use TypeScript to Build a Node API with Express
How (and why) you should use TypeScript with Node and Express.
How to set up an Express.js API using Webpack and TypeScript.
Create a server with Nodemon + Express + Typescript
With VSCode debug instructions:
Visual Studio Code: Node.js with TypeScript and Debugging
Debugging TypeScript in VS Code without compiling, using ts-node
Debugging Node.js apps in TypeScript with Visual Studio Code