how to use start my express aplication #144723
-
Select Topic AreaQuestion Bodyhey, i am new in this community and a i have a question, how i config git hub pages to start my express application in ts and run a exemplo in pages. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Configurar o Backend (Express com TypeScript) mkdir express-ts-app { import express from 'express'; app.get('/', (req, res) => { app.listen(port, () => { npx ts-node src/index.ts Instale o gh-pages para deploy: npm install gh-pages --save-dev "scripts": { npm run deploy |
Beta Was this translation helpful? Give feedback.
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
…