-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚧 Convert to Typescript #120
base: main
Are you sure you want to change the base?
Changes from all commits
92d21c3
3d62bea
f46ae12
25a55e0
c2e404c
435dbb8
f3b5327
c370ba7
542d152
815e191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = { | ||
env: { | ||
jest: true, | ||
node: true, | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint", "jest", "prettier"], | ||
rules: { | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/explicit-member-accessibility": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
args: "after-used", | ||
argsIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
}, | ||
], | ||
"no-var": "error", | ||
"prettier/prettier": "error", | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:jest/recommended", | ||
"prettier", | ||
], | ||
overrides: [ | ||
{ | ||
files: ["*.test.ts"], | ||
rules: { | ||
"@typescript-eslint/no-non-null-assertion": ["off"], | ||
"@typescript-eslint/no-explicit-any": ["off"], | ||
}, | ||
}, | ||
], | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ RUN npx [email protected] install --production | |
COPY . . | ||
ENV NODE_ENV=production | ||
EXPOSE 5000 | ||
CMD ["node", "app/server.js"] | ||
CMD npm run server |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: node app/server.js | ||
web: npm run server |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
collectCoverageFrom: ["app/**/*.{js,ts}"], | ||
globals: { | ||
"ts-jest": { | ||
isolatedModules: true, | ||
}, | ||
}, | ||
moduleNameMapper: { | ||
"^@app(.*)$": "<rootDir>/app$1", | ||
}, | ||
preset: "ts-jest", | ||
roots: ["app"], | ||
testEnvironment: "node", | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ | |
"scripts": { | ||
"prepare": "husky install", | ||
"prestart": "node bin/pre-start", | ||
"start": "nodemon --watch . --watch .env.development --watch .env.development.local app/server.js", | ||
"lint": "eslint 'app/**/*.js'", | ||
"server": "node app/server.js", | ||
"start": "ts-node-dev --transpile-only --watch .,.env.development,.env.development.local app/server.ts", | ||
"lint": "npm-run-all -c lint:*", | ||
"lint:eslint": "eslint 'app/**/*.{js,ts}'", | ||
"lint:tsc": "tsc --noEmit", | ||
"server": "ts-node --transpile-only app/server.ts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider an explicit build step instead of using |
||
"test": "jest --watch", | ||
"test:coverage": "jest --coverage" | ||
}, | ||
|
@@ -17,6 +19,7 @@ | |
"dependencies": { | ||
"body-parser": "^1.19.0", | ||
"cookie-parser": "^1.4.4", | ||
"dotenv": "^10.0.0", | ||
"express": "^4.17.1", | ||
"express-basic-auth": "^1.2.0", | ||
"helmet": "^4.6.0", | ||
|
@@ -26,10 +29,18 @@ | |
"morgan": "^1.9.0", | ||
"passport": "^0.4.0", | ||
"passport-jwt": "^4.0.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.4", | ||
"winston": "^3.2.1" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "^10.0.0", | ||
"@types/express": "^4.17.12", | ||
"@types/jest": "^26.0.23", | ||
"@types/lodash": "^4.14.170", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really still need lodash? Especially since this project is now Node 16+ and typescript. |
||
"@types/node": "^15.12.4", | ||
"@types/supertest": "^2.0.11", | ||
"@typescript-eslint/eslint-plugin": "^4.28.0", | ||
"@typescript-eslint/parser": "^4.28.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.4.0", | ||
|
@@ -38,27 +49,18 @@ | |
"jest": "^27.1.0", | ||
"jest-junit": "^12.0.0", | ||
"lint-staged": "^11.1.2", | ||
"nodemon": "^2.0.7", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.3.2", | ||
"shelljs": "^0.8.2", | ||
"supertest": "^6.1.6" | ||
"supertest": "^6.1.6", | ||
"ts-jest": "^27.0.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to have an example in the project of mocking a module in jest, and using the ts-jest utils. |
||
"ts-node-dev": "^1.1.6" | ||
}, | ||
"engines": { | ||
"node": "^14.17.6", | ||
"yarn": ">=1.12.1" | ||
}, | ||
"_moduleAliases": { | ||
"@app": "app" | ||
}, | ||
"jest": { | ||
"roots": [ | ||
"app" | ||
], | ||
"moduleNameMapper": { | ||
"^@app(.*)$": "<rootDir>/app$1" | ||
}, | ||
"collectCoverageFrom": [ | ||
"app/**/*.js" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure node and jest are included in |
||
"baseUrl": "app", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"lib": ["es2020"], | ||
"module": "commonjs", | ||
"outDir": "build", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"target": "es2020" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly list There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicit |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodemon
is a popular option.. ists-node-dev
well supported?