Odi
Search…
Getting Started

Installation

    1.
    Install npm package npm install odi --save
    2.
    Install reflect-metadata npm install reflect-metadata --save
    3.
    Import reflect-metadata (for example in index.ts): import "reflect-metadata";
    4.
    Enabled the following settings in tsconfig.json
    1
    "emitDecoratorMetadata": true,
    2
    "experimentalDecorators": true
    Copied!

Hello World application

First of all, let's create simple controller hello.controller.ts
1
import { Controller, IController, Get } from 'odi';
2
3
@Controller()
4
export class HelloController extends IController {
5
6
@Get index() {
7
return "Hello world !";
8
}
9
10
}
Copied!
And our startup file index.ts
1
import "reflect-metadata";
2
import { Core } from "odi";
3
4
const port = 8080;
5
const sources = __dirname;
6
7
new Core({ server: { port }, sources }).listen();
Copied!
Build your application and run it tsc && node index.js Check it in your browser
It was just a basic example. There are many other interesting things. Check docs for further information.
Last modified 3yr ago