Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

galatajs/decorators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

!! Not Ready for Prime Time, Experimental !!


@galatajs/decorators

Decorator package of galatajs framework.

Installation

npm install @galatajs/decorators

Usage

Enable decorators in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Main file

import { createApp, App } from "@galatajs/app";
import { createDecoratorApp } from "@galatajs/decorators";
import { mainModule } from "./src/main.module";

const app: App = createApp(mainModule);
app.register(createDecoratorApp());

app.start();

In Controller

import { Controller, Get } from "@galatajs/decorators";
import { Request, Response } from "@galatajs/http";

@Controller("some")
export class SomeController {
  @Get("test")
  test(req: Request, res: Response) {
    return res.success("test");
  }
}

In Module

import { createModule, Module } from "@galatajs/app";
import { SomeController } from "./some.controller";

const module: Module = createModule({
  providers: [SomeController],
});