crelte / server / CrelteServerRequest
Class: CrelteServerRequest
Constructors
Constructor
new CrelteServerRequest(req, opts): CrelteServerRequest;Parameters
req
opts
Returns
CrelteServerRequest
Properties
req
req: ServerRequest;The current request ServerRequest
Accessors
cookies
Get Signature
get cookies(): Cookies;Get the Cookies instance
Returns
graphQl
Get Signature
get graphQl(): Queries;Get the Queries instance
Returns
preferredLanguages
Get Signature
get preferredLanguages(): string[];The languages which are preferred by the user
Returns
string[]
site
Get Signature
get site(): Site;Easy access to this.req.site
Note
The site might not always match with the current route but be the site default site or one that matches the users language.
Returns
sites
Get Signature
get sites(): Site[];The sites which are available
Returns
Site[]
Methods
backendUrl()
backendUrl(path?): URL;returns the backend url with an optional path
Note
For the origin the ENDPOINT_URL env variable is used
Parameters
path?
string
Returns
URL
frontendUrl()
frontendUrl(path?): URL;returns the frontend url with an optional path
Note
For the origin the FRONTEND_URL env variable is used
Parameters
path?
string
Returns
URL
getEnv()
Call Signature
getEnv(name): string;returns an env variable from the craft/.env file.
Parameters
name
"ENDPOINT_URL"
Returns
string
Call Signature
getEnv(name): string;returns an env variable from the craft/.env file.
Parameters
name
"CRAFT_WEB_URL"
Returns
string
Call Signature
getEnv(name): string;returns an env variable from the craft/.env file.
Parameters
name
"FRONTEND_URL"
Returns
string
Call Signature
getEnv(name): string | null;returns an env variable from the craft/.env file.
Parameters
name
string
Returns
string | null
preferredSite()
preferredSite(): Site | null;Returns a site which is preferred based on the users language
Returns null if no site could be determined
Returns
Site | null
primarySite()
primarySite(): Site;Returns the primary site
Returns
query()
query(
query,
variables,
opts): Promise<unknown>;Run a Queries Query
Parameters
query
the default export from a graphql file or the gqlquery {} function
variables
Record<string, unknown> = {}
variables that should be passed to the graphql query
opts
QueryOptions = {}
Returns
Promise<unknown>