Skip to content

Instantly share code, notes, and snippets.

@robozavri
Last active September 10, 2020 08:10
Show Gist options
  • Save robozavri/c775c062955c10e2de4bd8a134b7da64 to your computer and use it in GitHub Desktop.
Save robozavri/c775c062955c10e2de4bd8a134b7da64 to your computer and use it in GitHub Desktop.
#node.js typescript #typescript
cd server/
npm init --yes
npm i express
import express from 'express';
// const express = require('express');
// rest of the code remains same
const app = express();
const PORT = 8000;
app.get('/', (req: any, res: any) => res.send('Express + TypeScript Server'));
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});
/*
tsc index.ts და გადაიყვანს ჯავასცრიპტში
tsc index.ts -w ჩაირთვება watch mode
*/
npm i -D @types/node @types/express nodemon typescript ts-node
tsc --init
// need set "outDir": "./dist", AND "rootDir": "./src", AND uncomment "moduleResolution": "node", to tsconfig.json
package.json:
"scripts": {
"start": "node dist/index.ts",
"dev": "nodemon src/index.ts",
"build": "tsc -p ."
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment