0.5.1 • Published 6 years ago

@opendevstack/generator-node-express-typescript v0.5.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

TypeScript NodeJS Generator

Build Status npm version

This is a fork of this generator but I added express to it.

I'm a minimal Yeoman generator for creating NodeJS express servers using TypeScript. I let you quickly setup a project with latest available tools and best practices.

I use:

  • npm - as task runner. You can choose to use gulp instead.
  • tslint - as linter for TypeScript source files.
  • mocha - as testing framework to write specs in TypeScript itself.
  • istanbul - a JavaScript code coverage tool working on TypeScript files.

I don't use: a UI renderer or anything visual I am a pure API targeted generator. So with me, you should build REST API's.

You want to know if you can change any of these? Of course, why not? It is your module after all. I simply get down to business of generating, no questions asked. Once done, I get out of the way and you can do as you please!

Usage

Install generator-node-express-typescript globally. If you are planning to use gulp, install gulp-cli globally.

$npm install -g generator-node-express-typescript

Create a new directory and cd into it.

$mkdir my-new-project && cd $_

Run the generator.

$yo node-express-typescript

You can choose to use gulp as your build system using command - $yo node-express-typescript --gulp

Run npm run for information on available tasks.

 $npm run
Lifecycle scripts included in node-ts:
  test
    npm run build && mocha --compilers ts:ts-node/register --recursive test/**/*-spec.ts
  coverage
    nyc --reporter=text --reporter=html mocha --compilers ts:ts-node/register

available via `npm run-script`:
  clean
    rimraf lib
  lint
    tslint --format verbose 'src/**/*.ts'
  build
    npm run clean && npm run lint && echo Using TypeScript && tsc --version && tsc --pretty
  coverage
    nyc --reporter=text --reporter=html mocha --compilers ts:ts-node/register
  watch
    npm run build -- --watch
  watch:test
    npm run test -- --watch

If you choose to use gulp, you can find the available tasks using command gulp help.

$gulp help

Usage
  gulp [TASK] [OPTIONS...]

Available tasks
  build  Compiles all TypeScript source files [lint]
  clean  Cleans the generated js files from lib directory
  help   Display this help text.
  lint   Lints all TypeScript source files
  test   Runs the mocha test specs [build]
  watch  Watches ts source files and runs build on change

Highlights of the latest release

  • I use latest version of TypeScript.
  • I use npm to fetch type definitions making life so much easier. You can find more information on https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/.
  • I use mocha as testing framework as it allows easier test runs from command line. Also, one of the most important things regarding testing is now you can write tests in TypeScript itself. The out-of-box configuration includes use of ts-node as mocha compiler allowing executing specs written in TypeScript without compiling them first.
  • I need no global dependencies. Every dependency such as TypeScript and tslint is installed as local dev dependency allowing you to freely use different versions of these for different modules.
  • I provide test coverage support using istanbul.
  • I provide nice integration with VS Code editor. I configure build, clean, lint, coverage and test tasks that you can run using Run Task option.

License

MIT