nexusframework 0.3.0-beta.73 → 0.3.0-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +55 -55
- package/README.md +12 -12
- package/about/index.json +5 -5
- package/about/index.nhp +4 -4
- package/icon.png +0 -0
- package/index.d.ts +0 -2
- package/index.js +0 -0
- package/index.js.map +1 -1
- package/index.ts +101 -101
- package/indexOfSkeleton.nhp +133 -133
- package/legacySkeleton.nhp +22 -22
- package/loader/overlay.css +1 -1
- package/loader/overlay.html +25 -25
- package/loader/overlay.scss +152 -152
- package/package.json +102 -90
- package/scripts/es5/compat.js +100 -100
- package/scripts/es5/compat.min.js +1 -1
- package/scripts/es5/loader.js +0 -0
- package/scripts/es5/loader.js.map +0 -0
- package/scripts/es5/loader.min.js +1 -1
- package/scripts/es5/loader.min.js.map +0 -0
- package/scripts/es5/nexusframeworkclient.js +1224 -1224
- package/scripts/es5/nexusframeworkclient.js.map +0 -0
- package/scripts/es5/nexusframeworkclient.min.js +1 -1
- package/scripts/es5/nexusframeworkclient.min.js.map +0 -0
- package/scripts/es6/compat.js +64 -64
- package/scripts/es6/compat.min.js +1 -1
- package/scripts/es6/loader.js +0 -0
- package/scripts/es6/loader.js.map +0 -0
- package/scripts/es6/loader.min.js +1 -1
- package/scripts/es6/loader.min.js.map +0 -0
- package/scripts/es6/nexusframeworkclient.js +1146 -1146
- package/scripts/es6/nexusframeworkclient.js.map +0 -0
- package/scripts/es6/nexusframeworkclient.min.js +1 -1
- package/scripts/es6/nexusframeworkclient.min.js.map +0 -0
- package/scripts/index.d.ts +259 -259
- package/scripts/src/compat.ts +62 -62
- package/scripts/src/loader.ts +385 -385
- package/scripts/src/nexusframeworkclient.ts +1163 -1163
- package/scripts/tsconfig.json +11 -11
- package/src/cli.d.ts +1 -0
- package/src/cli.js +102 -102
- package/src/cli.js.map +1 -1
- package/src/cli.ts +101 -101
- package/src/compileScripts.d.ts +0 -0
- package/src/compileScripts.js +0 -0
- package/src/compileScripts.js.map +1 -1
- package/src/compileScripts.ts +153 -153
- package/src/nexusframework.d.ts +5 -5
- package/src/nexusframework.js +44 -37
- package/src/nexusframework.js.map +1 -1
- package/src/nexusframework.ts +3631 -3622
- package/templates/basic/package.json +3 -3
- package/templates/basic/www/skeleton.nhp +1 -1
- package/templates/bootstrap/package.json +2 -2
- package/templates/bootstrap/www/skeleton.nhp +1 -1
- package/templates/bootstrap-material-design/package.json +2 -2
- package/templates/bootstrap-material-design/www/skeleton.nhp +1 -1
- package/tsconfig.json +25 -22
- package/types.d.ts +612 -612
package/types.d.ts
CHANGED
|
@@ -1,612 +1,612 @@
|
|
|
1
|
-
import { NexusFramework } from "./src/nexusframework";
|
|
2
|
-
import { CacheGenerator } from "lru-weak-cache/types";
|
|
3
|
-
import { nexusfork } from "nexusfork/types";
|
|
4
|
-
|
|
5
|
-
import { Template } from "nhp/lib/Template";
|
|
6
|
-
|
|
7
|
-
import { Agent, Details } from "useragent";
|
|
8
|
-
|
|
9
|
-
declare interface UploadedFile {
|
|
10
|
-
/**
|
|
11
|
-
* The original filename when uploaded.
|
|
12
|
-
*/
|
|
13
|
-
originalname: string,
|
|
14
|
-
destination: string,
|
|
15
|
-
/**
|
|
16
|
-
* The name of the field the file was uploaded to.
|
|
17
|
-
*/
|
|
18
|
-
fieldname: string,
|
|
19
|
-
filename: string,
|
|
20
|
-
mimetype: string,
|
|
21
|
-
/**
|
|
22
|
-
* The full path and filename where the file was uploaded to.
|
|
23
|
-
*/
|
|
24
|
-
path: string,
|
|
25
|
-
size: number
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare const enum BodyProcessor {
|
|
29
|
-
URLEncoded,
|
|
30
|
-
MultipartFormData,
|
|
31
|
-
JSONBody
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare interface AvatarFormats {
|
|
35
|
-
webp: string;
|
|
36
|
-
gif?: string;
|
|
37
|
-
png?: string;
|
|
38
|
-
jpg?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare interface AvatarSizes {
|
|
42
|
-
icon: AvatarFormats;
|
|
43
|
-
small: AvatarFormats;
|
|
44
|
-
medium: AvatarFormats;
|
|
45
|
-
large: AvatarFormats;
|
|
46
|
-
huge: AvatarFormats;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
declare interface AvatarLookup extends AvatarSizes {
|
|
50
|
-
["x2"]: AvatarSizes
|
|
51
|
-
["x3"]: AvatarSizes
|
|
52
|
-
["x4"]: AvatarSizes
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare interface User {
|
|
56
|
-
name?: string;
|
|
57
|
-
id?: string | number;
|
|
58
|
-
displayName?: string;
|
|
59
|
-
email?: string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Return an avatar at or above the requested size.
|
|
63
|
-
* Or contains the only available avatar as a URL.
|
|
64
|
-
*/
|
|
65
|
-
avatar?: string | AvatarLookup;
|
|
66
|
-
}
|
|
67
|
-
declare interface StaticMountOptions {
|
|
68
|
-
autoIndexSkeleton?: string | Template;
|
|
69
|
-
noOtherMounts?: boolean;
|
|
70
|
-
autoIndex?: boolean;
|
|
71
|
-
mutable?: boolean;
|
|
72
|
-
}
|
|
73
|
-
declare interface Resource {
|
|
74
|
-
source: string | URL;
|
|
75
|
-
inline?: boolean;
|
|
76
|
-
integrity?: string;
|
|
77
|
-
dependencies?: string[];
|
|
78
|
-
}
|
|
79
|
-
declare interface Font {
|
|
80
|
-
name: string;
|
|
81
|
-
weight?: number;
|
|
82
|
-
italic?: boolean;
|
|
83
|
-
}
|
|
84
|
-
declare interface RenderOptions {
|
|
85
|
-
/**
|
|
86
|
-
* The root path.
|
|
87
|
-
*/
|
|
88
|
-
root?: string;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The NHP skeleton to use for this mount, relative to the root path (if set).
|
|
92
|
-
*/
|
|
93
|
-
skeleton?: string | Template;
|
|
94
|
-
/**
|
|
95
|
-
* The page system skeleton to use for this mount, relative to the root path (if set).
|
|
96
|
-
*/
|
|
97
|
-
pagesysskeleton?: string | PageSystemSkeleton;
|
|
98
|
-
/**
|
|
99
|
-
* The legacy NHP skeleton to use for this mount, relative to the root path (if set).
|
|
100
|
-
*/
|
|
101
|
-
legacyskeleton?: string | Template;
|
|
102
|
-
/**
|
|
103
|
-
* The NHP skeleton to use for displaying folder directories, relative to the root path (if set).
|
|
104
|
-
*/
|
|
105
|
-
autoindexskeleton?: string | Template;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Paths to error documents, relative to the pages of this mount.
|
|
109
|
-
*/
|
|
110
|
-
errordoc?: {[index: string]: string};
|
|
111
|
-
|
|
112
|
-
fonts?: (Font|string)[];
|
|
113
|
-
scripts?: Resource[];
|
|
114
|
-
styles?: Resource[];
|
|
115
|
-
|
|
116
|
-
locals?: ResponseLocals<User>;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Paths to icons.
|
|
120
|
-
*/
|
|
121
|
-
icons?: {[index: string]: string | URL};
|
|
122
|
-
}
|
|
123
|
-
declare interface ImageResizerOptions {
|
|
124
|
-
square?: boolean;
|
|
125
|
-
notransparency?: boolean;
|
|
126
|
-
sizes?: number[] | number[][];
|
|
127
|
-
cache?: number | {minAge?:number,maxAge?:number,capacity?:number,resetTimersOnAccess?:boolean} | false | undefined;
|
|
128
|
-
diskcache?: string;
|
|
129
|
-
}
|
|
130
|
-
declare interface MountOptions extends RenderOptions {
|
|
131
|
-
/**
|
|
132
|
-
* The path to icon to use in all required sizes, relative to the root path (if set).
|
|
133
|
-
*/
|
|
134
|
-
iconfile?: string;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* If true, the path will be mounted with filesystem changes applied as they're detected.
|
|
138
|
-
*/
|
|
139
|
-
mutable?: boolean;
|
|
140
|
-
}
|
|
141
|
-
export type ApiTypes = ("bson" | "json" | "debug" | "xml");
|
|
142
|
-
export type FunctionOrString = Function | string;
|
|
143
|
-
export type FunctionOrStringOrEitherWithData = FunctionOrString | {impl: FunctionOrString, data: any};
|
|
144
|
-
declare interface PageSystemSkeleton {
|
|
145
|
-
(template: string, options: any, req: Request, res: Response, next: (err: Error, data?: any) => void): void;
|
|
146
|
-
}
|
|
147
|
-
export type UserAgentDetails = Agent & Details & {es6?: boolean, legacy?: boolean};
|
|
148
|
-
declare interface BaseLocals<U extends User> {
|
|
149
|
-
/**
|
|
150
|
-
* The user, if any;
|
|
151
|
-
*/
|
|
152
|
-
user?: U;
|
|
153
|
-
/**
|
|
154
|
-
* Information about the seragent of the request.
|
|
155
|
-
* Provided by seragent.
|
|
156
|
-
*/
|
|
157
|
-
useragent?: UserAgentDetails;
|
|
158
|
-
/**
|
|
159
|
-
* Whether or not the client accepts webp.
|
|
160
|
-
*/
|
|
161
|
-
webp?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Either "webp" or "png" depending on the request.
|
|
164
|
-
*/
|
|
165
|
-
webpOrPng?: string;
|
|
166
|
-
/**
|
|
167
|
-
* Either "webp" or "jpg" depending on the request.
|
|
168
|
-
*/
|
|
169
|
-
webpOrJpg?: string;
|
|
170
|
-
/**
|
|
171
|
-
* Either "webp" or "gif" depending on the request.
|
|
172
|
-
*/
|
|
173
|
-
webpOrGif?: string;
|
|
174
|
-
/**
|
|
175
|
-
* The site url for the directory and domain nexusframework was requested from.
|
|
176
|
-
*/
|
|
177
|
-
siteUrl?: string;
|
|
178
|
-
/**
|
|
179
|
-
* The subdirectory nexusframework was requested from, if one.
|
|
180
|
-
*/
|
|
181
|
-
sitePrefix?: string;
|
|
182
|
-
}
|
|
183
|
-
declare interface Request<U extends User> extends BaseLocals<U>, nexusfork.WebRequest {
|
|
184
|
-
res: Response<ResponseLocals<U>>;
|
|
185
|
-
/**
|
|
186
|
-
* The NexusFramework instance.
|
|
187
|
-
*/
|
|
188
|
-
nexusframework?: NexusFramework;
|
|
189
|
-
/**
|
|
190
|
-
* The request handler mapping.
|
|
191
|
-
*/
|
|
192
|
-
mapping?: RequestHandlerMethodExtendedMapping;
|
|
193
|
-
/**
|
|
194
|
-
* An array of all the RegExp matches while processing the request.
|
|
195
|
-
*/
|
|
196
|
-
matches?: RegExpMatchArray[];
|
|
197
|
-
/**
|
|
198
|
-
* The current RegExp match while procesing the request.
|
|
199
|
-
*/
|
|
200
|
-
match?: RegExpMatchArray;
|
|
201
|
-
/**
|
|
202
|
-
* The current mount.
|
|
203
|
-
*/
|
|
204
|
-
mount?: RequestHandlerEntry;
|
|
205
|
-
/**
|
|
206
|
-
* True when requested through the Page System API.
|
|
207
|
-
*/
|
|
208
|
-
pagesys?: boolean;
|
|
209
|
-
/**
|
|
210
|
-
* The associated Socket.IO Socket, if requested through the page API and using Socket.IO.
|
|
211
|
-
*/
|
|
212
|
-
io?: SocketIO.Socket;
|
|
213
|
-
/**
|
|
214
|
-
* The API encoder being used for this request, if any.
|
|
215
|
-
*/
|
|
216
|
-
api?: ApiTypes;
|
|
217
|
-
/**
|
|
218
|
-
* True if this request is either .xhr or .io.
|
|
219
|
-
*/
|
|
220
|
-
xhrOrIO?: boolean;
|
|
221
|
-
/**
|
|
222
|
-
* Contains an array of uploaded files.
|
|
223
|
-
* These files are destroyed automatically when the response ends.
|
|
224
|
-
*/
|
|
225
|
-
files?: {[index: string]: UploadedFile|UploadedFile[]};
|
|
226
|
-
/**
|
|
227
|
-
* Process the request body.
|
|
228
|
-
* By default all processors are usable, and the processor chosen is determined by the request content-type header.
|
|
229
|
-
*
|
|
230
|
-
* @param cb The callback
|
|
231
|
-
* @param processors The processors, all by default
|
|
232
|
-
*/
|
|
233
|
-
processBody?(cb: (err?: Error) => void, ...processors: BodyProcessor[]): Request;
|
|
234
|
-
/**
|
|
235
|
-
* Read the request body to a Buffer.
|
|
236
|
-
*/
|
|
237
|
-
readBody?(cb: (err: Error, data?: Buffer) => void, limit?: number): void;
|
|
238
|
-
/**
|
|
239
|
-
* The subdirectory nexusframework was requested from, if one.
|
|
240
|
-
*/
|
|
241
|
-
buildUrl?(uri?: string): string;
|
|
242
|
-
}
|
|
243
|
-
declare interface Renderer {
|
|
244
|
-
(out: {write: (data: string) => void},flush?:() => void): void
|
|
245
|
-
}
|
|
246
|
-
declare interface SocialTags {
|
|
247
|
-
/**
|
|
248
|
-
* The url of the page, will use the request to build this as a fallback when available
|
|
249
|
-
*/
|
|
250
|
-
url?: string | URL;
|
|
251
|
-
/**
|
|
252
|
-
* The title of the page, will use res.locals.title as a fallback when available
|
|
253
|
-
*/
|
|
254
|
-
title?: string;
|
|
255
|
-
/**
|
|
256
|
-
* The title of the site.
|
|
257
|
-
*/
|
|
258
|
-
siteTitle?: string;
|
|
259
|
-
/**
|
|
260
|
-
* The url to an image to display for this page.
|
|
261
|
-
*/
|
|
262
|
-
image?: string | URL;
|
|
263
|
-
/**
|
|
264
|
-
* The url to a relevant page.
|
|
265
|
-
*/
|
|
266
|
-
seeAlso?: string | URL;
|
|
267
|
-
/**
|
|
268
|
-
* The description of this page.
|
|
269
|
-
*/
|
|
270
|
-
description: string;
|
|
271
|
-
/**
|
|
272
|
-
* The type of twitter card, will use summary by default
|
|
273
|
-
*/
|
|
274
|
-
twitterCard?: string;
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
declare interface ResponseLocals<U extends User> extends BaseLocals<U> {
|
|
278
|
-
[key: string]: any;
|
|
279
|
-
}
|
|
280
|
-
declare interface Response<U extends User, L extends ResponseLocals<U>> extends nexusfork.WebResponse {
|
|
281
|
-
locals: L;
|
|
282
|
-
req: Request<U>;
|
|
283
|
-
renderoptions?: RenderOptions;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Render a page using a template engine and serve it.
|
|
287
|
-
* This method will use the skeleton if available, `render` will not.
|
|
288
|
-
*
|
|
289
|
-
* @param filename The absolute path to a file to render, or template source
|
|
290
|
-
* @param options The variables to use for rendering
|
|
291
|
-
*/
|
|
292
|
-
sendRender(filename: string, locals?: any): Response;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Replace the render options for this response.
|
|
296
|
-
*/
|
|
297
|
-
setRenderOptions(options: RenderOptions): void;
|
|
298
|
-
/**
|
|
299
|
-
* Override the render options for this response.
|
|
300
|
-
*/
|
|
301
|
-
applyRenderOptions(options: RenderOptions): void;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Enable the NexusFramework Loader to the script queue, and defer all scripts and styles,
|
|
305
|
-
* as well as display a configurable loading screen.
|
|
306
|
-
*/
|
|
307
|
-
enableLoader(): void;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Set a meta tag in the header html.
|
|
311
|
-
*/
|
|
312
|
-
setMetaTag(name: string, content?: string): void;
|
|
313
|
-
setSocialTags(info: SocialTags): void;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Add a style to the style queue.
|
|
317
|
-
*/
|
|
318
|
-
addStyle(url: string, integrity?: string, ...deps: string[]): void;
|
|
319
|
-
addInlineStyle(source: string, ...deps: string[]): void;
|
|
320
|
-
/**
|
|
321
|
-
* Add a font from Google's library, with the specified weight.
|
|
322
|
-
*
|
|
323
|
-
* @param family The font family
|
|
324
|
-
* @param weight The font weight, default 400
|
|
325
|
-
* @param italic Italic, default false
|
|
326
|
-
*/
|
|
327
|
-
addFont(family: string, weight?: number, italic?: boolean): void;
|
|
328
|
-
/**
|
|
329
|
-
* Add a renderer to the header.
|
|
330
|
-
*/
|
|
331
|
-
addHeaderRenderer(renderer: Renderer | string): void;
|
|
332
|
-
/**
|
|
333
|
-
* Push the script and style queue.
|
|
334
|
-
* Stores it for popping later.
|
|
335
|
-
*
|
|
336
|
-
* @param andClear And clear the queue
|
|
337
|
-
*/
|
|
338
|
-
pushResourceQueues(andClear?: boolean): void;
|
|
339
|
-
/**
|
|
340
|
-
* Pops a script and style queue.
|
|
341
|
-
*/
|
|
342
|
-
popResourceQueues(): void;
|
|
343
|
-
clearScripts(): void;
|
|
344
|
-
clearStyles(): void;
|
|
345
|
-
clearFonts(): void;
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Add a name to the body's classes.
|
|
349
|
-
*/
|
|
350
|
-
addBodyClassName(name: string): void;
|
|
351
|
-
/**
|
|
352
|
-
* Remove a name to the body's classes.
|
|
353
|
-
*/
|
|
354
|
-
removeBodyClassName(name: string): void;
|
|
355
|
-
/**
|
|
356
|
-
* Add a renderer after the body.
|
|
357
|
-
*/
|
|
358
|
-
addAfterBodyRenderer(renderer: Renderer | string): void;
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Add a renderer to the footer.
|
|
362
|
-
*/
|
|
363
|
-
addFooterRenderer(renderer: Renderer | string): void;
|
|
364
|
-
/**
|
|
365
|
-
* Add a script to the script queue.
|
|
366
|
-
*/
|
|
367
|
-
addScript(url: string, integrity?: string, ...deps: string[]): void;
|
|
368
|
-
addInlineScript(source: string, ...deps: string[]): void;
|
|
369
|
-
/**
|
|
370
|
-
* Add the Socket.IO Client to the script queue.
|
|
371
|
-
*/
|
|
372
|
-
addSocketIOClient(): void;
|
|
373
|
-
/**
|
|
374
|
-
* Add the NexusFramework Client to the script queue.
|
|
375
|
-
*
|
|
376
|
-
* @param includeSocketIO Whether or not to include and rely on Socket.IO, true by default
|
|
377
|
-
* @param autoEnablePageSystem Whether or not to enable the page system automatically, false by default
|
|
378
|
-
*/
|
|
379
|
-
addNexusFrameworkClient(includeSocketIO?: boolean, autoEnablePageSystem?: boolean): void;
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Write the header html to the stream.
|
|
383
|
-
* Try to position this just before the ending </head> tag.
|
|
384
|
-
*/
|
|
385
|
-
writeHeaderHtml(out?: NodeJS.WritableStream): void;
|
|
386
|
-
/**
|
|
387
|
-
* Write the after body html to the stream.
|
|
388
|
-
* Try to position this just after the <body> tag.
|
|
389
|
-
*/
|
|
390
|
-
writeAfterBodyHtml(out?: NodeJS.WritableStream): void;
|
|
391
|
-
/**
|
|
392
|
-
* Write the footer html to the stream.
|
|
393
|
-
* Try to position this just before the ending </body> tag.
|
|
394
|
-
*/
|
|
395
|
-
sendFooterHtml(out?: NodeJS.WritableStream): void;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Retreive the data used by NexusFrameworkLoader.load().
|
|
399
|
-
*/
|
|
400
|
-
getLoaderData(): any;
|
|
401
|
-
}
|
|
402
|
-
declare interface RequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
403
|
-
(req: I, res: O, next: (err?: Error) => void): void;
|
|
404
|
-
}
|
|
405
|
-
declare interface NHPRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
406
|
-
(req: I, res: O, next: (err?: Error, renderLocals?: any) => void): void;
|
|
407
|
-
}
|
|
408
|
-
declare interface RequestHandlerMethodMapping {
|
|
409
|
-
use?: NHPRequestHandler<any, any>;
|
|
410
|
-
get?: NHPRequestHandler<any, any>;
|
|
411
|
-
put?: NHPRequestHandler<any, any>;
|
|
412
|
-
post?: NHPRequestHandler<any, any>;
|
|
413
|
-
head?: NHPRequestHandler<any, any>;
|
|
414
|
-
patch?: NHPRequestHandler<any, any>;
|
|
415
|
-
del?: NHPRequestHandler<any, any>;
|
|
416
|
-
}
|
|
417
|
-
declare interface RequestHandlerMethodExtendedMapping extends RequestHandlerMethodMapping {
|
|
418
|
-
exists?: ExistsRequestHandler<any, any>;
|
|
419
|
-
access?: AccessRequestHandler<any, any>;
|
|
420
|
-
}
|
|
421
|
-
declare interface MappedRequestHandler extends RequestHandler<any, any>, RequestHandlerMethodMapping {}
|
|
422
|
-
declare interface ExtendedMappedRequestHandler extends RequestHandler<any, any>, RequestHandlerMethodExtendedMapping {}
|
|
423
|
-
declare interface ExistsRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
424
|
-
(req: I, res: O, exists: (err?: Error) => void, doesntExist: () => void): void;
|
|
425
|
-
}
|
|
426
|
-
declare interface RouteRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
427
|
-
(req: I, res: O, next: (err?: Error, routedpath?: string) => void, skip: () => void): void;
|
|
428
|
-
}
|
|
429
|
-
declare interface AccessRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
430
|
-
(req: I, res: O, allowed: (err?: Error) => void, denied: () => void): void;
|
|
431
|
-
}
|
|
432
|
-
declare interface Handler<I extends Request<User>, O extends Response<User>> {
|
|
433
|
-
(req: I, res: O, next?: (err: Error) => void): void;
|
|
434
|
-
}
|
|
435
|
-
interface RecursivePath {
|
|
436
|
-
[0]: string;
|
|
437
|
-
[index: number]: RecursivePath | string;
|
|
438
|
-
}
|
|
439
|
-
interface RequestHandlerEntry {
|
|
440
|
-
readonly leaf?: boolean;
|
|
441
|
-
handle: RequestHandler;
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Fetches children for this entry.
|
|
445
|
-
*/
|
|
446
|
-
children(): RequestHandlerChildEntry[];
|
|
447
|
-
/**
|
|
448
|
-
* Fetches the paths for children of this entry.
|
|
449
|
-
*/
|
|
450
|
-
childPaths(cb: (paths: string[]) => void, deep?: false): void;
|
|
451
|
-
/**
|
|
452
|
-
* Fetches the paths for children of this entry recursively.
|
|
453
|
-
*/
|
|
454
|
-
childPaths(cb: (paths: (RecursivePath | string)[]) => void, deep: true): void;
|
|
455
|
-
/**
|
|
456
|
-
* Fetches the child at path.
|
|
457
|
-
*
|
|
458
|
-
* @param path The path to search.
|
|
459
|
-
* @param createIfNotExists Whether or not to create the path if it doesn't exist.
|
|
460
|
-
*/
|
|
461
|
-
childAt(path: string, createIfNotExists?: boolean): RequestHandlerChildEntry;
|
|
462
|
-
/**
|
|
463
|
-
* Fetches the child at path.
|
|
464
|
-
*
|
|
465
|
-
* @param path The path.
|
|
466
|
-
* @param handler The handler to set.
|
|
467
|
-
* @param createIfNotExists Whether or not to create the path if it doesn't exist, true by default.
|
|
468
|
-
*/
|
|
469
|
-
setChild(path: string, handler: RequestHandlerChildEntry, createIfNotExists?: boolean): void;
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Fetches the view filename.
|
|
473
|
-
*
|
|
474
|
-
* @param type The type of view to fetch, by default its "nhp".
|
|
475
|
-
*/
|
|
476
|
-
view(type?: string): string;
|
|
477
|
-
/**
|
|
478
|
-
* Set the view filename for type.
|
|
479
|
-
*
|
|
480
|
-
* @param filename The view filename
|
|
481
|
-
* @param type The type of view to set, by default its "nhp".
|
|
482
|
-
*/
|
|
483
|
-
setView(filename: string, type?: string): void;
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Fetches the index handler for this entry.
|
|
487
|
-
*/
|
|
488
|
-
index(): RequestHandlerEntry;
|
|
489
|
-
/**
|
|
490
|
-
* Set the index handler for this entry.
|
|
491
|
-
*/
|
|
492
|
-
setIndex(index: RequestHandlerEntry): void;
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Fetches the route resolver for this entry.
|
|
496
|
-
*/
|
|
497
|
-
routeHandler(): RouteRequestHandler;
|
|
498
|
-
/**
|
|
499
|
-
* Fetches the access handler for this entry.
|
|
500
|
-
*/
|
|
501
|
-
accessHandler(): AccessRequestHandler;
|
|
502
|
-
/**
|
|
503
|
-
* Fetches the existence handler for this entry.
|
|
504
|
-
*/
|
|
505
|
-
existsHandler(): ExistsRequestHandler;
|
|
506
|
-
/**
|
|
507
|
-
* Set the route resolver for this entry.
|
|
508
|
-
*/
|
|
509
|
-
setRouteHandler(index: RouteRequestHandler): void;
|
|
510
|
-
/**
|
|
511
|
-
* Set the access handler for this entry.
|
|
512
|
-
*/
|
|
513
|
-
setAccessHandler(index: AccessRequestHandler): void;
|
|
514
|
-
/**
|
|
515
|
-
* Set the existence handler for this entry.
|
|
516
|
-
*/
|
|
517
|
-
setExistsHandler(index: ExistsRequestHandler): void;
|
|
518
|
-
/**
|
|
519
|
-
* Destroy this entry and all children
|
|
520
|
-
*/
|
|
521
|
-
destroy(): void;
|
|
522
|
-
}
|
|
523
|
-
interface RequestHandlerChildEntry extends RequestHandlerEntry {
|
|
524
|
-
readonly pattern: RegExp;
|
|
525
|
-
readonly rawPattern: string;
|
|
526
|
-
}
|
|
527
|
-
type APIEncoder<U extends User, L extends ResponseLocals<U>> = (locals: L, req: Request<U>, res: Response<L>) => void;
|
|
528
|
-
declare interface Mount extends MountOptions {
|
|
529
|
-
/**
|
|
530
|
-
* The filesystem path.
|
|
531
|
-
*/
|
|
532
|
-
fspath: string;
|
|
533
|
-
/**
|
|
534
|
-
* The web path.
|
|
535
|
-
*/
|
|
536
|
-
webpath: string;
|
|
537
|
-
}
|
|
538
|
-
declare interface APIResponse {
|
|
539
|
-
code: number;
|
|
540
|
-
warnings?: string[];
|
|
541
|
-
error?: {
|
|
542
|
-
type: string,
|
|
543
|
-
message: string,
|
|
544
|
-
stack: string
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
[key: string]: any;
|
|
548
|
-
}
|
|
549
|
-
declare interface Config extends MountOptions {
|
|
550
|
-
/**
|
|
551
|
-
* The pages path, relative to the root path.
|
|
552
|
-
* Default "pages"
|
|
553
|
-
*/
|
|
554
|
-
pages?: string;
|
|
555
|
-
/**
|
|
556
|
-
* The URL prefix
|
|
557
|
-
* Default "/"
|
|
558
|
-
*/
|
|
559
|
-
prefix?: string;
|
|
560
|
-
/**
|
|
561
|
-
* When true, the loader will not be enabled for compatible browsers.
|
|
562
|
-
* The loader is required for the dynamic page system.
|
|
563
|
-
*/
|
|
564
|
-
noloader?: boolean;
|
|
565
|
-
/**
|
|
566
|
-
* When true, scripts will not be served on {{prefix}}/:scripts
|
|
567
|
-
*/
|
|
568
|
-
noscripts?: boolean;
|
|
569
|
-
/**
|
|
570
|
-
* When true, about will not be served on {{prefix}}/:about
|
|
571
|
-
*/
|
|
572
|
-
noabout?: boolean;
|
|
573
|
-
/**
|
|
574
|
-
* When true, disables logging.
|
|
575
|
-
*/
|
|
576
|
-
nologging?: boolean;
|
|
577
|
-
/**
|
|
578
|
-
* When true, no Socket.IO instance will be created on {{prefix}}/:io
|
|
579
|
-
*/
|
|
580
|
-
noio?: boolean;
|
|
581
|
-
/**
|
|
582
|
-
* When true, no API support will be installed
|
|
583
|
-
*/
|
|
584
|
-
noapi?: boolean;
|
|
585
|
-
/**
|
|
586
|
-
* When true, serves the socket.io library to guests too.
|
|
587
|
-
*/
|
|
588
|
-
guestio?: boolean;
|
|
589
|
-
/**
|
|
590
|
-
* When true, enables the page system over Socket.IO
|
|
591
|
-
*/
|
|
592
|
-
iopagesys?: boolean;
|
|
593
|
-
/**
|
|
594
|
-
* Override the socket.io path
|
|
595
|
-
*/
|
|
596
|
-
iopath?: string;
|
|
597
|
-
/**
|
|
598
|
-
* When true, the page system will not be initialized
|
|
599
|
-
*/
|
|
600
|
-
nopagesys?: boolean;
|
|
601
|
-
/**
|
|
602
|
-
* Any items in this array are disabled from the built-in API encoders
|
|
603
|
-
*/
|
|
604
|
-
apiblacklist?: ApiTypes[];
|
|
605
|
-
/**
|
|
606
|
-
* Any items in this array are filtered from the response of API calls
|
|
607
|
-
*/
|
|
608
|
-
apifilter?: string[];
|
|
609
|
-
mounts?: Mount[] | Mount;
|
|
610
|
-
modules?: string[] | string;
|
|
611
|
-
[key: string]: any;
|
|
612
|
-
}
|
|
1
|
+
import { NexusFramework } from "./src/nexusframework";
|
|
2
|
+
import { CacheGenerator } from "lru-weak-cache/types";
|
|
3
|
+
import { nexusfork } from "nexusfork/types";
|
|
4
|
+
|
|
5
|
+
import { Template } from "nhp/lib/Template";
|
|
6
|
+
|
|
7
|
+
import { Agent, Details } from "useragent";
|
|
8
|
+
|
|
9
|
+
declare interface UploadedFile {
|
|
10
|
+
/**
|
|
11
|
+
* The original filename when uploaded.
|
|
12
|
+
*/
|
|
13
|
+
originalname: string,
|
|
14
|
+
destination: string,
|
|
15
|
+
/**
|
|
16
|
+
* The name of the field the file was uploaded to.
|
|
17
|
+
*/
|
|
18
|
+
fieldname: string,
|
|
19
|
+
filename: string,
|
|
20
|
+
mimetype: string,
|
|
21
|
+
/**
|
|
22
|
+
* The full path and filename where the file was uploaded to.
|
|
23
|
+
*/
|
|
24
|
+
path: string,
|
|
25
|
+
size: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const enum BodyProcessor {
|
|
29
|
+
URLEncoded,
|
|
30
|
+
MultipartFormData,
|
|
31
|
+
JSONBody
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare interface AvatarFormats {
|
|
35
|
+
webp: string;
|
|
36
|
+
gif?: string;
|
|
37
|
+
png?: string;
|
|
38
|
+
jpg?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface AvatarSizes {
|
|
42
|
+
icon: AvatarFormats;
|
|
43
|
+
small: AvatarFormats;
|
|
44
|
+
medium: AvatarFormats;
|
|
45
|
+
large: AvatarFormats;
|
|
46
|
+
huge: AvatarFormats;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare interface AvatarLookup extends AvatarSizes {
|
|
50
|
+
["x2"]: AvatarSizes
|
|
51
|
+
["x3"]: AvatarSizes
|
|
52
|
+
["x4"]: AvatarSizes
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare interface User {
|
|
56
|
+
name?: string;
|
|
57
|
+
id?: string | number;
|
|
58
|
+
displayName?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Return an avatar at or above the requested size.
|
|
63
|
+
* Or contains the only available avatar as a URL.
|
|
64
|
+
*/
|
|
65
|
+
avatar?: string | AvatarLookup;
|
|
66
|
+
}
|
|
67
|
+
declare interface StaticMountOptions {
|
|
68
|
+
autoIndexSkeleton?: string | Template;
|
|
69
|
+
noOtherMounts?: boolean;
|
|
70
|
+
autoIndex?: boolean;
|
|
71
|
+
mutable?: boolean;
|
|
72
|
+
}
|
|
73
|
+
declare interface Resource {
|
|
74
|
+
source: string | URL;
|
|
75
|
+
inline?: boolean;
|
|
76
|
+
integrity?: string;
|
|
77
|
+
dependencies?: string[];
|
|
78
|
+
}
|
|
79
|
+
declare interface Font {
|
|
80
|
+
name: string;
|
|
81
|
+
weight?: number;
|
|
82
|
+
italic?: boolean;
|
|
83
|
+
}
|
|
84
|
+
declare interface RenderOptions {
|
|
85
|
+
/**
|
|
86
|
+
* The root path.
|
|
87
|
+
*/
|
|
88
|
+
root?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The NHP skeleton to use for this mount, relative to the root path (if set).
|
|
92
|
+
*/
|
|
93
|
+
skeleton?: string | Template;
|
|
94
|
+
/**
|
|
95
|
+
* The page system skeleton to use for this mount, relative to the root path (if set).
|
|
96
|
+
*/
|
|
97
|
+
pagesysskeleton?: string | PageSystemSkeleton;
|
|
98
|
+
/**
|
|
99
|
+
* The legacy NHP skeleton to use for this mount, relative to the root path (if set).
|
|
100
|
+
*/
|
|
101
|
+
legacyskeleton?: string | Template;
|
|
102
|
+
/**
|
|
103
|
+
* The NHP skeleton to use for displaying folder directories, relative to the root path (if set).
|
|
104
|
+
*/
|
|
105
|
+
autoindexskeleton?: string | Template;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Paths to error documents, relative to the pages of this mount.
|
|
109
|
+
*/
|
|
110
|
+
errordoc?: {[index: string]: string};
|
|
111
|
+
|
|
112
|
+
fonts?: (Font|string)[];
|
|
113
|
+
scripts?: Resource[];
|
|
114
|
+
styles?: Resource[];
|
|
115
|
+
|
|
116
|
+
locals?: ResponseLocals<User>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Paths to icons.
|
|
120
|
+
*/
|
|
121
|
+
icons?: {[index: string]: string | URL};
|
|
122
|
+
}
|
|
123
|
+
declare interface ImageResizerOptions {
|
|
124
|
+
square?: boolean;
|
|
125
|
+
notransparency?: boolean;
|
|
126
|
+
sizes?: number[] | number[][];
|
|
127
|
+
cache?: number | {minAge?:number,maxAge?:number,capacity?:number,resetTimersOnAccess?:boolean} | false | undefined;
|
|
128
|
+
diskcache?: string;
|
|
129
|
+
}
|
|
130
|
+
declare interface MountOptions extends RenderOptions {
|
|
131
|
+
/**
|
|
132
|
+
* The path to icon to use in all required sizes, relative to the root path (if set).
|
|
133
|
+
*/
|
|
134
|
+
iconfile?: string;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* If true, the path will be mounted with filesystem changes applied as they're detected.
|
|
138
|
+
*/
|
|
139
|
+
mutable?: boolean;
|
|
140
|
+
}
|
|
141
|
+
export type ApiTypes = ("bson" | "json" | "debug" | "xml");
|
|
142
|
+
export type FunctionOrString = Function | string;
|
|
143
|
+
export type FunctionOrStringOrEitherWithData = FunctionOrString | {impl: FunctionOrString, data: any};
|
|
144
|
+
declare interface PageSystemSkeleton {
|
|
145
|
+
(template: string, options: any, req: Request, res: Response, next: (err: Error, data?: any) => void): void;
|
|
146
|
+
}
|
|
147
|
+
export type UserAgentDetails = Agent & Details & {es6?: boolean, legacy?: boolean};
|
|
148
|
+
declare interface BaseLocals<U extends User> {
|
|
149
|
+
/**
|
|
150
|
+
* The user, if any;
|
|
151
|
+
*/
|
|
152
|
+
user?: U;
|
|
153
|
+
/**
|
|
154
|
+
* Information about the seragent of the request.
|
|
155
|
+
* Provided by seragent.
|
|
156
|
+
*/
|
|
157
|
+
useragent?: UserAgentDetails;
|
|
158
|
+
/**
|
|
159
|
+
* Whether or not the client accepts webp.
|
|
160
|
+
*/
|
|
161
|
+
webp?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Either "webp" or "png" depending on the request.
|
|
164
|
+
*/
|
|
165
|
+
webpOrPng?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Either "webp" or "jpg" depending on the request.
|
|
168
|
+
*/
|
|
169
|
+
webpOrJpg?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Either "webp" or "gif" depending on the request.
|
|
172
|
+
*/
|
|
173
|
+
webpOrGif?: string;
|
|
174
|
+
/**
|
|
175
|
+
* The site url for the directory and domain nexusframework was requested from.
|
|
176
|
+
*/
|
|
177
|
+
siteUrl?: string;
|
|
178
|
+
/**
|
|
179
|
+
* The subdirectory nexusframework was requested from, if one.
|
|
180
|
+
*/
|
|
181
|
+
sitePrefix?: string;
|
|
182
|
+
}
|
|
183
|
+
declare interface Request<U extends User> extends BaseLocals<U>, nexusfork.WebRequest {
|
|
184
|
+
res: Response<ResponseLocals<U>>;
|
|
185
|
+
/**
|
|
186
|
+
* The NexusFramework instance.
|
|
187
|
+
*/
|
|
188
|
+
nexusframework?: NexusFramework;
|
|
189
|
+
/**
|
|
190
|
+
* The request handler mapping.
|
|
191
|
+
*/
|
|
192
|
+
mapping?: RequestHandlerMethodExtendedMapping;
|
|
193
|
+
/**
|
|
194
|
+
* An array of all the RegExp matches while processing the request.
|
|
195
|
+
*/
|
|
196
|
+
matches?: RegExpMatchArray[];
|
|
197
|
+
/**
|
|
198
|
+
* The current RegExp match while procesing the request.
|
|
199
|
+
*/
|
|
200
|
+
match?: RegExpMatchArray;
|
|
201
|
+
/**
|
|
202
|
+
* The current mount.
|
|
203
|
+
*/
|
|
204
|
+
mount?: RequestHandlerEntry;
|
|
205
|
+
/**
|
|
206
|
+
* True when requested through the Page System API.
|
|
207
|
+
*/
|
|
208
|
+
pagesys?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* The associated Socket.IO Socket, if requested through the page API and using Socket.IO.
|
|
211
|
+
*/
|
|
212
|
+
io?: SocketIO.Socket;
|
|
213
|
+
/**
|
|
214
|
+
* The API encoder being used for this request, if any.
|
|
215
|
+
*/
|
|
216
|
+
api?: ApiTypes;
|
|
217
|
+
/**
|
|
218
|
+
* True if this request is either .xhr or .io.
|
|
219
|
+
*/
|
|
220
|
+
xhrOrIO?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Contains an array of uploaded files.
|
|
223
|
+
* These files are destroyed automatically when the response ends.
|
|
224
|
+
*/
|
|
225
|
+
files?: {[index: string]: UploadedFile|UploadedFile[]};
|
|
226
|
+
/**
|
|
227
|
+
* Process the request body.
|
|
228
|
+
* By default all processors are usable, and the processor chosen is determined by the request content-type header.
|
|
229
|
+
*
|
|
230
|
+
* @param cb The callback
|
|
231
|
+
* @param processors The processors, all by default
|
|
232
|
+
*/
|
|
233
|
+
processBody?(cb: (err?: Error) => void, ...processors: BodyProcessor[]): Request;
|
|
234
|
+
/**
|
|
235
|
+
* Read the request body to a Buffer.
|
|
236
|
+
*/
|
|
237
|
+
readBody?(cb: (err: Error, data?: Buffer) => void, limit?: number): void;
|
|
238
|
+
/**
|
|
239
|
+
* The subdirectory nexusframework was requested from, if one.
|
|
240
|
+
*/
|
|
241
|
+
buildUrl?(uri?: string): string;
|
|
242
|
+
}
|
|
243
|
+
declare interface Renderer {
|
|
244
|
+
(out: {write: (data: string) => void},flush?:() => void): void
|
|
245
|
+
}
|
|
246
|
+
declare interface SocialTags {
|
|
247
|
+
/**
|
|
248
|
+
* The url of the page, will use the request to build this as a fallback when available
|
|
249
|
+
*/
|
|
250
|
+
url?: string | URL;
|
|
251
|
+
/**
|
|
252
|
+
* The title of the page, will use res.locals.title as a fallback when available
|
|
253
|
+
*/
|
|
254
|
+
title?: string;
|
|
255
|
+
/**
|
|
256
|
+
* The title of the site.
|
|
257
|
+
*/
|
|
258
|
+
siteTitle?: string;
|
|
259
|
+
/**
|
|
260
|
+
* The url to an image to display for this page.
|
|
261
|
+
*/
|
|
262
|
+
image?: string | URL;
|
|
263
|
+
/**
|
|
264
|
+
* The url to a relevant page.
|
|
265
|
+
*/
|
|
266
|
+
seeAlso?: string | URL;
|
|
267
|
+
/**
|
|
268
|
+
* The description of this page.
|
|
269
|
+
*/
|
|
270
|
+
description: string;
|
|
271
|
+
/**
|
|
272
|
+
* The type of twitter card, will use summary by default
|
|
273
|
+
*/
|
|
274
|
+
twitterCard?: string;
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
declare interface ResponseLocals<U extends User> extends BaseLocals<U> {
|
|
278
|
+
[key: string]: any;
|
|
279
|
+
}
|
|
280
|
+
declare interface Response<U extends User, L extends ResponseLocals<U>> extends nexusfork.WebResponse {
|
|
281
|
+
locals: L;
|
|
282
|
+
req: Request<U>;
|
|
283
|
+
renderoptions?: RenderOptions;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Render a page using a template engine and serve it.
|
|
287
|
+
* This method will use the skeleton if available, `render` will not.
|
|
288
|
+
*
|
|
289
|
+
* @param filename The absolute path to a file to render, or template source
|
|
290
|
+
* @param options The variables to use for rendering
|
|
291
|
+
*/
|
|
292
|
+
sendRender(filename: string, locals?: any): Response;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Replace the render options for this response.
|
|
296
|
+
*/
|
|
297
|
+
setRenderOptions(options: RenderOptions): void;
|
|
298
|
+
/**
|
|
299
|
+
* Override the render options for this response.
|
|
300
|
+
*/
|
|
301
|
+
applyRenderOptions(options: RenderOptions): void;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Enable the NexusFramework Loader to the script queue, and defer all scripts and styles,
|
|
305
|
+
* as well as display a configurable loading screen.
|
|
306
|
+
*/
|
|
307
|
+
enableLoader(): void;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Set a meta tag in the header html.
|
|
311
|
+
*/
|
|
312
|
+
setMetaTag(name: string, content?: string): void;
|
|
313
|
+
setSocialTags(info: SocialTags): void;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Add a style to the style queue.
|
|
317
|
+
*/
|
|
318
|
+
addStyle(url: string, integrity?: string, ...deps: string[]): void;
|
|
319
|
+
addInlineStyle(source: string, ...deps: string[]): void;
|
|
320
|
+
/**
|
|
321
|
+
* Add a font from Google's library, with the specified weight.
|
|
322
|
+
*
|
|
323
|
+
* @param family The font family
|
|
324
|
+
* @param weight The font weight, default 400
|
|
325
|
+
* @param italic Italic, default false
|
|
326
|
+
*/
|
|
327
|
+
addFont(family: string, weight?: number, italic?: boolean): void;
|
|
328
|
+
/**
|
|
329
|
+
* Add a renderer to the header.
|
|
330
|
+
*/
|
|
331
|
+
addHeaderRenderer(renderer: Renderer | string): void;
|
|
332
|
+
/**
|
|
333
|
+
* Push the script and style queue.
|
|
334
|
+
* Stores it for popping later.
|
|
335
|
+
*
|
|
336
|
+
* @param andClear And clear the queue
|
|
337
|
+
*/
|
|
338
|
+
pushResourceQueues(andClear?: boolean): void;
|
|
339
|
+
/**
|
|
340
|
+
* Pops a script and style queue.
|
|
341
|
+
*/
|
|
342
|
+
popResourceQueues(): void;
|
|
343
|
+
clearScripts(): void;
|
|
344
|
+
clearStyles(): void;
|
|
345
|
+
clearFonts(): void;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Add a name to the body's classes.
|
|
349
|
+
*/
|
|
350
|
+
addBodyClassName(name: string): void;
|
|
351
|
+
/**
|
|
352
|
+
* Remove a name to the body's classes.
|
|
353
|
+
*/
|
|
354
|
+
removeBodyClassName(name: string): void;
|
|
355
|
+
/**
|
|
356
|
+
* Add a renderer after the body.
|
|
357
|
+
*/
|
|
358
|
+
addAfterBodyRenderer(renderer: Renderer | string): void;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Add a renderer to the footer.
|
|
362
|
+
*/
|
|
363
|
+
addFooterRenderer(renderer: Renderer | string): void;
|
|
364
|
+
/**
|
|
365
|
+
* Add a script to the script queue.
|
|
366
|
+
*/
|
|
367
|
+
addScript(url: string, integrity?: string, ...deps: string[]): void;
|
|
368
|
+
addInlineScript(source: string, ...deps: string[]): void;
|
|
369
|
+
/**
|
|
370
|
+
* Add the Socket.IO Client to the script queue.
|
|
371
|
+
*/
|
|
372
|
+
addSocketIOClient(): void;
|
|
373
|
+
/**
|
|
374
|
+
* Add the NexusFramework Client to the script queue.
|
|
375
|
+
*
|
|
376
|
+
* @param includeSocketIO Whether or not to include and rely on Socket.IO, true by default
|
|
377
|
+
* @param autoEnablePageSystem Whether or not to enable the page system automatically, false by default
|
|
378
|
+
*/
|
|
379
|
+
addNexusFrameworkClient(includeSocketIO?: boolean, autoEnablePageSystem?: boolean): void;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Write the header html to the stream.
|
|
383
|
+
* Try to position this just before the ending </head> tag.
|
|
384
|
+
*/
|
|
385
|
+
writeHeaderHtml(out?: NodeJS.WritableStream): void;
|
|
386
|
+
/**
|
|
387
|
+
* Write the after body html to the stream.
|
|
388
|
+
* Try to position this just after the <body> tag.
|
|
389
|
+
*/
|
|
390
|
+
writeAfterBodyHtml(out?: NodeJS.WritableStream): void;
|
|
391
|
+
/**
|
|
392
|
+
* Write the footer html to the stream.
|
|
393
|
+
* Try to position this just before the ending </body> tag.
|
|
394
|
+
*/
|
|
395
|
+
sendFooterHtml(out?: NodeJS.WritableStream): void;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Retreive the data used by NexusFrameworkLoader.load().
|
|
399
|
+
*/
|
|
400
|
+
getLoaderData(): any;
|
|
401
|
+
}
|
|
402
|
+
declare interface RequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
403
|
+
(req: I, res: O, next: (err?: Error) => void): void;
|
|
404
|
+
}
|
|
405
|
+
declare interface NHPRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
406
|
+
(req: I, res: O, next: (err?: Error, renderLocals?: any) => void): void;
|
|
407
|
+
}
|
|
408
|
+
declare interface RequestHandlerMethodMapping {
|
|
409
|
+
use?: NHPRequestHandler<any, any>;
|
|
410
|
+
get?: NHPRequestHandler<any, any>;
|
|
411
|
+
put?: NHPRequestHandler<any, any>;
|
|
412
|
+
post?: NHPRequestHandler<any, any>;
|
|
413
|
+
head?: NHPRequestHandler<any, any>;
|
|
414
|
+
patch?: NHPRequestHandler<any, any>;
|
|
415
|
+
del?: NHPRequestHandler<any, any>;
|
|
416
|
+
}
|
|
417
|
+
declare interface RequestHandlerMethodExtendedMapping extends RequestHandlerMethodMapping {
|
|
418
|
+
exists?: ExistsRequestHandler<any, any>;
|
|
419
|
+
access?: AccessRequestHandler<any, any>;
|
|
420
|
+
}
|
|
421
|
+
declare interface MappedRequestHandler extends RequestHandler<any, any>, RequestHandlerMethodMapping {}
|
|
422
|
+
declare interface ExtendedMappedRequestHandler extends RequestHandler<any, any>, RequestHandlerMethodExtendedMapping {}
|
|
423
|
+
declare interface ExistsRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
424
|
+
(req: I, res: O, exists: (err?: Error) => void, doesntExist: () => void): void;
|
|
425
|
+
}
|
|
426
|
+
declare interface RouteRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
427
|
+
(req: I, res: O, next: (err?: Error, routedpath?: string) => void, skip: () => void): void;
|
|
428
|
+
}
|
|
429
|
+
declare interface AccessRequestHandler<I extends Request<User>, O extends Response<User>> {
|
|
430
|
+
(req: I, res: O, allowed: (err?: Error) => void, denied: () => void): void;
|
|
431
|
+
}
|
|
432
|
+
declare interface Handler<I extends Request<User>, O extends Response<User>> {
|
|
433
|
+
(req: I, res: O, next?: (err: Error) => void): void;
|
|
434
|
+
}
|
|
435
|
+
interface RecursivePath {
|
|
436
|
+
[0]: string;
|
|
437
|
+
[index: number]: RecursivePath | string;
|
|
438
|
+
}
|
|
439
|
+
interface RequestHandlerEntry {
|
|
440
|
+
readonly leaf?: boolean;
|
|
441
|
+
handle: RequestHandler;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Fetches children for this entry.
|
|
445
|
+
*/
|
|
446
|
+
children(): RequestHandlerChildEntry[];
|
|
447
|
+
/**
|
|
448
|
+
* Fetches the paths for children of this entry.
|
|
449
|
+
*/
|
|
450
|
+
childPaths(cb: (paths: string[]) => void, deep?: false): void;
|
|
451
|
+
/**
|
|
452
|
+
* Fetches the paths for children of this entry recursively.
|
|
453
|
+
*/
|
|
454
|
+
childPaths(cb: (paths: (RecursivePath | string)[]) => void, deep: true): void;
|
|
455
|
+
/**
|
|
456
|
+
* Fetches the child at path.
|
|
457
|
+
*
|
|
458
|
+
* @param path The path to search.
|
|
459
|
+
* @param createIfNotExists Whether or not to create the path if it doesn't exist.
|
|
460
|
+
*/
|
|
461
|
+
childAt(path: string, createIfNotExists?: boolean): RequestHandlerChildEntry;
|
|
462
|
+
/**
|
|
463
|
+
* Fetches the child at path.
|
|
464
|
+
*
|
|
465
|
+
* @param path The path.
|
|
466
|
+
* @param handler The handler to set.
|
|
467
|
+
* @param createIfNotExists Whether or not to create the path if it doesn't exist, true by default.
|
|
468
|
+
*/
|
|
469
|
+
setChild(path: string, handler: RequestHandlerChildEntry, createIfNotExists?: boolean): void;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Fetches the view filename.
|
|
473
|
+
*
|
|
474
|
+
* @param type The type of view to fetch, by default its "nhp".
|
|
475
|
+
*/
|
|
476
|
+
view(type?: string): string;
|
|
477
|
+
/**
|
|
478
|
+
* Set the view filename for type.
|
|
479
|
+
*
|
|
480
|
+
* @param filename The view filename
|
|
481
|
+
* @param type The type of view to set, by default its "nhp".
|
|
482
|
+
*/
|
|
483
|
+
setView(filename: string, type?: string): void;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Fetches the index handler for this entry.
|
|
487
|
+
*/
|
|
488
|
+
index(): RequestHandlerEntry;
|
|
489
|
+
/**
|
|
490
|
+
* Set the index handler for this entry.
|
|
491
|
+
*/
|
|
492
|
+
setIndex(index: RequestHandlerEntry): void;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Fetches the route resolver for this entry.
|
|
496
|
+
*/
|
|
497
|
+
routeHandler(): RouteRequestHandler;
|
|
498
|
+
/**
|
|
499
|
+
* Fetches the access handler for this entry.
|
|
500
|
+
*/
|
|
501
|
+
accessHandler(): AccessRequestHandler;
|
|
502
|
+
/**
|
|
503
|
+
* Fetches the existence handler for this entry.
|
|
504
|
+
*/
|
|
505
|
+
existsHandler(): ExistsRequestHandler;
|
|
506
|
+
/**
|
|
507
|
+
* Set the route resolver for this entry.
|
|
508
|
+
*/
|
|
509
|
+
setRouteHandler(index: RouteRequestHandler): void;
|
|
510
|
+
/**
|
|
511
|
+
* Set the access handler for this entry.
|
|
512
|
+
*/
|
|
513
|
+
setAccessHandler(index: AccessRequestHandler): void;
|
|
514
|
+
/**
|
|
515
|
+
* Set the existence handler for this entry.
|
|
516
|
+
*/
|
|
517
|
+
setExistsHandler(index: ExistsRequestHandler): void;
|
|
518
|
+
/**
|
|
519
|
+
* Destroy this entry and all children
|
|
520
|
+
*/
|
|
521
|
+
destroy(): void;
|
|
522
|
+
}
|
|
523
|
+
interface RequestHandlerChildEntry extends RequestHandlerEntry {
|
|
524
|
+
readonly pattern: RegExp;
|
|
525
|
+
readonly rawPattern: string;
|
|
526
|
+
}
|
|
527
|
+
type APIEncoder<U extends User, L extends ResponseLocals<U>> = (locals: L, req: Request<U>, res: Response<L>) => void;
|
|
528
|
+
declare interface Mount extends MountOptions {
|
|
529
|
+
/**
|
|
530
|
+
* The filesystem path.
|
|
531
|
+
*/
|
|
532
|
+
fspath: string;
|
|
533
|
+
/**
|
|
534
|
+
* The web path.
|
|
535
|
+
*/
|
|
536
|
+
webpath: string;
|
|
537
|
+
}
|
|
538
|
+
declare interface APIResponse {
|
|
539
|
+
code: number;
|
|
540
|
+
warnings?: string[];
|
|
541
|
+
error?: {
|
|
542
|
+
type: string,
|
|
543
|
+
message: string,
|
|
544
|
+
stack: string
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
[key: string]: any;
|
|
548
|
+
}
|
|
549
|
+
declare interface Config extends MountOptions {
|
|
550
|
+
/**
|
|
551
|
+
* The pages path, relative to the root path.
|
|
552
|
+
* Default "pages"
|
|
553
|
+
*/
|
|
554
|
+
pages?: string;
|
|
555
|
+
/**
|
|
556
|
+
* The URL prefix
|
|
557
|
+
* Default "/"
|
|
558
|
+
*/
|
|
559
|
+
prefix?: string;
|
|
560
|
+
/**
|
|
561
|
+
* When true, the loader will not be enabled for compatible browsers.
|
|
562
|
+
* The loader is required for the dynamic page system.
|
|
563
|
+
*/
|
|
564
|
+
noloader?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* When true, scripts will not be served on {{prefix}}/:scripts
|
|
567
|
+
*/
|
|
568
|
+
noscripts?: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* When true, about will not be served on {{prefix}}/:about
|
|
571
|
+
*/
|
|
572
|
+
noabout?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* When true, disables logging.
|
|
575
|
+
*/
|
|
576
|
+
nologging?: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* When true, no Socket.IO instance will be created on {{prefix}}/:io
|
|
579
|
+
*/
|
|
580
|
+
noio?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* When true, no API support will be installed
|
|
583
|
+
*/
|
|
584
|
+
noapi?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* When true, serves the socket.io library to guests too.
|
|
587
|
+
*/
|
|
588
|
+
guestio?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* When true, enables the page system over Socket.IO
|
|
591
|
+
*/
|
|
592
|
+
iopagesys?: boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Override the socket.io path
|
|
595
|
+
*/
|
|
596
|
+
iopath?: string;
|
|
597
|
+
/**
|
|
598
|
+
* When true, the page system will not be initialized
|
|
599
|
+
*/
|
|
600
|
+
nopagesys?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Any items in this array are disabled from the built-in API encoders
|
|
603
|
+
*/
|
|
604
|
+
apiblacklist?: ApiTypes[];
|
|
605
|
+
/**
|
|
606
|
+
* Any items in this array are filtered from the response of API calls
|
|
607
|
+
*/
|
|
608
|
+
apifilter?: string[];
|
|
609
|
+
mounts?: Mount[] | Mount;
|
|
610
|
+
modules?: string[] | string;
|
|
611
|
+
[key: string]: any;
|
|
612
|
+
}
|