handle curl
This commit is contained in:
parent
8880f2bce3
commit
fed0961210
3 changed files with 40 additions and 2 deletions
17
src/hooks.server.ts
Normal file
17
src/hooks.server.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import type { Handle } from '@sveltejs/kit';
|
||||
import figlet from 'figlet';
|
||||
import info from '$lib';
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
if (!event.request.headers.get('user-agent')?.includes('curl')) return await resolve(event);
|
||||
else return new Response(`\
|
||||
${info.title} - curl version
|
||||
|
||||
${await figlet.text(info.name.toUpperCase(), {
|
||||
font: "Standard",
|
||||
// @ts-expect-error
|
||||
}).catch(() => info.name.toUpperCase())}
|
||||
|
||||
${info.description}
|
||||
`);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue