This Project is wrriten in typescript, i personally perfer typescript because it is easy to use, provide contracts between multiple modules, less prone to type errors.
Please Configuation config.json file before running any scripts.
"HOST":"localhost",
"PORT":3000,
"GOOGLE_API_KEY":"",
"FORCAST_API_KEY":"" // provide your forcastio/darksky API key../start.shAbove single script will install npm modules, then execute the test cases and after then run the application in debug mode.
./deployToDocker.shAbove script will create a docker image. Assuming that npm packages already installed using npm install.
npm installAbove command will install all the npm dependency defined under package.json file.
npm run compileAbove command will compile the typescript files to js(es6) files.
npm startAbove command will start the application.
npm testAbove command will execute the test cases.
| package | Usage |
|---|---|
| bluebird | Good A+ specs promise library, cost 15% performance degradation but good error handling, no callback hell etc. |
| debug | logger for the application. |
| ejs | Templating engine. |
| express | Nodejs framework |
| moment | date time manipluation becomes easy with it. |
| query-string | for stringify the queries to form the url. |
| package | Usage |
|---|---|
| mocha | JS Test framework. |
| mocha-typescript | Class based test cases with decorators . |
| should | JS Assertion library |
| supertest | JS HTTP test framework. |
| tslint | for linting of typescript. |
| typescript | typescript to js compiler. |
| reflect-metadata | metadata for decorators, helps typescript to compile in js with decorators. |
Some type definitions are also defined under devDependencies.
. ├── Dockerfile ├── Readme.md ├── config.json ├── deployToDocker.sh ├── docker-compose.debug.yml ├── docker-compose.yml ├── package.json ├── source │ ├── Controllers │ │ ├── index.ts │ │ └── weatherCtrl.ts │ ├── Routes │ │ ├── index.ts │ │ └── weather.ts │ ├── Services │ │ ├── cache.ts │ │ ├── config.ts │ │ ├── forcastioApi.ts │ │ ├── googleGeoCodeApi.ts │ │ ├── index.ts │ │ └── request.ts │ ├── index.ts │ ├── server.ts │ └── test │ ├── Services │ │ ├── cache.specs.ts │ │ ├── forcastIo.specs.ts │ │ └── googleGeoCodeAPi.specs.ts │ └── app │ └── app.specs.ts ├── start.sh ├── static_assests │ └── js │ ├── main.js │ └── moment.min.js ├── tsconfig.json ├── tslint.json ├── views ├── 404.ejs └── index.ejs
Some optimization can be done as the results from darksky.net can be some how cached. The more effective approach would be using IOC with inversify (npm package), which provide good dependency injection and mocking of modules would be extermly easy.
~ 22 Hours