bliss/api/src/modules/root/root.controller.ts

51 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-12-15 07:34:09 +00:00
import {
Controller,
Get,
Param,
Render,
Response,
2022-12-16 15:48:04 +00:00
Request,
2022-12-15 07:34:09 +00:00
UseGuards,
} from "@nestjs/common";
2022-12-25 07:45:18 +00:00
import { SkipThrottle } from "@nestjs/throttler";
2022-12-16 15:48:04 +00:00
import { Response as EResponse, Request as ERequest } from "express";
2022-12-15 07:34:09 +00:00
import { AuthGuard } from "modules/auth/guard/auth.guard";
2022-12-21 09:56:45 +00:00
import { RedisService } from "modules/redis/redis.service";
2022-12-15 07:34:09 +00:00
import { RootService } from "./root.service";
2022-12-25 07:45:18 +00:00
@SkipThrottle()
2022-12-15 07:34:09 +00:00
@Controller()
export class RootController {
2022-12-21 09:56:45 +00:00
constructor(
private readonly rootService: RootService,
private readonly redisService: RedisService
) {}
2022-12-15 07:34:09 +00:00
@Get()
hello() {
return "<pre>Hello World!</pre>";
}
2022-12-18 02:30:26 +00:00
@Get("server-settings")
check() {
2022-12-21 09:56:45 +00:00
return this.redisService.readServerSettings();
2022-12-18 02:30:26 +00:00
}
2022-12-15 07:34:09 +00:00
@UseGuards(AuthGuard)
@Get("statistics")
getStats() {
return this.rootService.getStatistics();
}
@Get(":slug")
@Render("index")
2022-12-16 15:48:04 +00:00
file(@Param("slug") slug: string, @Request() req: ERequest) {
return this.rootService.getFile(slug, req);
2022-12-15 07:34:09 +00:00
}
@Get("d/:filename")
thumbnail(@Param("filename") filename: string, @Response() res: EResponse) {
2022-12-17 08:34:23 +00:00
return this.rootService.downloadFile(filename, res);
2022-12-15 07:34:09 +00:00
}
}