mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: /raw/{id} endpoint
This commit is contained in:
@@ -33,10 +33,6 @@ bld/
|
|||||||
[Ll]og/
|
[Ll]og/
|
||||||
[Ll]ogs/
|
[Ll]ogs/
|
||||||
|
|
||||||
p/
|
|
||||||
privp/
|
|
||||||
raw/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
const apiUrl = process.env.VITE_API_URL || 'http://localhost:5050';
|
||||||
|
|
||||||
|
export const GET: RequestHandler = async ({ params }) => {
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
const res = await fetch(`${apiUrl}/api/paste/${id}/raw`);
|
||||||
|
|
||||||
|
if (res.status === 404) {
|
||||||
|
return new Response('Paste not found', { status: 404 });
|
||||||
|
}
|
||||||
|
const content = await res.text();
|
||||||
|
return new Response(content, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain; charset=utf-8'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user