Skip to content

crelte / server / ServerRouter

Class: ServerRouter ​

Constructors ​

Constructor ​

ts
new ServerRouter(
   endpointUrl, 
   frontendUrl, 
   env, 
   sites, 
   opts?): ServerRouter;

Parameters ​

endpointUrl ​

string

frontendUrl ​

string

env ​

Map<string, string>

sites ​

SiteFromGraphQl[]

opts? ​

RouterOptions = {}

Returns ​

ServerRouter

Properties ​

all ​

ts
all: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


connect ​

ts
connect: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


delete ​

ts
delete: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


get ​

ts
get: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


ts
head: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


options ​

ts
options: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


patch ​

ts
patch: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


post ​

ts
post: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


put ​

ts
put: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


trace ​

ts
trace: (pattern, ...handlers) => this;

Parameters ​

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this

Accessors ​

sites ​

Get Signature ​

ts
get sites(): Site[];

The sites which are available

Returns ​

Site[]

Methods ​

add() ​

ts
add(
   method, 
   pattern, ...
   handlers): this;

Parameters ​

method ​

Methods

pattern ​

Pattern

handlers ​

...Handler[]

Returns ​

this


getEnv() ​

Call Signature ​

ts
getEnv(name): string;

returns an env variable from the craft/.env file.

Parameters ​
name ​

"ENDPOINT_URL"

Returns ​

string

Call Signature ​

ts
getEnv(name): string;

returns an env variable from the craft/.env file.

Parameters ​
name ​

"CRAFT_BASE_CP_URL"

Returns ​

string

Call Signature ​

ts
getEnv(name): string | null;

returns an env variable from the craft/.env file.

Parameters ​
name ​

string

Returns ​

string | null


primarySite() ​

ts
primarySite(): Site;

Returns the primary site

Returns ​

Site


query() ​

ts
query(
   query, 
   variables?, 
opts?): Promise<unknown>;

Run a Queries Query

Parameters ​

query ​

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>