Node.js TypeScript (Superset of JavaScript)
Simple receipt to bootstrap a Node.js process using TypeScript instead of JavaScript Based on: https://github.com/jabney/mongoose-continued
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "../dist/server",
"baseUrl": "",
"module": "commonjs"
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
package.json
{ "name": "nodejs-typescript", "version": "1.0.0", "license": "MIT", "author": "Claudio T", "original_author": "Davide Violante", "description": "boilerplate", "scripts": { "start": "node dist/server/app.js", "predev": "tsc -p server", "dev": "concurrently "tsc -w -p server" "nodemon dist/server/app.js"", "prod": "concurrently "tsc -p server && node dist/server/app.js"", "test": "tsc -p server && node_modules/.bin/mocha dist/server/test", "lintbe": "tslint --type-check -p server server//.ts{,x}" }, "private": true, "dependencies": { "bcryptjs": "^2.4.3", "body-parser": "^1.17.2", "bootstrap": "4.0.0-alpha.5", "core-js": "^2.4.1", "dotenv": "^4.0.0", "express": "^4.15.3", "font-awesome": "^4.7.0", "jquery": "^3.2.1", "jsonwebtoken": "^8.0.1", "mongoose": "^4.10.4", "morgan": "^1.8.2", "rxjs": "^5.4.2", "tether": "1.4.0", "zone.js": "^0.8.14" }, "devDependencies": { "@types/mongoose": "^4.7.23", "@types/node": "~6.0.60", "chai": "^4.1.0", "chai-http": "^3.0.0", "codelyzer": "~3.1.1", "concurrently": "^3.3.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "mocha": "^3.4.2", "nodemon": "1.11.0", "ts-node": "~3.2.0", "tslint": "~5.3.2", "typescript": "~2.3.3" } }
tslint.json
{ "rulesDirectory": [ "node_modules/codelyzer" ], "rules": { "arrow-return-shorthand": true, "callable-types": true, "class-name": true, "comment-format": [ true, "check-space" ], "curly": true, "eofline": true, "forin": true, "import-blacklist": [ true, "rxjs" ], "import-spacing": true, "indent": [ true, "spaces" ], "interface-over-type-literal": true, "label-position": true, "max-line-length": [ true, 140 ], "member-access": false, "member-ordering": [ true, { "order": [ "static-field", "instance-field", "static-method", "instance-method" ] } ], "no-arg": true, "no-bitwise": true, "no-console": [ true, "debug", "info", "time", "timeEnd", "trace" ], "no-construct": true, "no-debugger": true, "no-duplicate-super": true, "no-empty": false, "no-empty-interface": true, "no-eval": true, "no-inferrable-types": [ true, "ignore-params" ], "no-misused-new": true, "no-non-null-assertion": true, "no-shadowed-variable": true, "no-string-literal": false, "no-string-throw": true, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unnecessary-initializer": true, "no-unused-expression": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, "one-line": [ true, "check-open-brace", "check-catch", "check-else", "check-whitespace" ], "prefer-const": true, "quotemark": [ true, "single" ], "radix": true, "semicolon": [ true, "never" ], "triple-equals": [ true, "allow-null-check" ], "typedef-whitespace": [ true, { "call-signature": "nospace", "index-signature": "nospace", "parameter": "nospace", "property-declaration": "nospace", "variable-declaration": "nospace" } ], "typeof-compare": true, "unified-signatures": true, "variable-name": false, "whitespace": [ true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ], "directive-selector": [ true, "attribute", "app", "camelCase" ], "component-selector": [ true, "element", "app", "kebab-case" ], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, "no-input-rename": true, "no-output-rename": true, "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, "directive-class-suffix": true, "no-access-missing-member": true, "templates-use-public": true, "invoke-injectable": true } }
Created on 1/6/2018