-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from TxtDot/proxy
Proxy, config changes
- Loading branch information
Showing
13 changed files
with
246 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ConfigService } from "./config.service"; | ||
|
||
let configSvc: ConfigService | undefined; | ||
|
||
export default function getConfig(): ConfigService { | ||
if (configSvc) { | ||
return configSvc; | ||
} | ||
|
||
configSvc = new ConfigService(); | ||
return configSvc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FastifyInstance } from "fastify"; | ||
import { IProxySchema, ProxySchema } from "../../types/requests/browser"; | ||
import axios from "../../types/axios"; | ||
|
||
export default async function proxyRoute(fastify: FastifyInstance) { | ||
fastify.get<IProxySchema>( | ||
"/proxy", | ||
{ schema: ProxySchema }, | ||
async (request, reply) => { | ||
const response = await axios.get(request.query.url); | ||
const mime: string | undefined = response.headers["content-type"]?.toString(); | ||
const clen: string | undefined = response.headers["content-length"]?.toString(); | ||
mime && reply.header("Content-Type", mime); | ||
clen && reply.header("Content-Length", Number(clen)); | ||
return reply.send(response.data); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.