diff --git a/app/templates/.eslintrc.js b/app/templates/.eslintrc.js index c309395..c709596 100644 --- a/app/templates/.eslintrc.js +++ b/app/templates/.eslintrc.js @@ -1,16 +1,19 @@ module.exports = { - parser: "@typescript-eslint/parser", // Specifies the ESLint parser + parser: '@typescript-eslint/parser', // Specifies the ESLint parser parserOptions: { ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features - sourceType: "module" // Allows for the use of imports + sourceType: 'module', // Allows for the use of imports }, extends: [ - "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin - "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier - "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin + 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier + 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. ], rules: { + // 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs // e.g. "@typescript-eslint/explicit-function-return-type": "off", }, -}; \ No newline at end of file +}; diff --git a/app/templates/Dockerfile b/app/templates/Dockerfile index 9ba98ef..35a05e2 100644 --- a/app/templates/Dockerfile +++ b/app/templates/Dockerfile @@ -1,11 +1,11 @@ -FROM node:12-alpine +FROM node:14-alpine LABEL Author Carmine DiMascio RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app -RUN npm install +RUN npm install && npm run compile EXPOSE 3000 diff --git a/app/templates/package.json b/app/templates/package.json index 8357d70..b4bd121 100644 --- a/app/templates/package.json +++ b/app/templates/package.json @@ -2,7 +2,7 @@ "name": "<%= name %>", "version": "<%= version %>", "description": "<%= description %>", - "main": "index.js", + "main": "dist/index.js", "scripts": { "start": "node dist/index.js", "compile": "ts-node build.ts && tsc", @@ -18,23 +18,26 @@ "cookie-parser": "^1.4.5", "dotenv": "^8.2.0", "express": "^4.17.1", - "pino": "^6.8.0", + "pino": "^6.11.0", <% if (specification === 'openapi_3') { %> - "express-openapi-validator": "^4.10.6" + "express-openapi-validator": "^4.10.9" <% } else { %> "swagger-express-middleware": "^4.0.2" <% } %> }, "devDependencies": { "@types/chai": "^4.2.14", + "@types/cookie-parser": "^1.4.2", "@types/express": "^4.17.11", "@types/mocha": "^8.2.0", + "@types/node": "^14.14.22", "@types/pino": "^6.3.5", - "@typescript-eslint/eslint-plugin": "^4.13.0", - "@typescript-eslint/parser": "^4.13.0", + "@types/shelljs": "^0.8.8", + "@typescript-eslint/eslint-plugin": "^4.14.0", + "@typescript-eslint/parser": "^4.14.0", "chai": "^4.2.0", - "eslint": "^7.17.0", - "eslint-config-prettier": "^7.1.0", + "eslint": "^7.18.0", + "eslint-config-prettier": "^7.2.0", "eslint-plugin-prettier": "^3.3.1", "mocha": "^8.2.1", "nodemon": "^2.0.7", diff --git a/app/templates/server/api/controllers/examples/controller.ts b/app/templates/server/api/controllers/examples/controller.ts index 66fd287..b37e77d 100644 --- a/app/templates/server/api/controllers/examples/controller.ts +++ b/app/templates/server/api/controllers/examples/controller.ts @@ -2,7 +2,7 @@ import ExamplesService from '../../services/examples.service'; import { Request, Response } from 'express'; export class Controller { - all(req: Request, res: Response): void { + all(_: Request, res: Response): void { ExamplesService.all().then(r => res.json(r)); } diff --git a/app/templates/server/api/middlewares/error.handler.ts b/app/templates/server/api/middlewares/error.handler.ts index 9f1610f..eca87f0 100644 --- a/app/templates/server/api/middlewares/error.handler.ts +++ b/app/templates/server/api/middlewares/error.handler.ts @@ -1,13 +1,11 @@ import { Request, Response, NextFunction } from 'express'; <% if (specification === 'openapi_3') { %> -// eslint-disable-next-line no-unused-vars, no-shadow export default function errorHandler( - err, - req: Request, + err: any, + _req: Request, res: Response, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - next: NextFunction + _next: NextFunction ): void { const errors = err.errors || [{ message: err.message }]; res.status(err.status || 500).json({ errors }); diff --git a/app/templates/server/index.ts b/app/templates/server/index.ts index 71659b3..7b3f93b 100644 --- a/app/templates/server/index.ts +++ b/app/templates/server/index.ts @@ -2,7 +2,7 @@ import './common/env'; import Server from './common/server'; import routes from './routes'; -const port = parseInt(process.env.PORT); +const port = parseInt(process.env.PORT ?? '3000'); export default new Server() .router(routes) .listen(port); diff --git a/app/templates/tsconfig.json b/app/templates/tsconfig.json index b59f8eb..8b8145d 100644 --- a/app/templates/tsconfig.json +++ b/app/templates/tsconfig.json @@ -1,15 +1,27 @@ { "compileOnSave": false, "compilerOptions": { - "target": "es6", + "target":"ES2018", "module": "commonjs", + "lib": ["es2020"], + "declaration": true, + "strict": true, + "noImplicitAny": true, "esModuleInterop": true, - "sourceMap": true, "moduleResolution": "node", + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": false, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": false, + "sourceMap": true, + "strictPropertyInitialization":false, + "resolveJsonModule": true, "outDir": "dist", - "typeRoots": ["node_modules/@types"], - "resolveJsonModule": true + "typeRoots": ["./node_modules/@types"] }, - "include": ["typings.d.ts", "server/**/*.ts"], + "include": ["server/**/*.ts"], "exclude": ["node_modules"] }