commit
7011594d12
@ -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
20
src/routes/raw-html.ts
Normal 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;
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user