NodeTyped
A Node.js starter kit featuring ES6 with Secuential Asynchrony (async/await), Express (Routing middlewares, Web, Api), Typescript, Mongoose, MongooseClass, SCSS, EJS, Nodemon, Bootstrap 4, TSLint, Jasmine, JsDoc, .
-
Simple npm setup and maintenance, without grunt/gulp/webpack/...
-
Support for async/await
Example middleware:
{ let title = 'NodeTyped Express'; try let data = await ; // no callbacks! res; catch e ; }
Example model:
@ @ name: string; @ age: number; static : Promise<any> return this; { return `Hello I'm `; }
Requirements
Make sure you have node version >= 4.0
Clone and Install dependencies
# clone the repo # --depth 1 removes all but one .git commit history git clone --depth 1 https://github.com/jamg44/NodeTyped.git projectname # change directory to your new project cd projectname # install the repo dependencies with npm npm install # start the server npm run dev
If you want to use mongoose models, start mongodb, check localConfig.js and:
# load sample products in database (defaults to 'test') npm run loadMocks
Develop
Watch mode
You can start the server in development mode (linter included) with:
npm run dev
Open the browser at:
Start MongoDB, run 'npm run loadMocks', and check:
- http://localhost:3000/products
- http://localhost:3000/apiv1/products
- http://localhost:3000/apiv1/products/near/(meters)/lon/(lon)/lat/(lat)
As you save in your editor, the compiler will rebuild and restart the server.
Other commands
Run the linter manually:
npm run lint
Clean temp folders:
npm run clean
Run the tests:
npm test
Generate docs, the output will be in /doc folder:
npm run doc
Production / Integration
To run the project in a server you'll want to run the built code instead src version.
# deploy the repo to server and run npm installnpm start
Recommendations
- When requiring from node_modules you must use require:
// require from /node_moduleslet express = require;
- With other module types you can use import (node api, created modules):
import * as fs from 'fs';import
- To change project name update package.json
"name": "project_name", <-----..."dev": "tsc && DEBUG=project_name2:* ... <-----
- All your reusable functions must return promises for better use with async/await.
let readFile = function =>
Roadmap (TODO)
- API authentication with JWT
- Add SSL
- Add cluster
- User system (register, login, etc)
- Add sequelize
- Add test coverage report
- Yeoman
- Basic panel
License
Made with ♡ by Javier Miguel González @javiermiguelg