├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── src ├── app.ts ├── controller │ └── home.controller.ts └── express.router.ts ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node,visualstudiocode 3 | # Build directory 4 | dist 5 | 6 | ### Node ### 7 | # Logs 8 | logs 9 | *.log 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Runtime data 15 | pids 16 | *.pid 17 | *.seed 18 | *.pid.lock 19 | 20 | # Directory for instrumented libs generated by jscoverage/JSCover 21 | lib-cov 22 | 23 | # Coverage directory used by tools like istanbul 24 | coverage 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Typescript v1 declaration files 46 | typings/ 47 | 48 | # Optional npm cache directory 49 | .npm 50 | 51 | # Optional eslint cache 52 | .eslintcache 53 | 54 | # Optional REPL history 55 | .node_repl_history 56 | 57 | # Output of 'npm pack' 58 | *.tgz 59 | 60 | # Yarn Integrity file 61 | .yarn-integrity 62 | 63 | # dotenv environment variables file 64 | .env 65 | 66 | 67 | ### VisualStudioCode ### 68 | .vscode/* 69 | !.vscode/settings.json 70 | !.vscode/tasks.json 71 | !.vscode/launch.json 72 | !.vscode/extensions.json 73 | .history 74 | 75 | 76 | # End of https://www.gitignore.io/api/node,visualstudiocode 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A minimal web application structure with technologies like node.js, typescript, express 2 | 3 | This project is created to help people who wants to start creating application with the TypeScript, Node.js and Express. 4 | 5 | ## How to run this project: 6 | 7 | To run this project first you need to run following command 8 | 9 | ```sh 10 | npm install <= install all the npm Dependencies 11 | npm start <= It will run project on port 8000. 12 | ``` 13 | 14 | ## Directory strcture of project: 15 | 16 | * app.ts - Typescript file for creating express application class and where we have initialized the application. 17 | * routes.ts - Typescript files for creating all the routes under Init() Method. 18 | * package.json - Contains all the packages and dev dependencies required for this application. You can add more as your requirement.. 19 | * tsconfig.json - Where all the typescript configuration is there and we converting typescript into ES5.. 20 | * Controller Folder - Contains all the classes for the controller of the express application. 21 | * tsconfig.json - Contains all the rules for TypeScript linting. 22 | 23 | ## License 24 | 25 | MIT 26 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimum-nodejs-typescript-express", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/body-parser": { 8 | "version": "1.16.8", 9 | "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.16.8.tgz", 10 | "integrity": "sha512-BdN2PXxOFnTXFcyONPW6t0fHjz2fvRZHVMFpaS0wYr+Y8fWEaNOs4V8LEu/fpzQlMx+ahdndgTaGTwPC+J/EeA==", 11 | "dev": true, 12 | "requires": { 13 | "@types/express": "4.11.1", 14 | "@types/node": "9.4.7" 15 | } 16 | }, 17 | "@types/dotenv": { 18 | "version": "4.0.2", 19 | "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-4.0.2.tgz", 20 | "integrity": "sha512-09zBCDj0mcjBg+U56ldpA95d4zuZxQahtOp+UYiRTYuF7QO7hZwFepg7VtfjjxzBhrONoQ8fTUCYSgqDNZQJ9Q==", 21 | "dev": true, 22 | "requires": { 23 | "@types/node": "9.4.7" 24 | } 25 | }, 26 | "@types/events": { 27 | "version": "1.2.0", 28 | "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", 29 | "integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==", 30 | "dev": true 31 | }, 32 | "@types/express": { 33 | "version": "4.11.1", 34 | "resolved": "https://registry.npmjs.org/@types/express/-/express-4.11.1.tgz", 35 | "integrity": "sha512-ttWle8cnPA5rAelauSWeWJimtY2RsUf2aspYZs7xPHiWgOlPn6nnUfBMtrkcnjFJuIHJF4gNOdVvpLK2Zmvh6g==", 36 | "dev": true, 37 | "requires": { 38 | "@types/body-parser": "1.16.8", 39 | "@types/express-serve-static-core": "4.11.1", 40 | "@types/serve-static": "1.13.1" 41 | } 42 | }, 43 | "@types/express-serve-static-core": { 44 | "version": "4.11.1", 45 | "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.11.1.tgz", 46 | "integrity": "sha512-EehCl3tpuqiM8RUb+0255M8PhhSwTtLfmO7zBBdv0ay/VTd/zmrqDfQdZFsa5z/PVMbH2yCMZPXsnrImpATyIw==", 47 | "dev": true, 48 | "requires": { 49 | "@types/events": "1.2.0", 50 | "@types/node": "9.4.7" 51 | } 52 | }, 53 | "@types/mime": { 54 | "version": "2.0.0", 55 | "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.0.tgz", 56 | "integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA==", 57 | "dev": true 58 | }, 59 | "@types/node": { 60 | "version": "9.4.7", 61 | "resolved": "https://registry.npmjs.org/@types/node/-/node-9.4.7.tgz", 62 | "integrity": "sha512-4Ba90mWNx8ddbafuyGGwjkZMigi+AWfYLSDCpovwsE63ia8w93r3oJ8PIAQc3y8U+XHcnMOHPIzNe3o438Ywcw==", 63 | "dev": true 64 | }, 65 | "@types/serve-static": { 66 | "version": "1.13.1", 67 | "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.1.tgz", 68 | "integrity": "sha512-jDMH+3BQPtvqZVIcsH700Dfi8Q3MIcEx16g/VdxjoqiGR/NntekB10xdBpirMKnPe9z2C5cBmL0vte0YttOr3Q==", 69 | "dev": true, 70 | "requires": { 71 | "@types/express-serve-static-core": "4.11.1", 72 | "@types/mime": "2.0.0" 73 | } 74 | }, 75 | "accepts": { 76 | "version": "1.3.5", 77 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", 78 | "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", 79 | "requires": { 80 | "mime-types": "2.1.18", 81 | "negotiator": "0.6.1" 82 | } 83 | }, 84 | "array-flatten": { 85 | "version": "1.1.1", 86 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 87 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 88 | }, 89 | "body-parser": { 90 | "version": "1.18.2", 91 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", 92 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", 93 | "requires": { 94 | "bytes": "3.0.0", 95 | "content-type": "1.0.4", 96 | "debug": "2.6.9", 97 | "depd": "1.1.2", 98 | "http-errors": "1.6.2", 99 | "iconv-lite": "0.4.19", 100 | "on-finished": "2.3.0", 101 | "qs": "6.5.1", 102 | "raw-body": "2.3.2", 103 | "type-is": "1.6.16" 104 | } 105 | }, 106 | "bytes": { 107 | "version": "3.0.0", 108 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 109 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 110 | }, 111 | "content-disposition": { 112 | "version": "0.5.2", 113 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 114 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" 115 | }, 116 | "content-type": { 117 | "version": "1.0.4", 118 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 119 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 120 | }, 121 | "cookie": { 122 | "version": "0.3.1", 123 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 124 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 125 | }, 126 | "cookie-signature": { 127 | "version": "1.0.6", 128 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 129 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 130 | }, 131 | "debug": { 132 | "version": "2.6.9", 133 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 134 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 135 | "requires": { 136 | "ms": "2.0.0" 137 | } 138 | }, 139 | "depd": { 140 | "version": "1.1.2", 141 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 142 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 143 | }, 144 | "destroy": { 145 | "version": "1.0.4", 146 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 147 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 148 | }, 149 | "dotenv": { 150 | "version": "5.0.1", 151 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz", 152 | "integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==" 153 | }, 154 | "ee-first": { 155 | "version": "1.1.1", 156 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 157 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 158 | }, 159 | "encodeurl": { 160 | "version": "1.0.2", 161 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 162 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 163 | }, 164 | "escape-html": { 165 | "version": "1.0.3", 166 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 167 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 168 | }, 169 | "etag": { 170 | "version": "1.8.1", 171 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 172 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 173 | }, 174 | "express": { 175 | "version": "4.16.2", 176 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", 177 | "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", 178 | "requires": { 179 | "accepts": "1.3.5", 180 | "array-flatten": "1.1.1", 181 | "body-parser": "1.18.2", 182 | "content-disposition": "0.5.2", 183 | "content-type": "1.0.4", 184 | "cookie": "0.3.1", 185 | "cookie-signature": "1.0.6", 186 | "debug": "2.6.9", 187 | "depd": "1.1.2", 188 | "encodeurl": "1.0.2", 189 | "escape-html": "1.0.3", 190 | "etag": "1.8.1", 191 | "finalhandler": "1.1.0", 192 | "fresh": "0.5.2", 193 | "merge-descriptors": "1.0.1", 194 | "methods": "1.1.2", 195 | "on-finished": "2.3.0", 196 | "parseurl": "1.3.2", 197 | "path-to-regexp": "0.1.7", 198 | "proxy-addr": "2.0.3", 199 | "qs": "6.5.1", 200 | "range-parser": "1.2.0", 201 | "safe-buffer": "5.1.1", 202 | "send": "0.16.1", 203 | "serve-static": "1.13.1", 204 | "setprototypeof": "1.1.0", 205 | "statuses": "1.3.1", 206 | "type-is": "1.6.16", 207 | "utils-merge": "1.0.1", 208 | "vary": "1.1.2" 209 | } 210 | }, 211 | "finalhandler": { 212 | "version": "1.1.0", 213 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", 214 | "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", 215 | "requires": { 216 | "debug": "2.6.9", 217 | "encodeurl": "1.0.2", 218 | "escape-html": "1.0.3", 219 | "on-finished": "2.3.0", 220 | "parseurl": "1.3.2", 221 | "statuses": "1.3.1", 222 | "unpipe": "1.0.0" 223 | } 224 | }, 225 | "forwarded": { 226 | "version": "0.1.2", 227 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 228 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 229 | }, 230 | "fresh": { 231 | "version": "0.5.2", 232 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 233 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 234 | }, 235 | "http-errors": { 236 | "version": "1.6.2", 237 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", 238 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", 239 | "requires": { 240 | "depd": "1.1.1", 241 | "inherits": "2.0.3", 242 | "setprototypeof": "1.0.3", 243 | "statuses": "1.3.1" 244 | }, 245 | "dependencies": { 246 | "depd": { 247 | "version": "1.1.1", 248 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", 249 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" 250 | }, 251 | "setprototypeof": { 252 | "version": "1.0.3", 253 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", 254 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" 255 | } 256 | } 257 | }, 258 | "iconv-lite": { 259 | "version": "0.4.19", 260 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 261 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 262 | }, 263 | "inherits": { 264 | "version": "2.0.3", 265 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 266 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 267 | }, 268 | "ipaddr.js": { 269 | "version": "1.6.0", 270 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", 271 | "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" 272 | }, 273 | "media-typer": { 274 | "version": "0.3.0", 275 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 276 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 277 | }, 278 | "merge-descriptors": { 279 | "version": "1.0.1", 280 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 281 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 282 | }, 283 | "methods": { 284 | "version": "1.1.2", 285 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 286 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 287 | }, 288 | "mime": { 289 | "version": "1.4.1", 290 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", 291 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" 292 | }, 293 | "mime-db": { 294 | "version": "1.33.0", 295 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", 296 | "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" 297 | }, 298 | "mime-types": { 299 | "version": "2.1.18", 300 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", 301 | "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", 302 | "requires": { 303 | "mime-db": "1.33.0" 304 | } 305 | }, 306 | "ms": { 307 | "version": "2.0.0", 308 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 309 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 310 | }, 311 | "negotiator": { 312 | "version": "0.6.1", 313 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 314 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 315 | }, 316 | "on-finished": { 317 | "version": "2.3.0", 318 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 319 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 320 | "requires": { 321 | "ee-first": "1.1.1" 322 | } 323 | }, 324 | "parseurl": { 325 | "version": "1.3.2", 326 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", 327 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" 328 | }, 329 | "path-to-regexp": { 330 | "version": "0.1.7", 331 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 332 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 333 | }, 334 | "proxy-addr": { 335 | "version": "2.0.3", 336 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", 337 | "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", 338 | "requires": { 339 | "forwarded": "0.1.2", 340 | "ipaddr.js": "1.6.0" 341 | } 342 | }, 343 | "qs": { 344 | "version": "6.5.1", 345 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 346 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 347 | }, 348 | "range-parser": { 349 | "version": "1.2.0", 350 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", 351 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" 352 | }, 353 | "raw-body": { 354 | "version": "2.3.2", 355 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", 356 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", 357 | "requires": { 358 | "bytes": "3.0.0", 359 | "http-errors": "1.6.2", 360 | "iconv-lite": "0.4.19", 361 | "unpipe": "1.0.0" 362 | } 363 | }, 364 | "safe-buffer": { 365 | "version": "5.1.1", 366 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 367 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 368 | }, 369 | "send": { 370 | "version": "0.16.1", 371 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", 372 | "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", 373 | "requires": { 374 | "debug": "2.6.9", 375 | "depd": "1.1.2", 376 | "destroy": "1.0.4", 377 | "encodeurl": "1.0.2", 378 | "escape-html": "1.0.3", 379 | "etag": "1.8.1", 380 | "fresh": "0.5.2", 381 | "http-errors": "1.6.2", 382 | "mime": "1.4.1", 383 | "ms": "2.0.0", 384 | "on-finished": "2.3.0", 385 | "range-parser": "1.2.0", 386 | "statuses": "1.3.1" 387 | } 388 | }, 389 | "serve-static": { 390 | "version": "1.13.1", 391 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", 392 | "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", 393 | "requires": { 394 | "encodeurl": "1.0.2", 395 | "escape-html": "1.0.3", 396 | "parseurl": "1.3.2", 397 | "send": "0.16.1" 398 | } 399 | }, 400 | "setprototypeof": { 401 | "version": "1.1.0", 402 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", 403 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" 404 | }, 405 | "statuses": { 406 | "version": "1.3.1", 407 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", 408 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" 409 | }, 410 | "type-is": { 411 | "version": "1.6.16", 412 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", 413 | "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", 414 | "requires": { 415 | "media-typer": "0.3.0", 416 | "mime-types": "2.1.18" 417 | } 418 | }, 419 | "typescript": { 420 | "version": "2.7.2", 421 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz", 422 | "integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==", 423 | "dev": true 424 | }, 425 | "unpipe": { 426 | "version": "1.0.0", 427 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 428 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 429 | }, 430 | "utils-merge": { 431 | "version": "1.0.1", 432 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 433 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 434 | }, 435 | "vary": { 436 | "version": "1.1.2", 437 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 438 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 439 | } 440 | } 441 | } 442 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimum-nodejs-typescript-express", 3 | "version": "1.0.0", 4 | "description": "A minimum typescript,nodejs and express application", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "tsc && node dist/app.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/dotnetjalps/minimum-nodejs-typescript-express.git" 13 | }, 14 | "keywords": [ 15 | "typescript", 16 | "nodejs", 17 | "express" 18 | ], 19 | "devDependencies": { 20 | "@types/dotenv": "^4.0.2", 21 | "@types/express": "*", 22 | "@types/node": "*", 23 | "typescript": "*" 24 | }, 25 | "dependencies": { 26 | "dotenv": "^5.0.1", 27 | "express": "4.16.2" 28 | }, 29 | "author": "Jalpesh Vadgama", 30 | "license": "MIT", 31 | "bugs": { 32 | "url": "https://github.com/dotnetjalps/minimum-nodejs-typescript-express/issues" 33 | }, 34 | "homepage": "https://github.com/dotnetjalps/minimum-nodejs-typescript-express#readme" 35 | } 36 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | import * as dotenv from 'dotenv'; 2 | import express from 'express'; 3 | import ExpressRotuer from './express.router'; 4 | 5 | dotenv.config(); 6 | 7 | const app = express(); 8 | const expressRoutes = new ExpressRotuer(app); 9 | expressRoutes.init(); 10 | 11 | app.listen(process.env.PORT, () => { 12 | console.log(`Express server app listening on port ${process.env.PORT}!`); 13 | }); 14 | -------------------------------------------------------------------------------- /src/controller/home.controller.ts: -------------------------------------------------------------------------------- 1 | import { NextFunction, Request, Response } from 'express'; 2 | 3 | export default class HomeController { 4 | public static getDefault(req: Request, res: Response, next: NextFunction) { 5 | res.send('Hello World!'); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/express.router.ts: -------------------------------------------------------------------------------- 1 | import { Express, NextFunction, Request, Response, Router } from 'express'; 2 | import HomeController from './controller/home.controller'; 3 | 4 | export default class ExpressRouter { 5 | public router: Router; 6 | private app: Express; 7 | 8 | constructor(app: Express) { 9 | this.router = Router(); 10 | this.app = app; 11 | } 12 | 13 | public init(): void { 14 | this.router.get('/', HomeController.getDefault); 15 | this.app.use('/', this.router); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ 5 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 6 | // "lib": [], /* Specify library files to be included in the compilation. */ 7 | // "allowJs": true, /* Allow javascript files to be compiled. */ 8 | // "checkJs": true, /* Report errors in .js files. */ 9 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 10 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 11 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 12 | // "outFile": "./", /* Concatenate and emit output to single file. */ 13 | "outDir": "./dist", /* Redirect output structure to the directory. */ 14 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 15 | // "removeComments": true, /* Do not emit comments to output. */ 16 | // "noEmit": true, /* Do not emit outputs. */ 17 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 18 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 19 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 20 | 21 | /* Strict Type-Checking Options */ 22 | "strict": true, /* Enable all strict type-checking options. */ 23 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 24 | // "strictNullChecks": true, /* Enable strict null checks. */ 25 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 26 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 27 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 28 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 29 | 30 | /* Additional Checks */ 31 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 32 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 33 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 34 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 35 | 36 | /* Module Resolution Options */ 37 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 38 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 39 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 40 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 41 | // "typeRoots": [], /* List of folders to include type definitions from. */ 42 | // "types": [], /* Type declaration files to be included in compilation. */ 43 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 44 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 45 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 46 | 47 | /* Source Map Options */ 48 | // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 49 | // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ 50 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 51 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 52 | 53 | /* Experimental Options */ 54 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 55 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 56 | }, 57 | "include": [ 58 | "src/**/*.ts" 59 | ], 60 | "exclude": [ 61 | "node_modules" 62 | ] 63 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": ["tslint:recommended"], 4 | "jsRules": {}, 5 | "rules": { 6 | "quotemark": [true, "single"] 7 | }, 8 | "rulesDirectory": [] 9 | } 10 | --------------------------------------------------------------------------------