├── .vscode └── settings.json ├── README.md ├── src └── index.ts ├── tsconfig.json ├── .gitignore ├── package.json └── tslint.json /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-ts 2 | 3 | Simple Node and typeScript app 4 | 5 | ## Quick Start 6 | 7 | 1. `npm install` 8 | 2. `npm run serve-debug` 9 | 10 | ## Included 11 | 12 | - basic `tsconfig.json` 13 | - npm scripts to help build, run, watch, and debug 14 | - concurrently, ts-node, ts-lint, typescript for helping with builds 15 | - types for node with @types/node 16 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import * as http from 'http'; 2 | const port = process.env.PORT || 3000; 3 | 4 | const server = http.createServer((req, res) => { 5 | res.statusCode = 200; 6 | res.setHeader('Content-Type', 'text/plain'); 7 | res.end('Hello World!\n'); 8 | }); 9 | 10 | server.listen(port, () => { 11 | console.log(`Server running on http://localhost:${port}/`); 12 | }); 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "esModuleInterop": true, 5 | "target": "es6", 6 | "noImplicitAny": true, 7 | "moduleResolution": "node", 8 | "sourceMap": true, 9 | "outDir": "dist", 10 | "baseUrl": ".", 11 | "paths": { 12 | "*": ["node_modules/*"] 13 | } 14 | }, 15 | "include": ["src/**/*"] 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | *.swp 10 | 11 | pids 12 | logs 13 | results 14 | tmp 15 | 16 | # Coverage reports 17 | coverage 18 | 19 | # API keys and secrets 20 | .env 21 | 22 | # Dependency directory 23 | node_modules 24 | bower_components 25 | 26 | # Editors 27 | .idea 28 | *.iml 29 | 30 | # OS metadata 31 | .DS_Store 32 | Thumbs.db 33 | 34 | # Ignore built ts files 35 | dist/**/* -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-ts", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": {}, 7 | "devDependencies": { 8 | "@types/node": "^10.5.7", 9 | "concurrently": "^3.6.1", 10 | "nodemon": "^1.18.3", 11 | "ts-node": "^7.0.0", 12 | "tslint": "^5.11.0", 13 | "typescript": "^3.0.1" 14 | }, 15 | "scripts": { 16 | "build": "npm run build-ts && npm run tslint", 17 | "build-ts": "tsc", 18 | "watch-ts": "tsc -w", 19 | "serve": "node dist/index.js", 20 | "start": "npm run serve", 21 | "tslint": "tslint -c tslint.json -p tsconfig.json", 22 | "debug": "npm run build && npm run watch-debug", 23 | "serve-debug": "nodemon --inspect dist/index.js", 24 | "watch-debug": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve-debug\"" 25 | }, 26 | "keywords": [], 27 | "author": "", 28 | "license": "ISC" 29 | } 30 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "comment-format": [true, "check-space"], 5 | "indent": [true, "spaces"], 6 | "one-line": [true, "check-open-brace", "check-whitespace"], 7 | "no-var-keyword": true, 8 | "quotemark": [true, "single", "avoid-escape"], 9 | "semicolon": [true, "always", "ignore-bound-class-methods"], 10 | "whitespace": [ 11 | true, 12 | "check-branch", 13 | "check-decl", 14 | "check-operator", 15 | "check-module", 16 | "check-separator", 17 | "check-type" 18 | ], 19 | "typedef-whitespace": [ 20 | true, 21 | { 22 | "call-signature": "nospace", 23 | "index-signature": "nospace", 24 | "parameter": "nospace", 25 | "property-declaration": "nospace", 26 | "variable-declaration": "nospace" 27 | }, 28 | { 29 | "call-signature": "onespace", 30 | "index-signature": "onespace", 31 | "parameter": "onespace", 32 | "property-declaration": "onespace", 33 | "variable-declaration": "onespace" 34 | } 35 | ], 36 | "no-internal-module": true, 37 | "no-trailing-whitespace": true, 38 | "no-null-keyword": true, 39 | "prefer-const": true, 40 | "jsdoc-format": true 41 | } 42 | } 43 | --------------------------------------------------------------------------------