Skip to content

how to use start my express aplication #144723

Closed Answered by 21hs
Bobonimo111 asked this question in Pages
Discussion options

You must be logged in to vote

Configurar o Backend (Express com TypeScript)
Crie o projeto Express com TypeScript:

mkdir express-ts-app
cd express-ts-app
npm init -y
npm install express
npm install typescript ts-node @types/node @types/express --save-dev
Crie o arquivo tsconfig.json:

{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"strict": true
},
"include": ["src/**/*"]
}
Crie o arquivo src/index.ts:

import express from 'express';
const app = express();
const port = 3000;

app.get('/', (req, res) => {
res.send('Hello from Express!');
});

app.listen(port, () => {
console.log(Server running on http://localhost:${port});
});
Execute o servidor:

npx ts-node src/index.ts

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Bobonimo111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pages Host a static website, right from your repo Question
2 participants