reest
Version:
A library inspired by NestJS's elegance, specifically designed for efficient serverless API development on AWS Lambda. It streamlines the creation of microservices with automated Swagger documentation and enhanced decorator-based middleware support, makin
104 lines (91 loc) • 1.88 kB
text/typescript
import {
Body,
Controller,
Delete,
Get,
File,
Multer,
Param,
Patch,
Post,
Put,
Query,
IsFile,
Route,
Middleware,
} from "reest";
import {
IsString,
IsNumber,
IsOptional,
ValidateNested,
IsArray,
} from "class-validator";
import { Type } from "class-transformer";
import { FirstMiddleware } from "../middlewares/FirstMiddleware";
class QueryDto {
()
name: string;
()
()
age: number;
}
class Reporter {
()
name: string;
()
({}, { each: true })
age: number[];
}
class Coordinates {
()
x: string;
()
()
y: number;
()
({ each: true })
(() => Reporter)
reporters: Reporter[];
({ mime: ["image/jpg", "image/png", "image/jpeg"] })
testFile: File;
}
(FirstMiddleware)
("/cats")
export class CatsController extends Controller {
("/")
findAll() {
return "This action returns all users";
}
(FirstMiddleware)
(FirstMiddleware)
("/:id")
findOne("id") id: string, () q: QueryDto) {
(console.log(q.age, q.name);
return `This action returns a user with id ${id}`;
}
("/")
("testFile")
posta(body: Coordinates) {
() console.log(body);
return `This action returns a user with id ${body.x} ${body.y}`;
}
("/x")
("testFile2", { single: true })
posta2(body: Reporter) {
() console.log(body);
return `This action returns a user with id`;
}
("/")
create() {
return "This action adds a new user";
}
("/:id")
update("id") id: number) {
(return `This action updates a user with id ${id}`;
}
("/:id")
remove("id") id: string) {
(return `This action removes a user with id ${id}`;
}
}