/express-ts-template

express-ts-template used in MEAN-TS by @pouladpld.

Primary LanguageTypeScript

Express Typescript Template

Getting Started

Install

Fetch dependencies:

npm install

Build

To run the build, use either of the following:

# For production build:
node build.js prod
# For development build:
node build.js dev
# or
node build.js

Run

Express app listens on port 3000.

npm start

Mongo DB

Run Mongo DB. Express app connects to express-ts database by default.

If you use Docker, you can run the following container:

docker run --detach --publish 27017:27017 --name express-ts-mongo mongo

Development

Express

Express app is written in TypeScript and transpiled files are placed in dist/. The entry point of the app is www.js module. It runs the transpiled JS files in dist/.

Debug Express in VS Code

If you use Visual Studio Code, there are configurations to help you with debugging the app.

  1. Open app in VS Code
  2. Press Ctrl + Shift + B (Run Default Build Task) to watch TS files in "src/" and transpile them in background
  3. Press F5 to debug TS files

Configurations

Mongo Db connection string can be set in the config files or as a APP_MONGO environment variable.

If an app configuration is available both in a file and as environment variable, environment variable wins.