A minimal Express.js server in Typescript with Live Reloading. Ready to be hosted on heroku.
npm install
npm run dev
Server is ready at http://localhost:3000.
Edit src/index.ts
, save file, server restarts automatically, refresh your browser to see the changes.
Files in the public/
folder are served statically, see http://localhost:3000/cover.jpg.
Create a .env
file:
PORT=3000
STRIPE_PRIVATE_KEY=blablabla
Env vars are available in your app, eg. process.env.STRIPE_PRIVATE_KEY
.
It is good practice to:
- not commit your
.env
file - keep
.env.example
updated with empty value for sensitive key
Scripts in package.json
:
npm run dev
runs the server and automatically restart the server when a change is made insrc
folder.npm run build
generates.js
files from*.ts
files.npm run start
runs the node server from the generatedindex.js
.
This minimal project can be hosted on any platform that runs nodejs apps, such heroku, digital ocean, deta, etc.
Has been successfully deployed on heroku, see: https://expressjs-with-typescript.herokuapp.com/