Installing

Assuming you’ve already installed Node.js, create a directory to hold your application, and make that your working directory.

mkdir demo-app
cd demo-app

Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s package.json handling.

npm init

This command prompts you for a number of things, such as the name and version of your application.

For now, you can simply hit RETURN to accept the defaults for most of them, with the following exception:

  • entry point: (build/index.js)
  • Enter build/index.js, or whatever you want the name of the main file to be.

Now install Typeix and dependencies in the app directory and save it in the dependencies list:

npm install typescript --save
npm install @types/node --save
npm install @types/ws --save
npm install [email protected] --save

Add tsconfig.json

{
  "version": "2.0.3",
  "compileOnSave": true,
  "compilerOptions": {
    "declaration": true,
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "build",
    "sourceMap": true,
    "inlineSources": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "build",
    "node_modules"
  ]
}

Add following npm compile and start scripts to package.json

{
  "name": "demo-app",
  "version": "0.0.1",
  "scripts": {
    "compile": "tsc -p tsconfig.json",
    "start": "npm run compile && node build/bootstrap.js"
  },
  "devDependencies": {
    "@types/node": "^7.0.13",
    "typescript": "^2.3.0"
  },
  "dependencies": {
    "mu2": "^0.5.21", 
    "typeix": "^1.0.0-beta.15"
  }
}

mu2 - mustache template engine, you can choose any templating engine in this tutorial we choose well known mustache.

results matching ""

    No results matching ""