gaurishhs / elysia-decorators

Decorators support plugin for Elysia
MIT License
52 stars 6 forks source link

Example contains a missing `path` for the `Get()` decorator - causes a type error #2

Closed joshuaja-tangelo closed 10 months ago

joshuaja-tangelo commented 11 months ago

Example should be updated to add a path string as an argument to the Get() decorator to avoid a type error:

import { Controller, Get, decorators } from "elysia-decorators";
import { Elysia } from "elysia";

// /users prefix
@Controller("/users/")
class UsersController {
  @Get("")
  index() {
    return "Hello World";
  }
}

const app = new Elysia();

app.use(
  decorators({
    controllers: [UsersController],
  })
);

app.listen(3000);

Additionally, the user will need to make sure to set "experimentalDecorators": true, in their tsconfig.json compilerOptions object to avoid a type error on the Controller() decorator argument.

gaurishhs commented 10 months ago

Fixed