This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fastify): fixes fastify app loading
- Loading branch information
Showing
7 changed files
with
52 additions
and
83 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
"predev": "npm run lint", | ||
"dev": "cross-env NODE_ENV=development nodemon -e ts -w \"./src\" -x \"npm run debug\"", | ||
"debug": "node -r ts-node/register -r dotenv/config --inspect ./src/index.ts | pino-colada", | ||
"update": "npx npm-check -u", | ||
"update": "yarn upgrade-interactive --latest", | ||
"prelint": "npm run prettier", | ||
"lint": "eslint --fix \"./src/**/*.ts\"", | ||
"prettier": "prettier --loglevel warn --write \"./**/*.{ts,tsx}\"", | ||
|
@@ -28,15 +28,15 @@ | |
"author": "Maksim Sinik <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"cross-env": "~5.2.1", | ||
"cross-env": "^6.0.0", | ||
"fastify": "^2.0.0", | ||
"fastify-autoload": "^1.0.0", | ||
"fastify-blipp": "~2.1.0", | ||
"fastify-blipp": "^2.1.0", | ||
"fastify-cli": "^1.2.0", | ||
"fastify-cors": "~2.1.3", | ||
"fastify-helmet": "~3.0.1", | ||
"fastify-no-icon": "~3.0.0", | ||
"qs": "~6.8.0" | ||
"fastify-cors": "^2.1.3", | ||
"fastify-helmet": "^3.0.1", | ||
"fastify-no-icon": "^3.0.0", | ||
"qs": "^6.9.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.2.0", | ||
|
@@ -48,27 +48,27 @@ | |
"@semantic-release/github": "^5.4.3", | ||
"@semantic-release/release-notes-generator": "^7.3.0", | ||
"@types/node": "^12.7.4", | ||
"@types/qs": "~6.5.3", | ||
"@typescript-eslint/eslint-plugin": "2.2.0", | ||
"@typescript-eslint/parser": "2.2.0", | ||
"@types/qs": "^6.5.3", | ||
"@typescript-eslint/eslint-plugin": "2.3.1", | ||
"@typescript-eslint/parser": "2.3.1", | ||
"commitizen": "^4.0.3", | ||
"commitlint-config-cz": "^0.12.1", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"dotenv": "~8.1.0", | ||
"eslint": "~6.3.0", | ||
"eslint-config-prettier": "~6.2.0", | ||
"eslint-plugin-prettier": "~3.1.0", | ||
"fastify-plugin": "~1.6.0", | ||
"dotenv": "^8.1.0", | ||
"eslint": "^6.4.0", | ||
"eslint-config-prettier": "^6.3.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"fastify-plugin": "^1.6.0", | ||
"husky": "^3.0.5", | ||
"nodemon": "~1.19.2", | ||
"pino-colada": "~1.4.5", | ||
"prettier": "~1.18.2", | ||
"rimraf": "~3.0.0", | ||
"nodemon": "^1.19.2", | ||
"pino-colada": "^1.4.5", | ||
"prettier": "^1.18.2", | ||
"rimraf": "^3.0.0", | ||
"semantic-release": "^15.13.24", | ||
"tap": "^14.6.1", | ||
"tap-mocha-reporter": "~4.0.1", | ||
"tap-mocha-reporter": "^4.0.1", | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.6.2" | ||
"typescript": "~3.6.2" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
|
@@ -78,7 +78,7 @@ | |
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS", | ||
"pre-commit": "npm test" | ||
"pre-commit": "npm run lint && npm test" | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,24 @@ | ||
// we need this file because of this issue: https://github.com/fastify/fastify-cli/issues/131 | ||
import 'make-promises-safe' | ||
import blipp from 'fastify-blipp' | ||
|
||
import Fastify from 'fastify' | ||
import cors from 'fastify-cors' | ||
import noIcon from 'fastify-no-icon' | ||
import helmet from 'fastify-helmet' | ||
import qs from 'qs' | ||
|
||
import app from './app' | ||
|
||
console.time('Boot Time') | ||
const fastify = Fastify({ | ||
querystringParser: str => qs.parse(str), | ||
logger: true, | ||
ignoreTrailingSlash: true, | ||
}) | ||
|
||
fastify.register(cors, { | ||
allowedHeaders: ['Content-Type', 'Authorization'], | ||
}) | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
const blipp = require('fastify-blipp') // eslint-disable-line | ||
fastify.register(blipp) | ||
} | ||
const fastify = Fastify(app.options) | ||
|
||
fastify.register(helmet) | ||
|
||
fastify.register(noIcon) | ||
fastify.register(blipp) | ||
fastify.register(app) | ||
|
||
fastify.listen((process.env.PORT as any) || 3000, '0.0.0.0', err => { | ||
if (err) { | ||
console.log(err) | ||
process.exit(1) | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
fastify.blipp() | ||
} | ||
fastify.blipp() | ||
|
||
console.timeEnd('Boot Time') | ||
console.log(`Server listening on port ${(fastify.server as any).address().port}`) | ||
}) |