Last active
May 9, 2021 20:47
-
-
Save rfbatista/265252e0fda4141e19a7109eb4e56f9a to your computer and use it in GitHub Desktop.
Setup for express with typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir server | |
cd server/ | |
npm init --yes | |
yarn add express | |
echo "Creating index file..." | |
cat <<EOF > ./index.ts | |
import express from 'express'; | |
// rest of the code remains same | |
const app = express(); | |
const PORT = 8000; | |
app.get('/', (req, res) => res.send('Express + TypeScript Server')); | |
app.listen(PORT, () => { | |
console.log(`⚡️[server]: Server is running at https://localhost:${PORT}`); | |
}); | |
EOF | |
yarn add -D typescript ts-node | |
echo "Creating tsconfig file" | |
cat <<EOF > ./tsconfig.json | |
{ | |
"compilerOptions": { | |
"target": "es6", | |
"module": "commonjs", | |
"rootDir": "./", | |
"outDir": "./build", | |
"esModuleInterop": true, | |
"strict": true | |
} | |
} | |
EOF | |
echo "Creating package.json file" | |
cat <<EOF > ./package.json | |
{ | |
"name": "inbound-express", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "nodemon ./src/index.ts", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.17.1" | |
}, | |
"devDependencies": { | |
"@types/express": "^4.17.11", | |
"@types/node": "^15.0.2", | |
"nodemon": "^2.0.7", | |
"ts-node": "^9.1.1", | |
"typescript": "^4.2.4" | |
} | |
} | |
EOF | |
yarn add -D @types/node @types/express | |
yarn add -D nodemon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment