feat: raw html page

For custom user clients
This commit is contained in:
Artemy 2023-08-16 09:43:43 +03:00
parent 230fb3231d
commit eafdcf6240
2 changed files with 22 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import ejs from "ejs";
import getRoute from "./routes/get";
import parseRoute from "./routes/parse";
import indexRoute from "./routes/index";
import rawHtml from "./routes/raw-html";
class App {
config: IConfigService;
@ -38,6 +39,7 @@ class App {
fastify.register(indexRoute);
fastify.register(getRoute);
fastify.register(parseRoute);
fastify.register(rawHtml);
fastify.listen({ port: Number(this.config.get("PORT")) }, (err) => {
err && console.log(err);

20
src/routes/raw-html.ts Normal file
View File

@ -0,0 +1,20 @@
import { FastifyInstance } from "fastify";
import { GetRequest } from "../types/requests";
import handlePage from "../handlers/main";
import { generateRequestUrl } from "../utils";
export default async function rawHtml(fastify: FastifyInstance) {
fastify.get("/raw-html", async (request: GetRequest) => {
return (
await handlePage(
request.query.url,
generateRequestUrl(
request.protocol,
request.hostname,
request.originalUrl
)
)
).content;
});
}