added doga
This commit is contained in:
55
25_02_24/node_modules/@tinyhttp/app/dist/app.d.ts
generated
vendored
Normal file
55
25_02_24/node_modules/@tinyhttp/app/dist/app.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { type Server } from 'node:http';
|
||||
import type { Handler, Middleware, NextFunction, UseMethodParams } from '@tinyhttp/router';
|
||||
import { Router } from '@tinyhttp/router';
|
||||
import type { TemplateEngineOptions } from './index.js';
|
||||
import type { ErrorHandler } from './onError.js';
|
||||
import type { Request } from './request.js';
|
||||
import type { Response } from './response.js';
|
||||
import type { AppConstructor, AppInterface, AppRenderOptions, AppSettings, TemplateEngine } from './types.js';
|
||||
/**
|
||||
* `App` class - the starting point of tinyhttp app.
|
||||
*
|
||||
* With the `App` you can:
|
||||
* * use routing methods and `.use(...)`
|
||||
* * set no match (404) and error (500) handlers
|
||||
* * configure template engines
|
||||
* * store data in locals
|
||||
* * listen the http server on a specified port
|
||||
*
|
||||
* In case you use TypeScript, you can pass custom types to this class because it is also a generic class.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```ts
|
||||
* interface CoolReq extends Request {
|
||||
* genericsAreDope: boolean
|
||||
* }
|
||||
*
|
||||
* const app = App<any, CoolReq, Response>()
|
||||
* ```
|
||||
*/
|
||||
export declare class App<Req extends Request = Request, Res extends Response = Response> extends Router<App, Req, Res> implements AppInterface<Req, Res> {
|
||||
#private;
|
||||
middleware: Middleware<Req, Res>[];
|
||||
locals: Record<string, unknown>;
|
||||
noMatchHandler: Handler;
|
||||
onError: ErrorHandler;
|
||||
settings: AppSettings;
|
||||
engines: Record<string, TemplateEngine>;
|
||||
applyExtensions?: Handler;
|
||||
attach: (req: Req, res: Res, next?: NextFunction) => void;
|
||||
cache: Record<string, unknown>;
|
||||
constructor(options?: AppConstructor<Req, Res>);
|
||||
set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): this;
|
||||
enable<K extends keyof AppSettings>(setting: K): this;
|
||||
enabled<K extends keyof AppSettings>(setting: K): boolean;
|
||||
disable<K extends keyof AppSettings>(setting: K): this;
|
||||
path(): any;
|
||||
engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(ext: string, fn: TemplateEngine<RenderOptions>): this;
|
||||
render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(name: string, data?: Record<string, unknown>, options?: AppRenderOptions<RenderOptions>, cb?: (err: unknown, html?: unknown) => void): void;
|
||||
use(...args: UseMethodParams<Req, Res, AppInterface<any, any>>): this;
|
||||
route(path: string): App<any, any>;
|
||||
handler<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(req: Req, res: Res, next?: NextFunction): void;
|
||||
listen(port?: number, cb?: () => void, host?: string): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
||||
}
|
||||
//# sourceMappingURL=app.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/app.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/app.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAA;AAGzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM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E,MAAM,EACX,EAAE,EAAE,cAAc,CAAC,aAAa,CAAC,GAChC,IAAI;IAKP,MAAM,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB,EACxE,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAClC,OAAO,GAAE,gBAAgB,CAAC,aAAa,CAAyC,EAChF,EAAE,GAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAe;IA0CvD,GAAG,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI;IAmErE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAsBlC,OAAO,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB,EACzE,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,CAAC,EAAE,YAAY;IAmHrB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM;CAGrD"}
|
||||
323
25_02_24/node_modules/@tinyhttp/app/dist/app.js
generated
vendored
Normal file
323
25_02_24/node_modules/@tinyhttp/app/dist/app.js
generated
vendored
Normal file
@@ -0,0 +1,323 @@
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var _App_instances, _App_find;
|
||||
import { createServer } from 'node:http';
|
||||
import { getPathname } from '@tinyhttp/req';
|
||||
import { Router, pushMiddleware } from '@tinyhttp/router';
|
||||
import { parse as rg } from 'regexparam';
|
||||
import { extendMiddleware } from './extend.js';
|
||||
import { onErrorHandler } from './onError.js';
|
||||
import { getURLParams } from './request.js';
|
||||
import { View } from './view.js';
|
||||
/**
|
||||
* Add leading slash if not present (e.g. path -> /path, /path -> /path)
|
||||
* @param x
|
||||
*/
|
||||
const lead = (x) => (x.charCodeAt(0) === 47 ? x : `/${x}`);
|
||||
const trail = (x) => (x.charCodeAt(x.length - 1) === 47 ? x.substring(0, x.length - 1) : x);
|
||||
const mount = (fn) => (fn instanceof App ? fn.attach : fn);
|
||||
const applyHandler = (h) => async (req, res, next) => {
|
||||
try {
|
||||
if (h[Symbol.toStringTag] === 'AsyncFunction') {
|
||||
await h(req, res, next);
|
||||
}
|
||||
else
|
||||
h(req, res, next);
|
||||
}
|
||||
catch (e) {
|
||||
next === null || next === void 0 ? void 0 : next(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* `App` class - the starting point of tinyhttp app.
|
||||
*
|
||||
* With the `App` you can:
|
||||
* * use routing methods and `.use(...)`
|
||||
* * set no match (404) and error (500) handlers
|
||||
* * configure template engines
|
||||
* * store data in locals
|
||||
* * listen the http server on a specified port
|
||||
*
|
||||
* In case you use TypeScript, you can pass custom types to this class because it is also a generic class.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```ts
|
||||
* interface CoolReq extends Request {
|
||||
* genericsAreDope: boolean
|
||||
* }
|
||||
*
|
||||
* const app = App<any, CoolReq, Response>()
|
||||
* ```
|
||||
*/
|
||||
export class App extends Router {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
_App_instances.add(this);
|
||||
this.middleware = [];
|
||||
this.locals = {};
|
||||
this.engines = {};
|
||||
this.onError = (options === null || options === void 0 ? void 0 : options.onError) || onErrorHandler;
|
||||
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
|
||||
this.noMatchHandler = (options === null || options === void 0 ? void 0 : options.noMatchHandler) || this.onError.bind(this, { code: 404 });
|
||||
this.settings = {
|
||||
view: View,
|
||||
xPoweredBy: true,
|
||||
views: `${process.cwd()}/views`,
|
||||
'view cache': process.env.NODE_ENV === 'production',
|
||||
'trust proxy': 0,
|
||||
...options.settings
|
||||
};
|
||||
if (options.applyExtensions)
|
||||
this.applyExtensions = options === null || options === void 0 ? void 0 : options.applyExtensions;
|
||||
const boundHandler = this.handler.bind(this);
|
||||
this.attach = (req, res, next) => setImmediate(boundHandler, req, res, next);
|
||||
this.cache = {};
|
||||
}
|
||||
set(setting, value) {
|
||||
this.settings[setting] = value;
|
||||
return this;
|
||||
}
|
||||
enable(setting) {
|
||||
this.settings[setting] = true;
|
||||
return this;
|
||||
}
|
||||
enabled(setting) {
|
||||
return Boolean(this.settings[setting]);
|
||||
}
|
||||
disable(setting) {
|
||||
this.settings[setting] = false;
|
||||
return this;
|
||||
}
|
||||
path() {
|
||||
return this.parent ? this.parent.path() + this.mountpath : '';
|
||||
}
|
||||
engine(ext, fn) {
|
||||
this.engines[ext[0] === '.' ? ext : `.${ext}`] = fn;
|
||||
return this;
|
||||
}
|
||||
render(name, data = {}, options = {}, cb = () => { }) {
|
||||
let view;
|
||||
const { _locals, ...opts } = options;
|
||||
let locals = this.locals;
|
||||
if (_locals)
|
||||
locals = { ...locals, ..._locals };
|
||||
locals = { ...locals, ...data };
|
||||
if (opts.cache == null)
|
||||
opts.cache = this.enabled('view cache');
|
||||
if (opts.cache) {
|
||||
view = this.cache[name];
|
||||
}
|
||||
if (!view) {
|
||||
const ViewClass = this.settings.view || View;
|
||||
try {
|
||||
view = new ViewClass(name, {
|
||||
defaultEngine: this.settings['view engine'],
|
||||
root: this.settings.views,
|
||||
engines: this.engines
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
return cb(err);
|
||||
}
|
||||
if (opts.cache) {
|
||||
this.cache[name] = view;
|
||||
}
|
||||
}
|
||||
try {
|
||||
view.render(opts, locals, cb);
|
||||
}
|
||||
catch (err) {
|
||||
cb(err);
|
||||
}
|
||||
}
|
||||
use(...args) {
|
||||
var _a;
|
||||
const base = args[0];
|
||||
const fns = args.slice(1).flat();
|
||||
let pathArray = [];
|
||||
if (typeof base === 'function' || base instanceof App) {
|
||||
fns.unshift(base);
|
||||
}
|
||||
else {
|
||||
// if base is not an array of paths, then convert it to an array.
|
||||
let basePaths = [];
|
||||
if (Array.isArray(base))
|
||||
basePaths = base;
|
||||
else if (typeof base === 'string')
|
||||
basePaths = [base];
|
||||
basePaths = basePaths.filter((element) => {
|
||||
if (typeof element === 'string') {
|
||||
pathArray.push(element);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
fns.unshift(...basePaths);
|
||||
}
|
||||
pathArray = pathArray.length ? pathArray.map((path) => lead(path)) : ['/'];
|
||||
const mountpath = pathArray.join(', ');
|
||||
let regex;
|
||||
for (const fn of fns) {
|
||||
if (fn instanceof App) {
|
||||
for (const path of pathArray) {
|
||||
regex = rg(path, true);
|
||||
fn.mountpath = mountpath;
|
||||
this.apps[path] = fn;
|
||||
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
|
||||
fn.parent = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const path of pathArray) {
|
||||
const handlerPaths = [];
|
||||
const handlerFunctions = [];
|
||||
const handlerPathBase = path === '/' ? '' : lead(path);
|
||||
for (const fn of fns) {
|
||||
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) {
|
||||
for (const mw of fn.middleware) {
|
||||
handlerPaths.push(handlerPathBase + lead(mw.path));
|
||||
handlerFunctions.push(fn);
|
||||
}
|
||||
}
|
||||
else {
|
||||
handlerPaths.push('');
|
||||
handlerFunctions.push(fn);
|
||||
}
|
||||
}
|
||||
pushMiddleware(this.middleware)({
|
||||
path,
|
||||
regex,
|
||||
type: 'mw',
|
||||
handler: mount(handlerFunctions[0]),
|
||||
handlers: handlerFunctions.slice(1).map(mount),
|
||||
fullPaths: handlerPaths
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
route(path) {
|
||||
const app = new App({ settings: this.settings });
|
||||
this.use(path, app);
|
||||
return app;
|
||||
}
|
||||
handler(req, res, next) {
|
||||
/* Set X-Powered-By header */
|
||||
const { xPoweredBy } = this.settings;
|
||||
if (xPoweredBy)
|
||||
res.setHeader('X-Powered-By', typeof xPoweredBy === 'string' ? xPoweredBy : 'tinyhttp');
|
||||
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
|
||||
const exts = this.applyExtensions || extendMiddleware(this);
|
||||
let mw = [
|
||||
{
|
||||
handler: exts,
|
||||
type: 'mw',
|
||||
path: '/'
|
||||
}
|
||||
];
|
||||
req.baseUrl = '';
|
||||
const handle = (mw, pathname) => async (req, res, next) => {
|
||||
var _a;
|
||||
const { path, handler, regex } = mw;
|
||||
let params;
|
||||
try {
|
||||
params = regex ? getURLParams(regex, pathname) : {};
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
if (e instanceof URIError)
|
||||
return res.sendStatus(400);
|
||||
throw e;
|
||||
}
|
||||
let prefix = path;
|
||||
if (regex) {
|
||||
for (const key of regex.keys) {
|
||||
if (key === 'wild') {
|
||||
prefix = prefix.replace('*', params.wild);
|
||||
}
|
||||
else {
|
||||
prefix = prefix.replace(`:${key}`, params[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
req.params = { ...req.params, ...params };
|
||||
if (mw.type === 'mw') {
|
||||
req.url = lead(req.originalUrl.substring(prefix.length));
|
||||
req.baseUrl = trail(req.originalUrl.substring(0, prefix.length));
|
||||
}
|
||||
if (!req.path)
|
||||
req.path = pathname;
|
||||
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enableReqRoute)
|
||||
req.route = mw;
|
||||
await applyHandler(handler)(req, res, next);
|
||||
};
|
||||
let idx = 0;
|
||||
const loop = () => {
|
||||
req.originalUrl = req.baseUrl + req.url;
|
||||
const pathname = getPathname(req.url);
|
||||
const matched = __classPrivateFieldGet(this, _App_instances, "m", _App_find).call(this, pathname).filter((x) => (req.method === 'HEAD' || (x.method ? x.method === req.method : true)) && !mw.includes(x));
|
||||
if (matched.length && matched[0] !== null) {
|
||||
if (idx !== 0) {
|
||||
idx = mw.length;
|
||||
req.params = {};
|
||||
}
|
||||
mw = [
|
||||
...mw,
|
||||
...matched,
|
||||
{
|
||||
type: 'mw',
|
||||
handler: (req, res, next) => {
|
||||
if (req.method === 'HEAD') {
|
||||
res.statusCode = 204;
|
||||
return res.end('');
|
||||
}
|
||||
next === null || next === void 0 ? void 0 : next();
|
||||
},
|
||||
path: '/'
|
||||
}
|
||||
];
|
||||
}
|
||||
else if (this.parent == null) {
|
||||
mw.push({
|
||||
handler: this.noMatchHandler,
|
||||
type: 'route',
|
||||
path: '/'
|
||||
});
|
||||
}
|
||||
void handle(mw[idx++], pathname)(req, res, next);
|
||||
};
|
||||
const parentNext = next;
|
||||
next = (err) => {
|
||||
if (err != null) {
|
||||
// @ts-expect-error The 'this' context of type 'this' is not assignable to method's 'this' of type 'App<Request, Response<unknown>>' ts(2345)
|
||||
return this.onError(err, req, res);
|
||||
}
|
||||
if (res.writableEnded)
|
||||
return;
|
||||
if (idx >= mw.length) {
|
||||
if (parentNext != null)
|
||||
parentNext();
|
||||
return;
|
||||
}
|
||||
loop();
|
||||
};
|
||||
loop();
|
||||
}
|
||||
listen(port, cb, host) {
|
||||
return createServer().on('request', this.attach).listen(port, host, cb);
|
||||
}
|
||||
}
|
||||
_App_instances = new WeakSet(), _App_find = function _App_find(url) {
|
||||
return this.middleware.filter((m) => {
|
||||
m.regex = m.regex || rg(m.path, m.type === 'mw');
|
||||
let fullPathRegex;
|
||||
m.fullPath && typeof m.fullPath === 'string'
|
||||
? (fullPathRegex = rg(m.fullPath, m.type === 'mw'))
|
||||
: (fullPathRegex = null);
|
||||
return m.regex.pattern.test(url) && (m.type === 'mw' && fullPathRegex ? fullPathRegex.pattern.test(url) : true);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=app.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/app.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/app.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
25_02_24/node_modules/@tinyhttp/app/dist/extend.d.ts
generated
vendored
Normal file
8
25_02_24/node_modules/@tinyhttp/app/dist/extend.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { App } from './app.js';
|
||||
import type { Handler } from './index.js';
|
||||
import type { TemplateEngineOptions } from './types.js';
|
||||
/**
|
||||
* Extends Request and Response objects with custom properties and methods
|
||||
*/
|
||||
export declare const extendMiddleware: <EngineOptions extends TemplateEngineOptions = TemplateEngineOptions>(app: App) => Handler;
|
||||
//# sourceMappingURL=extend.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/extend.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/extend.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../src/extend.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAKzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,aAAa,SAAS,qBAAqB,+BAA+B,GAAG,KA+DtG,OAAO,CAAA"}
|
||||
64
25_02_24/node_modules/@tinyhttp/app/dist/extend.js
generated
vendored
Normal file
64
25_02_24/node_modules/@tinyhttp/app/dist/extend.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import { compile } from '@tinyhttp/proxy-addr';
|
||||
import { checkIfXMLHttpRequest, getAccepts, getAcceptsCharsets, getAcceptsEncodings, getAcceptsLanguages, getFreshOrStale, getQueryParams, getRangeFromHeader, getRequestHeader, reqIs } from '@tinyhttp/req';
|
||||
import { append, attachment, clearCookie, download, formatResponse, getResponseHeader, json, redirect, send, sendFile, sendStatus, setContentType, setCookie, setHeader, setLinksHeader, setLocationHeader, setVaryHeader, status } from '@tinyhttp/res';
|
||||
import { getSubdomains } from './request.js';
|
||||
import { getHost, getIP, getIPs, getProtocol } from './request.js';
|
||||
import { renderTemplate } from './response.js';
|
||||
/**
|
||||
* Extends Request and Response objects with custom properties and methods
|
||||
*/
|
||||
export const extendMiddleware = (app) => ((req, res, next) => {
|
||||
const { settings } = app;
|
||||
res.get = getResponseHeader(res);
|
||||
req.get = getRequestHeader(req);
|
||||
if (settings === null || settings === void 0 ? void 0 : settings.bindAppToReqRes) {
|
||||
req.app = app;
|
||||
res.app = app;
|
||||
}
|
||||
if (settings === null || settings === void 0 ? void 0 : settings.networkExtensions) {
|
||||
let trust = (settings === null || settings === void 0 ? void 0 : settings['trust proxy']) || 0;
|
||||
if (trust && typeof trust !== 'function') {
|
||||
trust = compile(trust);
|
||||
settings['trust proxy'] = trust;
|
||||
}
|
||||
req.protocol = getProtocol(req, trust);
|
||||
req.secure = req.protocol === 'https';
|
||||
const host = getHost(req, trust);
|
||||
req.hostname = host === null || host === void 0 ? void 0 : host.hostname;
|
||||
req.port = host === null || host === void 0 ? void 0 : host.port;
|
||||
req.subdomains = getSubdomains(req, trust, settings.subdomainOffset);
|
||||
req.ip = getIP(req, trust);
|
||||
req.ips = getIPs(req, trust);
|
||||
}
|
||||
req.query = getQueryParams(req.url);
|
||||
req.is = reqIs(req);
|
||||
req.range = getRangeFromHeader(req);
|
||||
req.accepts = getAccepts(req);
|
||||
req.acceptsCharsets = getAcceptsCharsets(req);
|
||||
req.acceptsEncodings = getAcceptsEncodings(req);
|
||||
req.acceptsLanguages = getAcceptsLanguages(req);
|
||||
req.xhr = checkIfXMLHttpRequest(req);
|
||||
res.header = res.set = setHeader(res);
|
||||
res.send = send(req, res);
|
||||
res.json = json(res);
|
||||
res.status = status(res);
|
||||
res.sendStatus = sendStatus(req, res);
|
||||
res.sendFile = sendFile(req, res);
|
||||
res.type = setContentType(res);
|
||||
res.location = setLocationHeader(req, res);
|
||||
res.links = setLinksHeader(res);
|
||||
res.vary = setVaryHeader(res);
|
||||
res.cookie = setCookie(req, res);
|
||||
res.clearCookie = clearCookie(req, res);
|
||||
res.render = renderTemplate(req, res, app);
|
||||
res.format = formatResponse(req, res, next);
|
||||
res.redirect = redirect(req, res, next);
|
||||
res.attachment = attachment(res);
|
||||
res.download = download(req, res);
|
||||
res.append = append(res);
|
||||
res.locals = res.locals || Object.create(null);
|
||||
Object.defineProperty(req, 'fresh', { get: getFreshOrStale.bind(null, req, res), configurable: true });
|
||||
req.stale = !req.fresh;
|
||||
next();
|
||||
});
|
||||
//# sourceMappingURL=extend.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/extend.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/extend.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../src/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACN,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,MAAM,EACP,MAAM,eAAe,CAAA;AAItB,OAAO,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,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C,KAAK,CAAA;IAEtB,IAAI,EAAE,CAAA;AACR,CAAC,CAAY,CAAA"}
|
||||
15
25_02_24/node_modules/@tinyhttp/app/dist/index.d.ts
generated
vendored
Normal file
15
25_02_24/node_modules/@tinyhttp/app/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export { App } from './app.js';
|
||||
export * from './request.js';
|
||||
export * from './response.js';
|
||||
export { extendMiddleware } from './extend.js';
|
||||
export { onErrorHandler, type ErrorHandler } from './onError.js';
|
||||
export { View } from './view.js';
|
||||
export type { AppSettings, TemplateEngineOptions, TemplateEngine, AppConstructor } from './types.js';
|
||||
import type { Middleware, NextFunction, AsyncHandler as RAsyncHandler, Handler as RHandler, SyncHandler as RSyncHandler } from '@tinyhttp/router';
|
||||
import type { Request } from './request.js';
|
||||
import type { Response } from './response.js';
|
||||
export type Handler = RHandler<Request, Response>;
|
||||
export type AsyncHandler = RAsyncHandler<Request, Response>;
|
||||
export type SyncHandler = RSyncHandler<Request, Response>;
|
||||
export type { NextFunction, Middleware, Request, Response };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/index.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEpG,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,YAAY,IAAI,aAAa,EAC7B,OAAO,IAAI,QAAQ,EACnB,WAAW,IAAI,YAAY,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACjD,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AAC3D,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACzD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
||||
7
25_02_24/node_modules/@tinyhttp/app/dist/index.js
generated
vendored
Normal file
7
25_02_24/node_modules/@tinyhttp/app/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export { App } from './app.js';
|
||||
export * from './request.js';
|
||||
export * from './response.js';
|
||||
export { extendMiddleware } from './extend.js';
|
||||
export { onErrorHandler } from './onError.js';
|
||||
export { View } from './view.js';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/index.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
||||
7
25_02_24/node_modules/@tinyhttp/app/dist/onError.d.ts
generated
vendored
Normal file
7
25_02_24/node_modules/@tinyhttp/app/dist/onError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { NextFunction } from '@tinyhttp/router';
|
||||
import type { App } from './app.js';
|
||||
import type { Request } from './request.js';
|
||||
import type { Response } from './response.js';
|
||||
export type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void;
|
||||
export declare const onErrorHandler: ErrorHandler;
|
||||
//# sourceMappingURL=onError.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/onError.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/onError.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"onError.d.ts","sourceRoot":"","sources":["../src/onError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAA;AAE1G,eAAO,MAAM,cAAc,EAAE,YAU5B,CAAA"}
|
||||
15
25_02_24/node_modules/@tinyhttp/app/dist/onError.js
generated
vendored
Normal file
15
25_02_24/node_modules/@tinyhttp/app/dist/onError.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { STATUS_CODES } from 'node:http';
|
||||
export const onErrorHandler = function (err, _req, res) {
|
||||
if (this.onError === onErrorHandler && this.parent)
|
||||
return this.parent.onError(err, _req, res);
|
||||
if (err instanceof Error)
|
||||
console.error(err);
|
||||
const code = err.code in STATUS_CODES ? err.code : err.status;
|
||||
if (typeof err === 'string' || Buffer.isBuffer(err))
|
||||
res.writeHead(500).end(err);
|
||||
else if (code in STATUS_CODES)
|
||||
res.writeHead(code).end(STATUS_CODES[code]);
|
||||
else
|
||||
res.writeHead(500).end(err.message);
|
||||
};
|
||||
//# sourceMappingURL=onError.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/onError.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/onError.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"onError.js","sourceRoot":"","sources":["../src/onError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAQxC,MAAM,CAAC,MAAM,cAAc,GAAiB,UAAqB,GAAQ,EAAE,IAAa,EAAE,GAAa;IACrG,IAAI,IAAI,CAAC,OAAO,KAAK,cAAc,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAE9F,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE5C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA;IAE7D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;SAC3E,IAAI,IAAI,IAAI,YAAY;QAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;;QACrE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AAC1C,CAAC,CAAA"}
|
||||
59
25_02_24/node_modules/@tinyhttp/app/dist/request.d.ts
generated
vendored
Normal file
59
25_02_24/node_modules/@tinyhttp/app/dist/request.d.ts
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
|
||||
import type { ParsedUrlQuery } from 'node:querystring';
|
||||
import { type Trust } from '@tinyhttp/proxy-addr';
|
||||
import type { Options, Ranges } from 'header-range-parser';
|
||||
import type { Middleware } from '@tinyhttp/router';
|
||||
import type { App } from './app.js';
|
||||
import type { Socket } from 'node:net';
|
||||
import type { TLSSocket } from 'node:tls';
|
||||
import type { URLParams } from '@tinyhttp/req';
|
||||
export { getURLParams } from '@tinyhttp/req';
|
||||
export type Host = {
|
||||
hostname: string;
|
||||
port?: number;
|
||||
};
|
||||
export declare const getProtocol: (req: Request, trust: Trust) => Protocol;
|
||||
export declare const getHost: (req: Request, trust: Trust) => Host | undefined;
|
||||
export declare const getIP: (req: Pick<Request, "headers" | "connection" | "socket">, trust: Trust) => string | undefined;
|
||||
export declare const getIPs: (req: Pick<Request, "headers" | "connection" | "socket">, trust: Trust) => string[] | undefined;
|
||||
export declare const getSubdomains: (req: Request, trust: Trust, subdomainOffset?: number) => string[];
|
||||
export type Connection = IncomingMessage['socket'] & {
|
||||
encrypted: boolean;
|
||||
};
|
||||
export type Protocol = 'http' | 'https' | string;
|
||||
export type { URLParams };
|
||||
type AcceptsReturns = string | boolean | string[];
|
||||
export interface Request extends IncomingMessage {
|
||||
originalUrl: string;
|
||||
path: string;
|
||||
url: string;
|
||||
baseUrl: string;
|
||||
query: ParsedUrlQuery;
|
||||
params: URLParams;
|
||||
connection: Connection;
|
||||
socket: TLSSocket | Socket;
|
||||
route?: Middleware;
|
||||
protocol: Protocol;
|
||||
secure: boolean;
|
||||
xhr: boolean;
|
||||
hostname?: string;
|
||||
port?: number;
|
||||
ip?: string;
|
||||
ips?: string[];
|
||||
subdomains?: string[];
|
||||
get: <HeaderName extends string>(header: HeaderName) => IncomingHttpHeaders[HeaderName];
|
||||
range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined;
|
||||
accepts: (...types: string[]) => AcceptsReturns;
|
||||
acceptsEncodings: (...encodings: string[]) => AcceptsReturns;
|
||||
acceptsCharsets: (...charsets: string[]) => AcceptsReturns;
|
||||
acceptsLanguages: (...languages: string[]) => AcceptsReturns;
|
||||
is: (...types: string[]) => string | boolean;
|
||||
cookies?: any;
|
||||
signedCookies?: any;
|
||||
secret?: string | string[];
|
||||
fresh?: boolean;
|
||||
stale?: boolean;
|
||||
body?: any;
|
||||
app?: App;
|
||||
}
|
||||
//# sourceMappingURL=request.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/request.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/request.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,KAAK,KAAK,EAAwC,MAAM,sBAAsB,CAAA;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAA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f,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,GAAG,CAAC,EAAE,GAAG,CAAA;CACV"}
|
||||
85
25_02_24/node_modules/@tinyhttp/app/dist/request.js
generated
vendored
Normal file
85
25_02_24/node_modules/@tinyhttp/app/dist/request.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { all, compile, proxyaddr as proxyAddr } from '@tinyhttp/proxy-addr';
|
||||
import { isIP } from 'node:net';
|
||||
export { getURLParams } from '@tinyhttp/req';
|
||||
const trustRemoteAddress = ({ socket }, trust) => {
|
||||
const val = socket.remoteAddress;
|
||||
if (typeof trust !== 'function')
|
||||
trust = compile(trust);
|
||||
return trust(val, 0);
|
||||
};
|
||||
export const getProtocol = (req, trust) => {
|
||||
const proto = `http${req.secure ? 's' : ''}`;
|
||||
if (!trustRemoteAddress(req, trust))
|
||||
return proto;
|
||||
const header = req.headers['X-Forwarded-Proto'] || proto;
|
||||
const index = header.indexOf(',');
|
||||
return index !== -1 ? header.substring(0, index).trim() : header.trim();
|
||||
};
|
||||
const normalizeHostString = (host) => decodeURIComponent(host).toLowerCase().normalize();
|
||||
const getAuthorityHeaderHostString = (req) => {
|
||||
const authority = req.get(':authority');
|
||||
if (Array.isArray(authority))
|
||||
return undefined;
|
||||
if (Array.isArray(authority) || !authority)
|
||||
return undefined;
|
||||
const index = authority.indexOf('@');
|
||||
if (index === -1)
|
||||
return normalizeHostString(authority);
|
||||
return normalizeHostString(authority.substring(index + 1));
|
||||
};
|
||||
const getForwardedHeaderHostString = (req) => {
|
||||
const forwardedHost = req.get('x-forwarded-host');
|
||||
if (Array.isArray(forwardedHost))
|
||||
return undefined;
|
||||
if (!forwardedHost)
|
||||
return undefined;
|
||||
return normalizeHostString(forwardedHost);
|
||||
};
|
||||
const getDefaultHeaderHostString = (req) => {
|
||||
const host = req.get('host');
|
||||
if (!host || host.indexOf(',') !== -1)
|
||||
return undefined;
|
||||
if (host.indexOf(',') !== -1)
|
||||
return undefined;
|
||||
return normalizeHostString(host);
|
||||
};
|
||||
const getHostString = (req, trust) => {
|
||||
var _a;
|
||||
if (trustRemoteAddress(req, trust)) {
|
||||
const forwardedHost = getForwardedHeaderHostString(req);
|
||||
if (forwardedHost)
|
||||
return forwardedHost;
|
||||
}
|
||||
const authorityHost = getAuthorityHeaderHostString(req);
|
||||
const defaultHost = getDefaultHeaderHostString(req);
|
||||
if (authorityHost && defaultHost) {
|
||||
if (authorityHost !== defaultHost)
|
||||
throw new Error('Request `:authority` pseudo-header does not agree with `Host` header');
|
||||
return authorityHost;
|
||||
}
|
||||
return (_a = authorityHost !== null && authorityHost !== void 0 ? authorityHost : defaultHost) !== null && _a !== void 0 ? _a : undefined;
|
||||
};
|
||||
export const getHost = (req, trust) => {
|
||||
const host = getHostString(req, trust);
|
||||
if (!host)
|
||||
return undefined;
|
||||
// IPv6 literal support
|
||||
const index = host.indexOf(':', host[0] === '[' ? host.indexOf(']') + 1 : 0);
|
||||
if (index === -1)
|
||||
return { hostname: host };
|
||||
const hostname = host.substring(0, index);
|
||||
const port = Number(host.substring(index + 1));
|
||||
if (Number.isNaN(port))
|
||||
throw new TypeError('Port number is NaN, therefore Host is malformed');
|
||||
return { hostname, port };
|
||||
};
|
||||
export const getIP = (req, trust) => proxyAddr(req, trust).replace(/^.*:/, ''); // striping the redundant prefix addeded by OS to IPv4 address
|
||||
export const getIPs = (req, trust) => all(req, trust);
|
||||
export const getSubdomains = (req, trust, subdomainOffset = 2) => {
|
||||
const host = getHost(req, trust);
|
||||
if (!(host === null || host === void 0 ? void 0 : host.hostname))
|
||||
return [];
|
||||
const subdomains = isIP(host.hostname) ? [host.hostname] : host.hostname.split('.').reverse();
|
||||
return subdomains.slice(subdomainOffset);
|
||||
};
|
||||
//# sourceMappingURL=request.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/request.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/request.js.map
generated
vend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utgoingHttpHeaders, ServerResponse } from 'node:http';
|
||||
import type { SerializeOptions } from '@tinyhttp/cookie';
|
||||
import type { DownloadOptions, FormatProps, SendFileOptions } from '@tinyhttp/res';
|
||||
import type { App } from './app.js';
|
||||
import type { Request } from './request.js';
|
||||
import type { AppRenderOptions, TemplateEngineOptions } from './types.js';
|
||||
export declare const renderTemplate: <O extends TemplateEngineOptions = TemplateEngineOptions>(_req: Request, res: Response, app: App) => (file: string, data?: Record<string, unknown>, options?: AppRenderOptions<O>) => Response;
|
||||
export interface Response<B = unknown> extends ServerResponse {
|
||||
header(field: string | Record<string, unknown>, val?: string | any[]): Response<B>;
|
||||
set(field: string | Record<string, unknown>, val?: string | any[]): Response<B>;
|
||||
get<HeaderName extends string>(field: HeaderName): OutgoingHttpHeaders[HeaderName];
|
||||
send(body: B): Response<B>;
|
||||
sendFile(path: string, options?: SendFileOptions, cb?: (err?: unknown) => void): Response<B>;
|
||||
json(body: B): Response<B>;
|
||||
status(status: number): Response<B>;
|
||||
sendStatus(statusCode: number): Response<B>;
|
||||
cookie(name: string, value: string | Record<string, unknown>, options?: SerializeOptions & Partial<{
|
||||
signed: boolean;
|
||||
}>): Response<B>;
|
||||
clearCookie(name: string, options?: SerializeOptions): Response<B>;
|
||||
location(url: string): Response<B>;
|
||||
links(links: {
|
||||
[key: string]: string;
|
||||
}): Response<B>;
|
||||
render<O extends TemplateEngineOptions = TemplateEngineOptions>(file: string, data?: Record<string, any>, options?: AppRenderOptions<O>): Response<B>;
|
||||
vary(field: string): Response<B>;
|
||||
format(obj: FormatProps): Response<B>;
|
||||
redirect(url: string, status?: number): Response<B>;
|
||||
type(type: string): Response<B>;
|
||||
download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: unknown) => void): Response<B>;
|
||||
attachment(filename?: string): Response<B>;
|
||||
app?: App;
|
||||
locals: Record<string, any>;
|
||||
/**
|
||||
* Send JSON response with JSONP callback support.
|
||||
*
|
||||
* To enable this method, install the `@tinyhttp/jsonp` package and attach the method to `res.jsonp` property.
|
||||
*
|
||||
* @param obj Response object
|
||||
*/
|
||||
jsonp(obj: any): Response<B>;
|
||||
append(field: string, value: any): Response<B>;
|
||||
}
|
||||
//# sourceMappingURL=response.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/response.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/response.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEzE,eAAO,MAAM,cAAc,GACxB,CAAC,SAAS,qBAAqB,gCAAgC,OAAO,OAAO,QAAQ,OAAO,GAAG,YACzF,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAAG,QAM9E,CAAA;AAEH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc;IAC3D,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAClF,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OA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plate = (_req, res, app) => (file, data, options) => {
|
||||
app.render(file, data ? { ...res.locals, ...data } : res.locals, options, (err, html) => {
|
||||
if (err)
|
||||
throw err;
|
||||
res.send(html);
|
||||
});
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=response.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/response.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/response.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,cAAc,GACzB,CAA0D,IAAa,EAAE,GAAa,EAAE,GAAQ,EAAE,EAAE,CACpG,CAAC,IAAY,EAAE,IAA8B,EAAE,OAA6B,EAAY,EAAE;IACxF,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAY,EAAE,IAAa,EAAE,EAAE;QACxG,IAAI,GAAG;YAAE,MAAM,GAAG,CAAA;QAClB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
108
25_02_24/node_modules/@tinyhttp/app/dist/types.d.ts
generated
vendored
Normal file
108
25_02_24/node_modules/@tinyhttp/app/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
import type { Server } from 'node:http';
|
||||
import type { Trust } from '@tinyhttp/proxy-addr';
|
||||
import type { Handler, NextFunction, RouterInterface, UseMethodParams } from '@tinyhttp/router';
|
||||
import type { ErrorHandler } from './onError.js';
|
||||
import type { Request } from './request.js';
|
||||
import type { Response } from './response.js';
|
||||
import type { View } from './view.js';
|
||||
/**
|
||||
* tinyhttp App has a few settings for toggling features
|
||||
*/
|
||||
export type AppSettings = Partial<{
|
||||
networkExtensions: boolean;
|
||||
subdomainOffset: number;
|
||||
bindAppToReqRes: boolean;
|
||||
xPoweredBy: string | boolean;
|
||||
enableReqRoute: boolean;
|
||||
views: string | string[];
|
||||
view: typeof View;
|
||||
'view cache': boolean;
|
||||
'view engine': string;
|
||||
'trust proxy': Trust;
|
||||
}>;
|
||||
export type TemplateEngineOptions = {
|
||||
[key: string]: unknown;
|
||||
cache?: boolean;
|
||||
};
|
||||
/**
|
||||
* Function that processes the template
|
||||
*/
|
||||
export type TemplateEngine<O extends TemplateEngineOptions = TemplateEngineOptions> = (path: string, locals: Record<string, unknown>, opts: AppRenderOptions<O>, cb: (err: Error | null, html: unknown) => void) => void;
|
||||
export type AppRenderOptions<O extends TemplateEngineOptions = TemplateEngineOptions> = O & Partial<{
|
||||
cache: boolean;
|
||||
ext: string;
|
||||
viewsFolder: string;
|
||||
_locals: Record<string, unknown>;
|
||||
}>;
|
||||
export type AppConstructor<Req extends Request = Request, Res extends Response = Response> = Partial<{
|
||||
noMatchHandler: Handler<Req, Res>;
|
||||
onError: ErrorHandler;
|
||||
settings: AppSettings;
|
||||
applyExtensions: Handler<Req, Res>;
|
||||
new (options: AppConstructor<Req, Res>): AppInterface<Req, Res>;
|
||||
}>;
|
||||
export interface AppInterface<Req extends Request, Res extends Response> extends RouterInterface<AppInterface<Req, Res>, Req, Res> {
|
||||
/**
|
||||
* Set app setting
|
||||
* @param setting setting name
|
||||
* @param value setting value
|
||||
*/
|
||||
set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): AppInterface<Req, Res>;
|
||||
/**
|
||||
* Enable app setting
|
||||
* @param setting Setting name
|
||||
*/
|
||||
enable<K extends keyof AppSettings>(setting: K): AppInterface<Req, Res>;
|
||||
/**
|
||||
* Check if setting is enabled
|
||||
* @param setting Setting name
|
||||
* @returns
|
||||
*/
|
||||
enabled<K extends keyof AppSettings>(setting: K): boolean;
|
||||
/**
|
||||
* Disable app setting
|
||||
* @param setting Setting name
|
||||
*/
|
||||
disable<K extends keyof AppSettings>(setting: K): AppInterface<Req, Res>;
|
||||
/**
|
||||
* Return the app's absolute pathname
|
||||
* based on the parent(s) that have
|
||||
* mounted it.
|
||||
*
|
||||
* For example if the application was
|
||||
* mounted as `"/admin"`, which itself
|
||||
* was mounted as `"/blog"` then the
|
||||
* return value would be `"/blog/admin"`.
|
||||
*
|
||||
*/
|
||||
path(): string;
|
||||
/**
|
||||
* Register a template engine with extension
|
||||
*/
|
||||
engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(ext: string, fn: TemplateEngine<RenderOptions>): AppInterface<Req, Res>;
|
||||
/**
|
||||
* Render a template
|
||||
* @param name What to render
|
||||
* @param data data that is passed to a template
|
||||
* @param options Template engine options
|
||||
* @param cb Callback that consumes error and html
|
||||
*/
|
||||
render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(name: string, data: Record<string, unknown>, options: AppRenderOptions<RenderOptions>, cb: (err: unknown, html?: unknown) => void): void;
|
||||
use(...args: UseMethodParams<Req, Res, AppInterface<any, any>>): AppInterface<Req, Res>;
|
||||
route(path: string): AppInterface<Req, Res>;
|
||||
/**
|
||||
* Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
|
||||
* @param req Req object
|
||||
* @param res Res object
|
||||
* @param next 'Next' function
|
||||
*/
|
||||
handler(req: Req, res: Res, next?: NextFunction): void;
|
||||
/**
|
||||
* Creates HTTP server and dispatches middleware
|
||||
* @param port server listening port
|
||||
* @param cb callback to be invoked after server starts listening
|
||||
* @param host server listening host
|
||||
*/
|
||||
listen(port?: number, cb?: () => void, host?: string): Server;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/types.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/types.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3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E,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC9D"}
|
||||
2
25_02_24/node_modules/@tinyhttp/app/dist/types.js
generated
vendored
Normal file
2
25_02_24/node_modules/@tinyhttp/app/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/types.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
||||
38
25_02_24/node_modules/@tinyhttp/app/dist/view.d.ts
generated
vendored
Normal file
38
25_02_24/node_modules/@tinyhttp/app/dist/view.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*!
|
||||
* Ported from https://github.com/expressjs/express/blob/master/lib/view.js
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
import type { TemplateEngine, TemplateEngineOptions } from './types.js';
|
||||
/**
|
||||
* Initialize a new `View` with the given `name`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `defaultEngine` the default template engine name
|
||||
* - `engines` template engine require() cache
|
||||
* - `root` root path for view lookup
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @public
|
||||
*/
|
||||
export declare class View<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions> {
|
||||
#private;
|
||||
ext?: string;
|
||||
defaultEngine?: string;
|
||||
name: string;
|
||||
engine: TemplateEngine<RenderOptions>;
|
||||
path: string;
|
||||
root: string | string[];
|
||||
constructor(name: string, opts?: Partial<{
|
||||
defaultEngine: string;
|
||||
root: string | string[];
|
||||
engines: Record<string, TemplateEngine<RenderOptions>>;
|
||||
}>);
|
||||
render(options: RenderOptions, data: Record<string, unknown>, cb: (err: Error | null, html: unknown) => void): void;
|
||||
}
|
||||
//# sourceMappingURL=view.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/view.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/app/dist/view.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAUvE;;;;;;;;;;;;GAYG;AAEH,qBAAa,IAAI,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB;;IACnF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,CAAA;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAK;gBAE1B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,OAAO,CAAC;QACZ,aAAa,EAAE,MAAM,CAAA;QACrB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAA;KACvD,CAAM;IAiET,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI;CAG7G"}
|
||||
100
25_02_24/node_modules/@tinyhttp/app/dist/view.js
generated
vendored
Normal file
100
25_02_24/node_modules/@tinyhttp/app/dist/view.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*!
|
||||
* Ported from https://github.com/expressjs/express/blob/master/lib/view.js
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var _View_instances, _View_lookup, _View_resolve;
|
||||
import { statSync } from 'node:fs';
|
||||
import { basename, dirname, extname, join, resolve } from 'node:path';
|
||||
function tryStat(path) {
|
||||
try {
|
||||
return statSync(path);
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initialize a new `View` with the given `name`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `defaultEngine` the default template engine name
|
||||
* - `engines` template engine require() cache
|
||||
* - `root` root path for view lookup
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @public
|
||||
*/
|
||||
export class View {
|
||||
constructor(name, opts = {}) {
|
||||
var _a, _b;
|
||||
_View_instances.add(this);
|
||||
this.root = [];
|
||||
this.ext = extname(name);
|
||||
this.name = name;
|
||||
if (opts.root)
|
||||
this.root = opts.root;
|
||||
if (opts.defaultEngine)
|
||||
this.defaultEngine = opts.defaultEngine;
|
||||
if (!this.ext && !this.defaultEngine)
|
||||
throw new Error('No default engine was specified and no extension was provided.');
|
||||
let fileName = name;
|
||||
if (!this.ext) {
|
||||
// get extension from default engine name
|
||||
this.ext = ((_a = this.defaultEngine) === null || _a === void 0 ? void 0 : _a[0]) !== '.' ? `.${this.defaultEngine}` : this.defaultEngine;
|
||||
fileName += this.ext;
|
||||
}
|
||||
if (!((_b = opts.engines) === null || _b === void 0 ? void 0 : _b[this.ext]))
|
||||
throw new Error(`No engine was found for ${this.ext}`);
|
||||
const path = __classPrivateFieldGet(this, _View_instances, "m", _View_lookup).call(this, fileName);
|
||||
const dirs = Array.isArray(this.root) && this.root.length > 1
|
||||
? `directories "${this.root.slice(0, -1).join('", "')}" or "${this.root[this.root.length - 1]}"`
|
||||
: `directory "${this.root}"`;
|
||||
if (!path)
|
||||
throw new Error(`Failed to lookup view "${name}" in views ${dirs}`);
|
||||
this.engine = opts.engines[this.ext];
|
||||
this.path = path;
|
||||
}
|
||||
render(options, data, cb) {
|
||||
this.engine(this.path, data, options, cb);
|
||||
}
|
||||
}
|
||||
_View_instances = new WeakSet(), _View_lookup = function _View_lookup(name) {
|
||||
let path;
|
||||
const roots = [].concat(this.root);
|
||||
for (let i = 0; i < roots.length && !path; i++) {
|
||||
const root = roots[i];
|
||||
// resolve the path
|
||||
const loc = resolve(root, name);
|
||||
const dir = dirname(loc);
|
||||
const file = basename(loc);
|
||||
// resolve the file
|
||||
path = __classPrivateFieldGet(this, _View_instances, "m", _View_resolve).call(this, dir, file);
|
||||
}
|
||||
return path;
|
||||
}, _View_resolve = function _View_resolve(dir, file) {
|
||||
const ext = this.ext;
|
||||
// <path>.<ext>
|
||||
let path = join(dir, file);
|
||||
let stat = tryStat(path);
|
||||
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
// <path>/index.<ext>
|
||||
path = join(dir, basename(file, ext), `index${ext}`);
|
||||
stat = tryStat(path);
|
||||
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=view.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/app/dist/view.js.map
generated
vendored
Normal file
1
25_02_24/node_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