https://dev.to/hte305/simple-deploy-typescript-application-to-heroku-5b6g
mkdir simple-deploy-app-typescript-to-heroku
automatic create new file package.json
cd simple-deploy-app-typescript-to-heroku
npm init -y
npm i @types/express @types/node express nodemon ts-node typescript
automatic for create new file tsconfig.json
sudo npm install typescript -g
tsc --init
"include" : [
"src/**/*.ts" /* Include every ts file in source folder */
],
"exclude" : [
"node_modules" /* exclude everything in node_modules */
]
Edit file package.json
"compilerOptions" : {
//**/
},
"scripts": {
"start": "ts-node src/config/server.ts",
"dev": "nodemon -x ts-node src/config/server.ts"
},
Server script would live in src/config/server.ts
Create a new simple server with express now. src/config/server.ts
import express from 'express';
const app = express()
const PORT : string|number = process.env.PORT || 4000;
app.use("*",(req, res) =>{
res.send("<h1>Welcome to your simple server! Awesome right</h1>");
});
app.listen(PORT,() => console.log(`hosting @${PORT}`));
npm run dev