Skip to content

Commit

Permalink
Set-up Typescript, ESLint, Prettier, ts-node-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
one-aalam committed Jul 10, 2021
1 parent c29b77e commit 856878f
Show file tree
Hide file tree
Showing 9 changed files with 1,331 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_PORT=3000
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12, // Allows for the parsing of modern ECMAScript features. 12 is ES12 or ES2021
"sourceType": "module" // Allows for the use of imports
},
"plugins": ["@typescript-eslint"],
"rules": {},
"ignorePatterns": []
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
dist
.env
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
yarn.lock
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"printWidth": 100
}
26 changes: 25 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@
"version": "1.0.0",
"description": "Learn Fastify by building an app",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev -r dotenv/config --log-error --files ./src/server.ts",
"build": "tsc -p tsconfig.json",
"start": "NODE_ENV=production node -r dotenv/config dist/server.js",
"type:check": "tsc --project tsconfig.json --pretty --noEmit",
"lint": "prettier --c src/** && eslint src/** --quiet",
"format": "prettier --write ./src",
"lint:fix": "eslint src/** --fix"
},
"type": "module",
"repository": "https://github.com/one-aalam/fastifyrius",
"author": "Aftab Alam",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"@types/node": "^16.3.1",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.3.2",
"ts-node-dev": "^1.1.8",
"typescript": "^4.3.5"
},
"dependencies": {
"dotenv": "^10.0.0"
}
}
7 changes: 7 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import http from 'http'

const server = http.createServer((req, res) => {
res.end(`You requested for ${req.url} using method ${req.method}`)
})

server.listen(process.env.APP_PORT, () => console.log(`Server started on ${process.env.APP_PORT} 🚀`))
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"preserveConstEnums": true,
"removeComments": true,
"rootDir": "src",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"lib": ["ES6", "DOM"]
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "dist"],
"parserOptions": {
"ecmaVersion": "2021", // Allows for the parsing of modern ECMAScript features
"sourceType": "module" // Allows for the use of imports
}
}

0 comments on commit 856878f

Please sign in to comment.