@tinyhttp/app 2.3.0 → 2.3.1

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/dist/app.d.ts CHANGED
@@ -37,7 +37,7 @@ export declare class App<Req extends Request = Request, Res extends Response = R
37
37
  settings: AppSettings;
38
38
  engines: Record<string, TemplateEngine>;
39
39
  applyExtensions: (req: Request, res: Response, next: NextFunction) => void;
40
- attach: (req: Req, res: Res) => void;
40
+ attach: (req: Req, res: Res, next?: NextFunction) => void;
41
41
  cache: Record<string, unknown>;
42
42
  constructor(options?: AppConstructor<Req, Res>);
43
43
  /**
@@ -80,7 +80,7 @@ export declare class App<Req extends Request = Request, Res extends Response = R
80
80
  engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(ext: string, fn: TemplateEngine<RenderOptions>): this;
81
81
  /**
82
82
  * Render a template
83
- * @param file What to render
83
+ * @param name What to render
84
84
  * @param data data that is passed to a template
85
85
  * @param options Template engine options
86
86
  * @param cb Callback that consumes error and html
@@ -92,12 +92,13 @@ export declare class App<Req extends Request = Request, Res extends Response = R
92
92
  * Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
93
93
  * @param req Req object
94
94
  * @param res Res object
95
+ * @param next 'Next' function
95
96
  */
96
97
  handler<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(req: Req, res: Res, next?: NextFunction): void;
97
98
  /**
98
99
  * Creates HTTP server and dispatches middleware
99
100
  * @param port server listening port
100
- * @param Server callback after server starts listening
101
+ * @param cb callback to be invoked after server starts listening
101
102
  * @param host server listening host
102
103
  */
103
104
  listen(port?: number, cb?: () => void, host?: string): Server;
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,WAAW,CAAA;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,E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AAG,IAAI;IAkElD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAsBxB;;;;;OAKG;IACH,OAAO,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB,EACzE,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,CAAC,EAAE,YAAY,GAClB,IAAI;IAwGP;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;CAG9D"}
package/dist/index.js CHANGED
@@ -182,7 +182,8 @@ class App extends Router {
182
182
  ...options.settings
183
183
  };
184
184
  this.applyExtensions = options == null ? void 0 : options.applyExtensions;
185
- this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, void 0), req, res);
185
+ const boundHandler = this.handler.bind(this);
186
+ this.attach = (req, res, next) => setImmediate(boundHandler, req, res, next);
186
187
  this.cache = {};
187
188
  }
188
189
  /**
@@ -241,7 +242,7 @@ class App extends Router {
241
242
  }
242
243
  /**
243
244
  * Render a template
244
- * @param file What to render
245
+ * @param name What to render
245
246
  * @param data data that is passed to a template
246
247
  * @param options Template engine options
247
248
  * @param cb Callback that consumes error and html
@@ -355,6 +356,7 @@ class App extends Router {
355
356
  * Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
356
357
  * @param req Req object
357
358
  * @param res Res object
359
+ * @param next 'Next' function
358
360
  */
359
361
  handler(req, res, next) {
360
362
  const { xPoweredBy } = this.settings;
@@ -384,11 +386,13 @@ class App extends Router {
384
386
  path: "/"
385
387
  });
386
388
  }
387
- mw.push({
388
- handler: this.noMatchHandler,
389
- type: "mw",
390
- path: "/"
391
- });
389
+ if (this.parent == null) {
390
+ mw.push({
391
+ handler: this.noMatchHandler,
392
+ type: "mw",
393
+ path: "/"
394
+ });
395
+ }
392
396
  const handle = (mw2) => async (req2, res2, next2) => {
393
397
  var _a;
394
398
  const { path, handler, regex } = mw2;
@@ -419,14 +423,25 @@ class App extends Router {
419
423
  await applyHandler(handler)(req2, res2, next2);
420
424
  };
421
425
  let idx = 0;
422
- const loop = () => res.writableEnded || idx < mw.length && handle(mw[idx++])(req, res, next);
423
- next = next || ((err) => err ? this.onError(err, req, res) : loop());
426
+ const loop = () => void handle(mw[idx++])(req, res, next);
427
+ const parentNext = next;
428
+ next = (err) => {
429
+ if (err != null) {
430
+ return this.onError(err, req, res);
431
+ }
432
+ if (res.writableEnded) return;
433
+ if (idx >= mw.length) {
434
+ if (parentNext != null) parentNext();
435
+ return;
436
+ }
437
+ loop();
438
+ };
424
439
  loop();
425
440
  }
426
441
  /**
427
442
  * Creates HTTP server and dispatches middleware
428
443
  * @param port server listening port
429
- * @param Server callback after server starts listening
444
+ * @param cb callback to be invoked after server starts listening
430
445
  * @param host server listening host
431
446
  */
432
447
  listen(port, cb, host) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/request.ts","../src/response.ts","../src/extend.ts","../src/onError.ts","../src/view.ts","../src/app.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport type { ParsedUrlQuery } from 'node:querystring'\n\nimport { type Trust, all, compile, proxyaddr as proxyAddr } from '@tinyhttp/proxy-addr'\nimport type { Options, Ranges } from 'header-range-parser'\n\nimport type { Middleware } from '@tinyhttp/router'\nimport type { App } from './app.js'\n\nimport { isIP } from 'node:net'\nimport type { Socket } from 'node:net'\nimport type { TLSSocket } from 'node:tls'\nimport type { URLParams } from '@tinyhttp/req'\n\nexport { getURLParams } from '@tinyhttp/req'\n\nconst trustRemoteAddress = ({ socket }: Pick<Request, 'headers' | 'socket'>, trust: Trust): boolean => {\n const val = socket.remoteAddress\n if (typeof trust !== 'function') trust = compile(trust)\n return trust(val, 0)\n}\n\nexport const getProtocol = (req: Request, trust: Trust): Protocol => {\n const proto = `http${req.secure ? 's' : ''}`\n\n if (!trustRemoteAddress(req, trust)) return proto\n\n const header = (req.headers['X-Forwarded-Proto'] as string) || proto\n\n const index = header.indexOf(',')\n\n return index !== -1 ? header.substring(0, index).trim() : header.trim()\n}\n\nexport const getHostname = (req: Request, trust: Trust): string | undefined => {\n let host: string = req.get('X-Forwarded-Host') as string\n\n if (!host || !trustRemoteAddress(req, trust)) host = req.get('Host') as string\n\n if (!host) return\n\n // IPv6 literal support\n const index = host.indexOf(':', host[0] === '[' ? host.indexOf(']') + 1 : 0)\n\n return index !== -1 ? host.substring(0, index) : host\n}\n\nexport const getIP = (req: Pick<Request, 'headers' | 'connection' | 'socket'>, trust: Trust): string | undefined =>\n proxyAddr(req, trust).replace(/^.*:/, '') // striping the redundant prefix addeded by OS to IPv4 address\n\nexport const getIPs = (req: Pick<Request, 'headers' | 'connection' | 'socket'>, trust: Trust): string[] | undefined =>\n all(req, trust)\n\nexport const getSubdomains = (req: Request, trust: Trust, subdomainOffset = 2): string[] => {\n const hostname = getHostname(req, trust)\n\n if (!hostname) return []\n\n const subdomains = isIP(hostname) ? [hostname] : hostname.split('.').reverse()\n\n return subdomains.slice(subdomainOffset)\n}\n\nexport type Connection = IncomingMessage['socket'] & {\n encrypted: boolean\n}\n\nexport type Protocol = 'http' | 'https' | string\n\nexport type { URLParams }\n\ntype AcceptsReturns = string | boolean | string[]\n\nexport interface Request extends IncomingMessage {\n originalUrl: string\n path: string\n url: string\n query: ParsedUrlQuery\n params: URLParams\n connection: Connection\n socket: TLSSocket | Socket\n route?: Middleware\n protocol: Protocol\n secure: boolean\n xhr: boolean\n hostname?: string\n ip?: string\n ips?: string[]\n subdomains?: string[]\n get: (header: string) => string | string[] | undefined\n range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined\n accepts: (...types: string[]) => AcceptsReturns\n acceptsEncodings: (...encodings: string[]) => AcceptsReturns\n acceptsCharsets: (...charsets: string[]) => AcceptsReturns\n acceptsLanguages: (...languages: string[]) => AcceptsReturns\n is: (...types: string[]) => boolean\n cookies?: any\n signedCookies?: any\n secret?: string | string[]\n fresh?: boolean\n stale?: boolean\n body?: any\n app?: App\n}\n","import type { ServerResponse } from 'node:http'\nimport type { SerializeOptions } from '@tinyhttp/cookie'\nimport type { DownloadOptions, FormatProps, ReadStreamOptions } from '@tinyhttp/res'\nimport type { App } from './app.js'\nimport type { Request } from './request.js'\nimport type { AppRenderOptions, TemplateEngineOptions } from './types.js'\n\nexport const renderTemplate =\n <O extends TemplateEngineOptions = TemplateEngineOptions>(_req: Request, res: Response, app: App) =>\n (file: string, data?: Record<string, unknown>, options?: AppRenderOptions<O>): Response => {\n app.render(file, data ? { ...res.locals, ...data } : res.locals, options, (err: unknown, html: unknown) => {\n if (err) throw err\n res.send(html)\n })\n return res\n }\n\nexport interface Response<B = unknown> extends ServerResponse {\n header(field: string | Record<string, unknown>, val?: string | any[]): Response<B>\n set(field: string | Record<string, unknown>, val?: string | any[]): Response<B>\n get(field: string): string | number | string[]\n send(body: B): Response<B>\n sendFile(path: string, options?: ReadStreamOptions, cb?: (err?: unknown) => void): Response<B>\n json(body: B): Response<B>\n status(status: number): Response<B>\n sendStatus(statusCode: number): Response<B>\n cookie(\n name: string,\n value: string | Record<string, unknown>,\n options?: SerializeOptions & Partial<{ signed: boolean }>\n ): Response<B>\n clearCookie(name: string, options?: SerializeOptions): Response<B>\n location(url: string): Response<B>\n links(links: { [key: string]: string }): Response<B>\n render<O extends TemplateEngineOptions = TemplateEngineOptions>(\n file: string,\n data?: Record<string, any>,\n options?: AppRenderOptions<O>\n ): Response<B>\n vary(field: string): Response<B>\n format(obj: FormatProps): Response<B>\n redirect(url: string, status?: number): Response<B>\n type(type: string): Response<B>\n download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: unknown) => void): Response<B>\n attachment(filename?: string): Response<B>\n app?: App\n locals: Record<string, any>\n /**\n * Send JSON response with JSONP callback support.\n *\n * To enable this method, install the `@tinyhttp/jsonp` package and attach the method to `res.jsonp` property.\n *\n * @param obj Response object\n */\n jsonp(obj: any): Response<B>\n\n append(field: string, value: any): Response<B>\n}\n","import { compile } from '@tinyhttp/proxy-addr'\nimport {\n checkIfXMLHttpRequest,\n getAccepts,\n getAcceptsCharsets,\n getAcceptsEncodings,\n getAcceptsLanguages,\n getFreshOrStale,\n getQueryParams,\n getRangeFromHeader,\n getRequestHeader\n} from '@tinyhttp/req'\nimport {\n append,\n attachment,\n clearCookie,\n download,\n formatResponse,\n getResponseHeader,\n json,\n redirect,\n send,\n sendFile,\n sendStatus,\n setContentType,\n setCookie,\n setHeader,\n setLinksHeader,\n setLocationHeader,\n setVaryHeader,\n status\n} from '@tinyhttp/res'\nimport type { NextFunction } from '@tinyhttp/router'\nimport type { App } from './app.js'\nimport { type Request, getSubdomains } from './request.js'\nimport { getHostname, getIP, getIPs, getProtocol } from './request.js'\nimport type { Response } from './response.js'\nimport { renderTemplate } from './response.js'\nimport type { TemplateEngineOptions } from './types.js'\n\n/**\n * Extends Request and Response objects with custom properties and methods\n */\nexport const extendMiddleware =\n <EngineOptions extends TemplateEngineOptions = TemplateEngineOptions>(app: App) =>\n (req: Request, res: Response<EngineOptions>, next: NextFunction): void => {\n const { settings } = app\n\n res.get = getResponseHeader(res)\n req.get = getRequestHeader(req)\n\n if (settings?.bindAppToReqRes) {\n req.app = app\n res.app = app\n }\n\n let trust = settings?.['trust proxy']\n if (typeof trust !== 'function') {\n trust = compile(trust)\n settings['trust proxy'] = trust\n }\n\n if (settings?.networkExtensions) {\n req.protocol = getProtocol(req, trust)\n req.secure = req.protocol === 'https'\n req.hostname = getHostname(req, trust)\n req.subdomains = getSubdomains(req, trust, settings.subdomainOffset)\n req.ip = getIP(req, trust)\n req.ips = getIPs(req, trust)\n }\n\n req.query = getQueryParams(req.url)\n\n req.range = getRangeFromHeader(req)\n req.accepts = getAccepts(req)\n req.acceptsCharsets = getAcceptsCharsets(req)\n req.acceptsEncodings = getAcceptsEncodings(req)\n req.acceptsLanguages = getAcceptsLanguages(req)\n\n req.xhr = checkIfXMLHttpRequest(req)\n\n res.header = res.set = setHeader<Response>(res)\n res.send = send<Request, Response>(req, res)\n res.json = json<Response>(res)\n res.status = status<Response>(res)\n res.sendStatus = sendStatus<Request, Response>(req, res)\n res.sendFile = sendFile<Request, Response>(req, res)\n res.type = setContentType<Response>(res)\n res.location = setLocationHeader<Request, Response>(req, res)\n res.links = setLinksHeader<Response>(res)\n res.vary = setVaryHeader<Response>(res)\n res.cookie = setCookie<Request, Response>(req, res)\n res.clearCookie = clearCookie<Request, Response>(req, res)\n res.render = renderTemplate(req, res, app)\n res.format = formatResponse(req, res, next)\n res.redirect = redirect(req, res, next)\n res.attachment = attachment<Response>(res)\n res.download = download<Request, Response>(req, res)\n res.append = append<Response>(res)\n res.locals = res.locals || Object.create(null)\n\n Object.defineProperty(req, 'fresh', { get: getFreshOrStale.bind(null, req, res), configurable: true })\n req.stale = !req.fresh\n\n next()\n }\n","import { STATUS_CODES } from 'node:http'\nimport type { NextFunction } from '@tinyhttp/router'\nimport type { App } from './app.js'\nimport type { Request } from './request.js'\nimport type { Response } from './response.js'\n\nexport type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void\n\nexport const onErrorHandler: ErrorHandler = function (this: App, err: any, _req: Request, res: Response) {\n if (this.onError === onErrorHandler && this.parent) return this.parent.onError(err, _req, res)\n\n if (err instanceof Error) console.error(err)\n\n const code = err.code in STATUS_CODES ? err.code : err.status\n\n if (typeof err === 'string' || Buffer.isBuffer(err)) res.writeHead(500).end(err)\n else if (code in STATUS_CODES) res.writeHead(code).end(STATUS_CODES[code])\n else res.writeHead(500).end(err.message)\n}\n","/*!\n * Ported from https://github.com/expressjs/express/blob/master/lib/view.js\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nimport { statSync } from 'node:fs'\nimport { basename, dirname, extname, join, resolve } from 'node:path'\nimport type { TemplateEngine, TemplateEngineOptions } from './types.js'\n\nfunction tryStat(path: string) {\n try {\n return statSync(path)\n } catch (e) {\n return undefined\n }\n}\n\n/**\n * Initialize a new `View` with the given `name`.\n *\n * Options:\n *\n * - `defaultEngine` the default template engine name\n * - `engines` template engine require() cache\n * - `root` root path for view lookup\n *\n * @param name\n * @param options\n * @public\n */\n\nexport class View<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions> {\n ext: string\n defaultEngine: string\n name: string\n engine: TemplateEngine<RenderOptions>\n path: string\n root: string | string[]\n constructor(\n name: string,\n opts: Partial<{\n defaultEngine: string\n root: string | string[]\n engines: Record<string, TemplateEngine<RenderOptions>>\n }> = {}\n ) {\n this.ext = extname(name)\n this.name = name\n this.root = opts.root\n this.defaultEngine = opts.defaultEngine\n\n if (!this.ext && !this.defaultEngine)\n throw new Error('No default engine was specified and no extension was provided.')\n\n let fileName = name\n\n if (!this.ext) {\n // get extension from default engine name\n this.ext = this.defaultEngine[0] !== '.' ? `.${this.defaultEngine}` : this.defaultEngine\n\n fileName += this.ext\n }\n\n if (!opts.engines[this.ext]) throw new Error(`No engine was found for ${this.ext}`)\n\n this.engine = opts.engines[this.ext]\n this.path = this.#lookup(fileName)\n }\n #lookup(name: string) {\n let path: string\n const roots = [].concat(this.root)\n\n for (let i = 0; i < roots.length && !path; i++) {\n const root = roots[i]\n // resolve the path\n const loc = resolve(root, name)\n const dir = dirname(loc)\n const file = basename(loc)\n\n // resolve the file\n path = this.#resolve(dir, file)\n }\n\n return path\n }\n #resolve(dir: string, file: string) {\n const ext = this.ext\n\n // <path>.<ext>\n let path = join(dir, file)\n let stat = tryStat(path)\n\n if (stat?.isFile()) {\n return path\n }\n\n // <path>/index.<ext>\n path = join(dir, basename(file, ext), `index${ext}`)\n stat = tryStat(path)\n\n if (stat?.isFile()) {\n return path\n }\n }\n render(options: RenderOptions, data: Record<string, unknown>, cb: (err: Error | null, html: unknown) => void) {\n this.engine(this.path, data, options, cb)\n }\n}\n","import { type Server, createServer } from 'node:http'\nimport { getPathname } from '@tinyhttp/req'\nimport type { Handler, Middleware, NextFunction, UseMethodParams } from '@tinyhttp/router'\nimport { Router, pushMiddleware } from '@tinyhttp/router'\nimport { parse as rg } from 'regexparam'\nimport { extendMiddleware } from './extend.js'\nimport type { TemplateEngineOptions } from './index.js'\nimport type { ErrorHandler } from './onError.js'\nimport { onErrorHandler } from './onError.js'\nimport { getURLParams } from './request.js'\nimport type { Request, URLParams } from './request.js'\nimport type { Response } from './response.js'\nimport type { AppConstructor, AppRenderOptions, AppSettings, TemplateEngine } from './types.js'\nimport { View } from './view.js'\n\n/**\n * Add leading slash if not present (e.g. path -> /path, /path -> /path)\n * @param x\n */\nconst lead = (x: string) => (x.charCodeAt(0) === 47 ? x : `/${x}`)\n\nconst mount = (fn: App | Handler) => (fn instanceof App ? fn.attach : fn)\n\nconst applyHandler =\n <Req, Res>(h: Handler<Req, Res>) =>\n async (req: Req, res: Res, next?: NextFunction) => {\n try {\n if (h[Symbol.toStringTag] === 'AsyncFunction') {\n await h(req, res, next)\n } else h(req, res, next)\n } catch (e) {\n next(e)\n }\n }\n\n/**\n * `App` class - the starting point of tinyhttp app.\n *\n * With the `App` you can:\n * * use routing methods and `.use(...)`\n * * set no match (404) and error (500) handlers\n * * configure template engines\n * * store data in locals\n * * listen the http server on a specified port\n *\n * In case you use TypeScript, you can pass custom types to this class because it is also a generic class.\n *\n * Example:\n *\n * ```ts\n * interface CoolReq extends Request {\n * genericsAreDope: boolean\n * }\n *\n * const app = App<any, CoolReq, Response>()\n * ```\n */\nexport class App<Req extends Request = Request, Res extends Response = Response> extends Router<App, Req, Res> {\n middleware: Middleware<Req, Res>[] = []\n locals: Record<string, unknown> = {}\n noMatchHandler: Handler\n onError: ErrorHandler\n settings: AppSettings\n engines: Record<string, TemplateEngine> = {}\n applyExtensions: (req: Request, res: Response, next: NextFunction) => void\n attach: (req: Req, res: Res) => void\n cache: Record<string, unknown>\n\n constructor(options: AppConstructor<Req, Res> = {}) {\n super()\n this.onError = options?.onError || onErrorHandler\n this.noMatchHandler = options?.noMatchHandler || this.onError.bind(this, { code: 404 })\n this.settings = {\n view: View,\n xPoweredBy: true,\n views: `${process.cwd()}/views`,\n 'view cache': process.env.NODE_ENV === 'production',\n 'trust proxy': 0,\n ...options.settings\n }\n this.applyExtensions = options?.applyExtensions\n this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, undefined), req, res)\n this.cache = {}\n }\n\n /**\n * Set app setting\n * @param setting setting name\n * @param value setting value\n */\n set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): this {\n this.settings[setting] = value\n\n return this\n }\n\n /**\n * Enable app setting\n * @param setting Setting name\n */\n enable<K extends keyof AppSettings>(setting: K): this {\n this.settings[setting] = true as AppSettings[K]\n\n return this\n }\n\n /**\n * Check if setting is enabled\n * @param setting Setting name\n * @returns\n */\n enabled<K extends keyof AppSettings>(setting: K): boolean {\n return Boolean(this.settings[setting])\n }\n\n /**\n * Disable app setting\n * @param setting Setting name\n */\n disable<K extends keyof AppSettings>(setting: K): this {\n this.settings[setting] = false as AppSettings[K]\n\n return this\n }\n\n /**\n * Return the app's absolute pathname\n * based on the parent(s) that have\n * mounted it.\n *\n * For example if the application was\n * mounted as `\"/admin\"`, which itself\n * was mounted as `\"/blog\"` then the\n * return value would be `\"/blog/admin\"`.\n *\n */\n path(): string {\n return this.parent ? this.parent.path() + this.mountpath : ''\n }\n\n /**\n * Register a template engine with extension\n */\n engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n ext: string,\n fn: TemplateEngine<RenderOptions>\n ): this {\n this.engines[ext[0] === '.' ? ext : `.${ext}`] = fn\n\n return this\n }\n\n /**\n * Render a template\n * @param file What to render\n * @param data data that is passed to a template\n * @param options Template engine options\n * @param cb Callback that consumes error and html\n */\n render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n name: string,\n data: Record<string, unknown> = {},\n options: AppRenderOptions<RenderOptions> = {} as AppRenderOptions<RenderOptions>,\n cb: (err: unknown, html?: unknown) => void = () => {}\n ): void {\n let view: View | undefined\n\n const { _locals, ...opts } = options\n\n let locals = this.locals\n\n if (_locals) locals = { ...locals, ..._locals }\n\n locals = { ...locals, ...data }\n\n if (opts.cache == null) (opts.cache as boolean) = this.enabled('view cache')\n\n if (opts.cache) {\n view = this.cache[name] as View\n }\n\n if (!view) {\n const View = this.settings.view\n view = new View(name, {\n defaultEngine: this.settings['view engine'],\n root: this.settings.views,\n engines: this.engines\n })\n\n if (!view.path) {\n const dirs =\n Array.isArray(view.root) && view.root.length > 1\n ? `directories \"${view.root.slice(0, -1).join('\", \"')}\" or \"${view.root[view.root.length - 1]}\"`\n : `directory \"${view.root}\"`\n const err = new Error(`Failed to lookup view \"${name}\" in views ${dirs}`)\n\n return cb(err)\n }\n\n if (opts.cache) {\n this.cache[name] = view\n }\n }\n\n try {\n view.render(opts, locals, cb)\n } catch (err) {\n cb(err)\n }\n }\n use(...args: UseMethodParams<Req, Res, App>): this {\n const base = args[0]\n\n const fns = args.slice(1).flat()\n\n let pathArray = []\n if (typeof base === 'function' || base instanceof App) {\n fns.unshift(base)\n } else {\n // if base is not an array of paths, then convert it to an array.\n let basePaths = []\n if (Array.isArray(base)) basePaths = [...base]\n else if (typeof base === 'string') basePaths = [base]\n\n basePaths = basePaths.filter((element) => {\n if (typeof element === 'string') {\n pathArray.push(element)\n return false\n }\n return true\n })\n fns.unshift(...basePaths)\n }\n pathArray = pathArray.length ? pathArray.map((path) => lead(path)) : ['/']\n\n const mountpath = pathArray.join(', ')\n let regex: { keys: string[]; pattern: RegExp }\n\n for (const fn of fns) {\n if (fn instanceof App) {\n for (const path of pathArray) {\n regex = rg(path, true)\n fn.mountpath = mountpath\n this.apps[path] = fn\n fn.parent = this\n }\n }\n }\n for (const path of pathArray) {\n const handlerPaths = []\n const handlerFunctions = []\n const handlerPathBase = path === '/' ? '' : lead(path)\n for (const fn of fns) {\n if (fn instanceof App && fn.middleware?.length) {\n for (const mw of fn.middleware) {\n handlerPaths.push(handlerPathBase + lead(mw.path))\n handlerFunctions.push(fn)\n }\n } else {\n handlerPaths.push('')\n handlerFunctions.push(fn)\n }\n }\n pushMiddleware(this.middleware)({\n path,\n regex,\n type: 'mw',\n handler: mount(handlerFunctions[0] as Handler),\n handlers: handlerFunctions.slice(1).map(mount),\n fullPaths: handlerPaths\n })\n }\n\n return this\n }\n\n route(path: string): App {\n const app = new App({ settings: this.settings })\n\n this.use(path, app)\n\n return app\n }\n\n #find(url: string): Middleware<Req, Res>[] {\n return this.middleware.filter((m) => {\n m.regex = m.regex || rg(m.path, m.type === 'mw')\n\n let fullPathRegex: { keys: string[]; pattern: RegExp }\n\n m.fullPath && typeof m.fullPath === 'string'\n ? (fullPathRegex = rg(m.fullPath, m.type === 'mw'))\n : (fullPathRegex = null)\n\n return m.regex.pattern.test(url) && (m.type === 'mw' && fullPathRegex ? fullPathRegex.pattern.test(url) : true)\n })\n }\n\n /**\n * Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware\n * @param req Req object\n * @param res Res object\n */\n handler<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n req: Req,\n res: Res,\n next?: NextFunction\n ): void {\n /* Set X-Powered-By header */\n const { xPoweredBy } = this.settings\n if (xPoweredBy) res.setHeader('X-Powered-By', typeof xPoweredBy === 'string' ? xPoweredBy : 'tinyhttp')\n\n const exts = this.applyExtensions || extendMiddleware<RenderOptions>(this)\n\n req.originalUrl = req.url || req.originalUrl\n\n const pathname = getPathname(req.originalUrl)\n\n const matched = this.#find(pathname)\n\n const mw: Middleware[] = [\n {\n handler: exts,\n type: 'mw',\n path: '/'\n },\n ...matched.filter((x) => req.method === 'HEAD' || (x.method ? x.method === req.method : true))\n ]\n\n if (matched[0] != null) {\n mw.push({\n type: 'mw',\n handler: (req, res, next) => {\n if (req.method === 'HEAD') {\n res.statusCode = 204\n return res.end('')\n }\n next()\n },\n path: '/'\n })\n }\n\n mw.push({\n handler: this.noMatchHandler,\n type: 'mw',\n path: '/'\n })\n\n const handle = (mw: Middleware) => async (req: Req, res: Res, next?: NextFunction) => {\n const { path, handler, regex } = mw\n\n let params: URLParams\n\n try {\n params = regex ? getURLParams(regex, pathname) : {}\n } catch (e) {\n console.error(e)\n if (e instanceof URIError) return res.sendStatus(400)\n throw e\n }\n\n // Warning: users should not use :wild as a pattern\n let prefix = path\n if (regex) {\n for (const key of regex.keys as string[]) {\n if (key === 'wild') {\n prefix = prefix.replace('*', params.wild)\n } else {\n prefix = prefix.replace(`:${key}`, params[key])\n }\n }\n }\n\n req.params = { ...req.params, ...params }\n\n if (mw.type === 'mw') {\n req.url = lead(req.originalUrl.substring(prefix.length))\n }\n\n if (!req.path) req.path = getPathname(req.url)\n\n if (this.settings?.enableReqRoute) req.route = mw\n\n await applyHandler<Req, Res>(handler as unknown as Handler<Req, Res>)(req, res, next)\n }\n\n let idx = 0\n\n const loop = () => res.writableEnded || (idx < mw.length && handle(mw[idx++])(req, res, next))\n\n next = next || ((err) => (err ? this.onError(err, req, res) : loop()))\n\n loop()\n }\n\n /**\n * Creates HTTP server and dispatches middleware\n * @param port server listening port\n * @param Server callback after server starts listening\n * @param host server listening host\n */\n listen(port?: number, cb?: () => void, host?: string): Server {\n return createServer().on('request', this.attach).listen(port, host, cb)\n }\n}\n"],"names":["proxyAddr","View","rg","req","res","next","mw"],"mappings":";;;;;;;;;;AAgBA,MAAM,qBAAqB,CAAC,EAAE,UAA+C,UAA0B;AACrG,QAAM,MAAM,OAAO;AACnB,MAAI,OAAO,UAAU,WAAY,SAAQ,QAAQ,KAAK;AAC/C,SAAA,MAAM,KAAK,CAAC;AACrB;AAEa,MAAA,cAAc,CAAC,KAAc,UAA2B;AACnE,QAAM,QAAQ,OAAO,IAAI,SAAS,MAAM,EAAE;AAE1C,MAAI,CAAC,mBAAmB,KAAK,KAAK,EAAU,QAAA;AAE5C,QAAM,SAAU,IAAI,QAAQ,mBAAmB,KAAgB;AAEzD,QAAA,QAAQ,OAAO,QAAQ,GAAG;AAEzB,SAAA,UAAU,KAAK,OAAO,U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UAAAA,IAAG,SAAS,MAAM;AACpBH,aAAI,MAAM,KAAKA,KAAI,YAAY,UAAU,OAAO,MAAM,CAAC;AAAA,MACzD;AAEI,UAAA,CAACA,KAAI,KAAMA,MAAI,OAAO,YAAYA,KAAI,GAAG;AAE7C,WAAI,UAAK,aAAL,mBAAe,eAAgBA,MAAI,QAAQG;AAE/C,YAAM,aAAuB,OAAuC,EAAEH,MAAKC,MAAKC,KAAI;AAAA,IAAA;AAGtF,QAAI,MAAM;AAEV,UAAM,OAAO,MAAM,IAAI,iBAAkB,MAAM,GAAG,UAAU,OAAO,GAAG,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI;AAErF,WAAA,SAAS,CAAC,QAAS,MAAM,KAAK,QAAQ,KAAK,KAAK,GAAG,IAAI,KAAK;AAE9D;EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,MAAe,IAAiB,MAAuB;AACrD,WAAA,aAAe,EAAA,GAAG,WAAW,KAAK,MAAM,EAAE,OAAO,MAAM,MAAM,EAAE;AAAA,EACxE;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/request.ts","../src/response.ts","../src/extend.ts","../src/onError.ts","../src/view.ts","../src/app.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport type { ParsedUrlQuery } from 'node:querystring'\n\nimport { type Trust, all, compile, proxyaddr as proxyAddr } from '@tinyhttp/proxy-addr'\nimport type { Options, Ranges } from 'header-range-parser'\n\nimport type { Middleware } from '@tinyhttp/router'\nimport type { App } from './app.js'\n\nimport { isIP } from 'node:net'\nimport type { Socket } from 'node:net'\nimport type { TLSSocket } from 'node:tls'\nimport type { URLParams } from '@tinyhttp/req'\n\nexport { getURLParams } from '@tinyhttp/req'\n\nconst trustRemoteAddress = ({ socket }: Pick<Request, 'headers' | 'socket'>, trust: Trust): boolean => {\n const val = socket.remoteAddress\n if (typeof trust !== 'function') trust = compile(trust)\n return trust(val, 0)\n}\n\nexport const getProtocol = (req: Request, trust: Trust): Protocol => {\n const proto = `http${req.secure ? 's' : ''}`\n\n if (!trustRemoteAddress(req, trust)) return proto\n\n const header = (req.headers['X-Forwarded-Proto'] as string) || proto\n\n const index = header.indexOf(',')\n\n return index !== -1 ? header.substring(0, index).trim() : header.trim()\n}\n\nexport const getHostname = (req: Request, trust: Trust): string | undefined => {\n let host: string = req.get('X-Forwarded-Host') as string\n\n if (!host || !trustRemoteAddress(req, trust)) host = req.get('Host') as string\n\n if (!host) return\n\n // IPv6 literal support\n const index = host.indexOf(':', host[0] === '[' ? host.indexOf(']') + 1 : 0)\n\n return index !== -1 ? host.substring(0, index) : host\n}\n\nexport const getIP = (req: Pick<Request, 'headers' | 'connection' | 'socket'>, trust: Trust): string | undefined =>\n proxyAddr(req, trust).replace(/^.*:/, '') // striping the redundant prefix addeded by OS to IPv4 address\n\nexport const getIPs = (req: Pick<Request, 'headers' | 'connection' | 'socket'>, trust: Trust): string[] | undefined =>\n all(req, trust)\n\nexport const getSubdomains = (req: Request, trust: Trust, subdomainOffset = 2): string[] => {\n const hostname = getHostname(req, trust)\n\n if (!hostname) return []\n\n const subdomains = isIP(hostname) ? [hostname] : hostname.split('.').reverse()\n\n return subdomains.slice(subdomainOffset)\n}\n\nexport type Connection = IncomingMessage['socket'] & {\n encrypted: boolean\n}\n\nexport type Protocol = 'http' | 'https' | string\n\nexport type { URLParams }\n\ntype AcceptsReturns = string | boolean | string[]\n\nexport interface Request extends IncomingMessage {\n originalUrl: string\n path: string\n url: string\n query: ParsedUrlQuery\n params: URLParams\n connection: Connection\n socket: TLSSocket | Socket\n route?: Middleware\n protocol: Protocol\n secure: boolean\n xhr: boolean\n hostname?: string\n ip?: string\n ips?: string[]\n subdomains?: string[]\n get: (header: string) => string | string[] | undefined\n range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined\n accepts: (...types: string[]) => AcceptsReturns\n acceptsEncodings: (...encodings: string[]) => AcceptsReturns\n acceptsCharsets: (...charsets: string[]) => AcceptsReturns\n acceptsLanguages: (...languages: string[]) => AcceptsReturns\n is: (...types: string[]) => boolean\n cookies?: any\n signedCookies?: any\n secret?: string | string[]\n fresh?: boolean\n stale?: boolean\n body?: any\n app?: App\n}\n","import type { ServerResponse } from 'node:http'\nimport type { SerializeOptions } from '@tinyhttp/cookie'\nimport type { DownloadOptions, FormatProps, ReadStreamOptions } from '@tinyhttp/res'\nimport type { App } from './app.js'\nimport type { Request } from './request.js'\nimport type { AppRenderOptions, TemplateEngineOptions } from './types.js'\n\nexport const renderTemplate =\n <O extends TemplateEngineOptions = TemplateEngineOptions>(_req: Request, res: Response, app: App) =>\n (file: string, data?: Record<string, unknown>, options?: AppRenderOptions<O>): Response => {\n app.render(file, data ? { ...res.locals, ...data } : res.locals, options, (err: unknown, html: unknown) => {\n if (err) throw err\n res.send(html)\n })\n return res\n }\n\nexport interface Response<B = unknown> extends ServerResponse {\n header(field: string | Record<string, unknown>, val?: string | any[]): Response<B>\n set(field: string | Record<string, unknown>, val?: string | any[]): Response<B>\n get(field: string): string | number | string[]\n send(body: B): Response<B>\n sendFile(path: string, options?: ReadStreamOptions, cb?: (err?: unknown) => void): Response<B>\n json(body: B): Response<B>\n status(status: number): Response<B>\n sendStatus(statusCode: number): Response<B>\n cookie(\n name: string,\n value: string | Record<string, unknown>,\n options?: SerializeOptions & Partial<{ signed: boolean }>\n ): Response<B>\n clearCookie(name: string, options?: SerializeOptions): Response<B>\n location(url: string): Response<B>\n links(links: { [key: string]: string }): Response<B>\n render<O extends TemplateEngineOptions = TemplateEngineOptions>(\n file: string,\n data?: Record<string, any>,\n options?: AppRenderOptions<O>\n ): Response<B>\n vary(field: string): Response<B>\n format(obj: FormatProps): Response<B>\n redirect(url: string, status?: number): Response<B>\n type(type: string): Response<B>\n download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: unknown) => void): Response<B>\n attachment(filename?: string): Response<B>\n app?: App\n locals: Record<string, any>\n /**\n * Send JSON response with JSONP callback support.\n *\n * To enable this method, install the `@tinyhttp/jsonp` package and attach the method to `res.jsonp` property.\n *\n * @param obj Response object\n */\n jsonp(obj: any): Response<B>\n\n append(field: string, value: any): Response<B>\n}\n","import { compile } from '@tinyhttp/proxy-addr'\nimport {\n checkIfXMLHttpRequest,\n getAccepts,\n getAcceptsCharsets,\n getAcceptsEncodings,\n getAcceptsLanguages,\n getFreshOrStale,\n getQueryParams,\n getRangeFromHeader,\n getRequestHeader\n} from '@tinyhttp/req'\nimport {\n append,\n attachment,\n clearCookie,\n download,\n formatResponse,\n getResponseHeader,\n json,\n redirect,\n send,\n sendFile,\n sendStatus,\n setContentType,\n setCookie,\n setHeader,\n setLinksHeader,\n setLocationHeader,\n setVaryHeader,\n status\n} from '@tinyhttp/res'\nimport type { NextFunction } from '@tinyhttp/router'\nimport type { App } from './app.js'\nimport { type Request, getSubdomains } from './request.js'\nimport { getHostname, getIP, getIPs, getProtocol } from './request.js'\nimport type { Response } from './response.js'\nimport { renderTemplate } from './response.js'\nimport type { TemplateEngineOptions } from './types.js'\n\n/**\n * Extends Request and Response objects with custom properties and methods\n */\nexport const extendMiddleware =\n <EngineOptions extends TemplateEngineOptions = TemplateEngineOptions>(app: App) =>\n (req: Request, res: Response<EngineOptions>, next: NextFunction): void => {\n const { settings } = app\n\n res.get = getResponseHeader(res)\n req.get = getRequestHeader(req)\n\n if (settings?.bindAppToReqRes) {\n req.app = app\n res.app = app\n }\n\n let trust = settings?.['trust proxy']\n if (typeof trust !== 'function') {\n trust = compile(trust)\n settings['trust proxy'] = trust\n }\n\n if (settings?.networkExtensions) {\n req.protocol = getProtocol(req, trust)\n req.secure = req.protocol === 'https'\n req.hostname = getHostname(req, trust)\n req.subdomains = getSubdomains(req, trust, settings.subdomainOffset)\n req.ip = getIP(req, trust)\n req.ips = getIPs(req, trust)\n }\n\n req.query = getQueryParams(req.url)\n\n req.range = getRangeFromHeader(req)\n req.accepts = getAccepts(req)\n req.acceptsCharsets = getAcceptsCharsets(req)\n req.acceptsEncodings = getAcceptsEncodings(req)\n req.acceptsLanguages = getAcceptsLanguages(req)\n\n req.xhr = checkIfXMLHttpRequest(req)\n\n res.header = res.set = setHeader<Response>(res)\n res.send = send<Request, Response>(req, res)\n res.json = json<Response>(res)\n res.status = status<Response>(res)\n res.sendStatus = sendStatus<Request, Response>(req, res)\n res.sendFile = sendFile<Request, Response>(req, res)\n res.type = setContentType<Response>(res)\n res.location = setLocationHeader<Request, Response>(req, res)\n res.links = setLinksHeader<Response>(res)\n res.vary = setVaryHeader<Response>(res)\n res.cookie = setCookie<Request, Response>(req, res)\n res.clearCookie = clearCookie<Request, Response>(req, res)\n res.render = renderTemplate(req, res, app)\n res.format = formatResponse(req, res, next)\n res.redirect = redirect(req, res, next)\n res.attachment = attachment<Response>(res)\n res.download = download<Request, Response>(req, res)\n res.append = append<Response>(res)\n res.locals = res.locals || Object.create(null)\n\n Object.defineProperty(req, 'fresh', { get: getFreshOrStale.bind(null, req, res), configurable: true })\n req.stale = !req.fresh\n\n next()\n }\n","import { STATUS_CODES } from 'node:http'\nimport type { NextFunction } from '@tinyhttp/router'\nimport type { App } from './app.js'\nimport type { Request } from './request.js'\nimport type { Response } from './response.js'\n\nexport type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void\n\nexport const onErrorHandler: ErrorHandler = function (this: App, err: any, _req: Request, res: Response) {\n if (this.onError === onErrorHandler && this.parent) return this.parent.onError(err, _req, res)\n\n if (err instanceof Error) console.error(err)\n\n const code = err.code in STATUS_CODES ? err.code : err.status\n\n if (typeof err === 'string' || Buffer.isBuffer(err)) res.writeHead(500).end(err)\n else if (code in STATUS_CODES) res.writeHead(code).end(STATUS_CODES[code])\n else res.writeHead(500).end(err.message)\n}\n","/*!\n * Ported from https://github.com/expressjs/express/blob/master/lib/view.js\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nimport { statSync } from 'node:fs'\nimport { basename, dirname, extname, join, resolve } from 'node:path'\nimport type { TemplateEngine, TemplateEngineOptions } from './types.js'\n\nfunction tryStat(path: string) {\n try {\n return statSync(path)\n } catch (e) {\n return undefined\n }\n}\n\n/**\n * Initialize a new `View` with the given `name`.\n *\n * Options:\n *\n * - `defaultEngine` the default template engine name\n * - `engines` template engine require() cache\n * - `root` root path for view lookup\n *\n * @param name\n * @param options\n * @public\n */\n\nexport class View<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions> {\n ext: string\n defaultEngine: string\n name: string\n engine: TemplateEngine<RenderOptions>\n path: string\n root: string | string[]\n constructor(\n name: string,\n opts: Partial<{\n defaultEngine: string\n root: string | string[]\n engines: Record<string, TemplateEngine<RenderOptions>>\n }> = {}\n ) {\n this.ext = extname(name)\n this.name = name\n this.root = opts.root\n this.defaultEngine = opts.defaultEngine\n\n if (!this.ext && !this.defaultEngine)\n throw new Error('No default engine was specified and no extension was provided.')\n\n let fileName = name\n\n if (!this.ext) {\n // get extension from default engine name\n this.ext = this.defaultEngine[0] !== '.' ? `.${this.defaultEngine}` : this.defaultEngine\n\n fileName += this.ext\n }\n\n if (!opts.engines[this.ext]) throw new Error(`No engine was found for ${this.ext}`)\n\n this.engine = opts.engines[this.ext]\n this.path = this.#lookup(fileName)\n }\n #lookup(name: string) {\n let path: string\n const roots = [].concat(this.root)\n\n for (let i = 0; i < roots.length && !path; i++) {\n const root = roots[i]\n // resolve the path\n const loc = resolve(root, name)\n const dir = dirname(loc)\n const file = basename(loc)\n\n // resolve the file\n path = this.#resolve(dir, file)\n }\n\n return path\n }\n #resolve(dir: string, file: string) {\n const ext = this.ext\n\n // <path>.<ext>\n let path = join(dir, file)\n let stat = tryStat(path)\n\n if (stat?.isFile()) {\n return path\n }\n\n // <path>/index.<ext>\n path = join(dir, basename(file, ext), `index${ext}`)\n stat = tryStat(path)\n\n if (stat?.isFile()) {\n return path\n }\n }\n render(options: RenderOptions, data: Record<string, unknown>, cb: (err: Error | null, html: unknown) => void) {\n this.engine(this.path, data, options, cb)\n }\n}\n","import { type Server, createServer } from 'node:http'\nimport { getPathname } from '@tinyhttp/req'\nimport type { Handler, Middleware, NextFunction, UseMethodParams } from '@tinyhttp/router'\nimport { Router, pushMiddleware } from '@tinyhttp/router'\nimport { parse as rg } from 'regexparam'\nimport { extendMiddleware } from './extend.js'\nimport type { TemplateEngineOptions } from './index.js'\nimport type { ErrorHandler } from './onError.js'\nimport { onErrorHandler } from './onError.js'\nimport { getURLParams } from './request.js'\nimport type { Request, URLParams } from './request.js'\nimport type { Response } from './response.js'\nimport type { AppConstructor, AppRenderOptions, AppSettings, TemplateEngine } from './types.js'\nimport { View } from './view.js'\n\n/**\n * Add leading slash if not present (e.g. path -> /path, /path -> /path)\n * @param x\n */\nconst lead = (x: string) => (x.charCodeAt(0) === 47 ? x : `/${x}`)\n\nconst mount = (fn: App | Handler) => (fn instanceof App ? fn.attach : fn)\n\nconst applyHandler =\n <Req, Res>(h: Handler<Req, Res>) =>\n async (req: Req, res: Res, next?: NextFunction) => {\n try {\n if (h[Symbol.toStringTag] === 'AsyncFunction') {\n await h(req, res, next)\n } else h(req, res, next)\n } catch (e) {\n next(e)\n }\n }\n\n/**\n * `App` class - the starting point of tinyhttp app.\n *\n * With the `App` you can:\n * * use routing methods and `.use(...)`\n * * set no match (404) and error (500) handlers\n * * configure template engines\n * * store data in locals\n * * listen the http server on a specified port\n *\n * In case you use TypeScript, you can pass custom types to this class because it is also a generic class.\n *\n * Example:\n *\n * ```ts\n * interface CoolReq extends Request {\n * genericsAreDope: boolean\n * }\n *\n * const app = App<any, CoolReq, Response>()\n * ```\n */\nexport class App<Req extends Request = Request, Res extends Response = Response> extends Router<App, Req, Res> {\n middleware: Middleware<Req, Res>[] = []\n locals: Record<string, unknown> = {}\n noMatchHandler: Handler\n onError: ErrorHandler\n settings: AppSettings\n engines: Record<string, TemplateEngine> = {}\n applyExtensions: (req: Request, res: Response, next: NextFunction) => void\n attach: (req: Req, res: Res, next?: NextFunction) => void\n cache: Record<string, unknown>\n\n constructor(options: AppConstructor<Req, Res> = {}) {\n super()\n this.onError = options?.onError || onErrorHandler\n this.noMatchHandler = options?.noMatchHandler || this.onError.bind(this, { code: 404 })\n this.settings = {\n view: View,\n xPoweredBy: true,\n views: `${process.cwd()}/views`,\n 'view cache': process.env.NODE_ENV === 'production',\n 'trust proxy': 0,\n ...options.settings\n }\n this.applyExtensions = options?.applyExtensions\n const boundHandler = this.handler.bind(this)\n this.attach = (req, res, next?: NextFunction) => setImmediate(boundHandler, req, res, next)\n this.cache = {}\n }\n\n /**\n * Set app setting\n * @param setting setting name\n * @param value setting value\n */\n set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): this {\n this.settings[setting] = value\n\n return this\n }\n\n /**\n * Enable app setting\n * @param setting Setting name\n */\n enable<K extends keyof AppSettings>(setting: K): this {\n this.settings[setting] = true as AppSettings[K]\n\n return this\n }\n\n /**\n * Check if setting is enabled\n * @param setting Setting name\n * @returns\n */\n enabled<K extends keyof AppSettings>(setting: K): boolean {\n return Boolean(this.settings[setting])\n }\n\n /**\n * Disable app setting\n * @param setting Setting name\n */\n disable<K extends keyof AppSettings>(setting: K): this {\n this.settings[setting] = false as AppSettings[K]\n\n return this\n }\n\n /**\n * Return the app's absolute pathname\n * based on the parent(s) that have\n * mounted it.\n *\n * For example if the application was\n * mounted as `\"/admin\"`, which itself\n * was mounted as `\"/blog\"` then the\n * return value would be `\"/blog/admin\"`.\n *\n */\n path(): string {\n return this.parent ? this.parent.path() + this.mountpath : ''\n }\n\n /**\n * Register a template engine with extension\n */\n engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n ext: string,\n fn: TemplateEngine<RenderOptions>\n ): this {\n this.engines[ext[0] === '.' ? ext : `.${ext}`] = fn\n\n return this\n }\n\n /**\n * Render a template\n * @param name What to render\n * @param data data that is passed to a template\n * @param options Template engine options\n * @param cb Callback that consumes error and html\n */\n render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n name: string,\n data: Record<string, unknown> = {},\n options: AppRenderOptions<RenderOptions> = {} as AppRenderOptions<RenderOptions>,\n cb: (err: unknown, html?: unknown) => void = () => {}\n ): void {\n let view: View | undefined\n\n const { _locals, ...opts } = options\n\n let locals = this.locals\n\n if (_locals) locals = { ...locals, ..._locals }\n\n locals = { ...locals, ...data }\n\n if (opts.cache == null) (opts.cache as boolean) = this.enabled('view cache')\n\n if (opts.cache) {\n view = this.cache[name] as View\n }\n\n if (!view) {\n const View = this.settings.view\n view = new View(name, {\n defaultEngine: this.settings['view engine'],\n root: this.settings.views,\n engines: this.engines\n })\n\n if (!view.path) {\n const dirs =\n Array.isArray(view.root) && view.root.length > 1\n ? `directories \"${view.root.slice(0, -1).join('\", \"')}\" or \"${view.root[view.root.length - 1]}\"`\n : `directory \"${view.root}\"`\n const err = new Error(`Failed to lookup view \"${name}\" in views ${dirs}`)\n\n return cb(err)\n }\n\n if (opts.cache) {\n this.cache[name] = view\n }\n }\n\n try {\n view.render(opts, locals, cb)\n } catch (err) {\n cb(err)\n }\n }\n use(...args: UseMethodParams<Req, Res, App>): this {\n const base = args[0]\n\n const fns = args.slice(1).flat()\n\n let pathArray = []\n if (typeof base === 'function' || base instanceof App) {\n fns.unshift(base)\n } else {\n // if base is not an array of paths, then convert it to an array.\n let basePaths = []\n if (Array.isArray(base)) basePaths = [...base]\n else if (typeof base === 'string') basePaths = [base]\n\n basePaths = basePaths.filter((element) => {\n if (typeof element === 'string') {\n pathArray.push(element)\n return false\n }\n return true\n })\n fns.unshift(...basePaths)\n }\n pathArray = pathArray.length ? pathArray.map((path) => lead(path)) : ['/']\n\n const mountpath = pathArray.join(', ')\n let regex: { keys: string[]; pattern: RegExp }\n\n for (const fn of fns) {\n if (fn instanceof App) {\n for (const path of pathArray) {\n regex = rg(path, true)\n fn.mountpath = mountpath\n this.apps[path] = fn\n fn.parent = this\n }\n }\n }\n for (const path of pathArray) {\n const handlerPaths = []\n const handlerFunctions = []\n const handlerPathBase = path === '/' ? '' : lead(path)\n for (const fn of fns) {\n if (fn instanceof App && fn.middleware?.length) {\n for (const mw of fn.middleware) {\n handlerPaths.push(handlerPathBase + lead(mw.path))\n handlerFunctions.push(fn)\n }\n } else {\n handlerPaths.push('')\n handlerFunctions.push(fn)\n }\n }\n pushMiddleware(this.middleware)({\n path,\n regex,\n type: 'mw',\n handler: mount(handlerFunctions[0] as Handler),\n handlers: handlerFunctions.slice(1).map(mount),\n fullPaths: handlerPaths\n })\n }\n\n return this\n }\n\n route(path: string): App {\n const app = new App({ settings: this.settings })\n\n this.use(path, app)\n\n return app\n }\n\n #find(url: string): Middleware<Req, Res>[] {\n return this.middleware.filter((m) => {\n m.regex = m.regex || rg(m.path, m.type === 'mw')\n\n let fullPathRegex: { keys: string[]; pattern: RegExp }\n\n m.fullPath && typeof m.fullPath === 'string'\n ? (fullPathRegex = rg(m.fullPath, m.type === 'mw'))\n : (fullPathRegex = null)\n\n return m.regex.pattern.test(url) && (m.type === 'mw' && fullPathRegex ? fullPathRegex.pattern.test(url) : true)\n })\n }\n\n /**\n * Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware\n * @param req Req object\n * @param res Res object\n * @param next 'Next' function\n */\n handler<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(\n req: Req,\n res: Res,\n next?: NextFunction\n ): void {\n /* Set X-Powered-By header */\n const { xPoweredBy } = this.settings\n if (xPoweredBy) res.setHeader('X-Powered-By', typeof xPoweredBy === 'string' ? xPoweredBy : 'tinyhttp')\n\n const exts = this.applyExtensions || extendMiddleware<RenderOptions>(this)\n\n req.originalUrl = req.url || req.originalUrl\n\n const pathname = getPathname(req.originalUrl)\n\n const matched = this.#find(pathname)\n\n const mw: Middleware[] = [\n {\n handler: exts,\n type: 'mw',\n path: '/'\n },\n ...matched.filter((x) => req.method === 'HEAD' || (x.method ? x.method === req.method : true))\n ]\n\n if (matched[0] != null) {\n mw.push({\n type: 'mw',\n handler: (req, res, next) => {\n if (req.method === 'HEAD') {\n res.statusCode = 204\n return res.end('')\n }\n next()\n },\n path: '/'\n })\n }\n\n if (this.parent == null) {\n mw.push({\n handler: this.noMatchHandler,\n type: 'mw',\n path: '/'\n })\n }\n\n const handle = (mw: Middleware) => async (req: Req, res: Res, next?: NextFunction) => {\n const { path, handler, regex } = mw\n\n let params: URLParams\n\n try {\n params = regex ? getURLParams(regex, pathname) : {}\n } catch (e) {\n console.error(e)\n if (e instanceof URIError) return res.sendStatus(400)\n throw e\n }\n\n // Warning: users should not use :wild as a pattern\n let prefix = path\n if (regex) {\n for (const key of regex.keys as string[]) {\n if (key === 'wild') {\n prefix = prefix.replace('*', params.wild)\n } else {\n prefix = prefix.replace(`:${key}`, params[key])\n }\n }\n }\n\n req.params = { ...req.params, ...params }\n\n if (mw.type === 'mw') {\n req.url = lead(req.originalUrl.substring(prefix.length))\n }\n\n if (!req.path) req.path = getPathname(req.url)\n\n if (this.settings?.enableReqRoute) req.route = mw\n\n await applyHandler<Req, Res>(handler as unknown as Handler<Req, Res>)(req, res, next)\n }\n\n let idx = 0\n\n const loop = (): void => void handle(mw[idx++])(req, res, next)\n\n const parentNext = next\n next = (err) => {\n if (err != null) {\n return this.onError(err, req, res)\n }\n\n if (res.writableEnded) return\n if (idx >= mw.length) {\n if (parentNext != null) parentNext()\n return\n }\n\n loop()\n }\n\n loop()\n }\n\n /**\n * Creates HTTP server and dispatches middleware\n * @param port server listening port\n * @param cb callback to be invoked after server starts listening\n * @param host server listening host\n */\n listen(port?: number, cb?: () => void, host?: string): Server {\n return createServer().on('request', this.attach).listen(port, host, cb)\n }\n}\n"],"names":["proxyAddr","View","rg","req","res","next","mw"],"mappings":";;;;;;;;;;AAgBA,MAAM,qBAAqB,CAAC,EAAE,UAA+C,UAA0B;AACrG,QAAM,MAAM,OAAO;AACnB,MAAI,OAAO,UAAU,WAAY,SAAQ,QAAQ,KAAK;AAC/C,SAAA,MAAM,KAAK,CAAC;AACrB;AAEa,MAAA,cAAc,CAAC,KAAc,UA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4
  "description": "0-legacy, tiny & fast web framework as a replacement of Express",
5
5
  "type": "module",
6
6
  "homepage": "https://tinyhttp.v1rtl.site",
@@ -35,10 +35,10 @@
35
35
  "header-range-parser": "1.1.3",
36
36
  "regexparam": "^2.0.2",
37
37
  "@tinyhttp/cookie": "2.1.1",
38
- "@tinyhttp/res": "2.2.3",
39
- "@tinyhttp/router": "2.2.2",
38
+ "@tinyhttp/proxy-addr": "2.2.0",
40
39
  "@tinyhttp/req": "2.2.3",
41
- "@tinyhttp/proxy-addr": "2.2.0"
40
+ "@tinyhttp/res": "2.2.3",
41
+ "@tinyhttp/router": "2.2.2"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "vite",