$app/server
import { function getRequestEvent(): RequestEvent<Partial<Record<string, string>>, string | null>
Returns the current RequestEvent
. Can be used inside server hooks, server load
functions, actions, and endpoints (and functions called by them).
In environments without AsyncLocalStorage
, this must be called synchronously (i.e. not after an await
).
getRequestEvent, function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read } from '$app/server';
getRequestEvent
Disponible depuis la version 2.20.0
Renvoie l’objet RequestEvent
courant. Peut être utilisé dans les hooks de serveur, les fonctions
load
de serveur, les actions, et les endpoints (et dans les fonctions exécutées par ceux-ci).
Dans les environnements ne possédant pas de
AsyncLocalStorage
, cette
méthode doit être appelée de manière synchrone (c’est-à-dire pas après un await
).
function getRequestEvent(): RequestEvent<
Partial<Record<string, string>>,
string | null
>;
read
Disponible depuis la version 2.4.0
Lit le contenu d’un asset importé depuis le système de fichiers.
import { function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read } from '$app/server';
import const somefile: string
somefile from './somefile.txt';
const const asset: Response
asset = function read(asset: string): Response
Read the contents of an imported asset from the filesystem
read(const somefile: string
somefile);
const const text: string
text = await const asset: Response
asset.Body.text(): Promise<string>
text();
function read(asset: string): Response;
Modifier cette page sur Github llms.txt