@mergehez/dokie-node 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/assets/dokie.html +889 -0
- package/dist/index.cjs +266 -0
- package/dist/index.d.cts +113 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.mjs +242 -0
- package/package.json +72 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let node_fs = require("node:fs");
|
|
25
|
+
node_fs = __toESM(node_fs);
|
|
26
|
+
let node_path = require("node:path");
|
|
27
|
+
node_path = __toESM(node_path);
|
|
28
|
+
const _coreExports = createDokieServerExports(node_path.default.resolve(__dirname, "../assets/dokie.html"), (assetPath) => node_fs.default.readFileSync(assetPath, "utf8"));
|
|
29
|
+
function normalizeFetchRequest(req) {
|
|
30
|
+
const url = new URL(req.url);
|
|
31
|
+
return {
|
|
32
|
+
get(name) {
|
|
33
|
+
return req.headers.get(name) ?? void 0;
|
|
34
|
+
},
|
|
35
|
+
header(name) {
|
|
36
|
+
return req.headers.get(name) ?? void 0;
|
|
37
|
+
},
|
|
38
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
39
|
+
hostname: url.host,
|
|
40
|
+
protocol: url.protocol.replace(/:$/, "")
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function forCustomServer() {
|
|
44
|
+
return {
|
|
45
|
+
createDokieHandler: _coreExports.createDokieHandler,
|
|
46
|
+
createDokieMiddleware: _coreExports.createDokieHandler,
|
|
47
|
+
getDokieAssetPath: _coreExports.getDokieAssetPath,
|
|
48
|
+
registerDokieRoute: _coreExports.registerDokieRoute,
|
|
49
|
+
renderDokieHtml: _coreExports.renderDokieHtml
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function forFetch() {
|
|
53
|
+
function renderDokieHtmlForFetch(options = {}, req) {
|
|
54
|
+
return _coreExports.renderDokieHtml(options, req ? normalizeFetchRequest(req) : void 0);
|
|
55
|
+
}
|
|
56
|
+
function createDokieHandlerForFetch(options = {}) {
|
|
57
|
+
return function dokieFetchHandler(req) {
|
|
58
|
+
const html = renderDokieHtmlForFetch(options, req);
|
|
59
|
+
return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
createDokieHandler: createDokieHandlerForFetch,
|
|
64
|
+
createDokieMiddleware: createDokieHandlerForFetch,
|
|
65
|
+
getDokieAssetPath: _coreExports.getDokieAssetPath,
|
|
66
|
+
renderDokieHtml: renderDokieHtmlForFetch
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function escapeHtml(value) {
|
|
70
|
+
return String(value).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
71
|
+
}
|
|
72
|
+
function safeJson(value) {
|
|
73
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
74
|
+
}
|
|
75
|
+
function trimTrailingSlash(value) {
|
|
76
|
+
return typeof value === "string" ? value.replace(/\/+$/, "") : value;
|
|
77
|
+
}
|
|
78
|
+
function getRequestHeader(req, name) {
|
|
79
|
+
if (!req) return;
|
|
80
|
+
if (typeof req.get === "function") return req.get(name);
|
|
81
|
+
if (typeof req.header === "function") return req.header(name);
|
|
82
|
+
const headers = req.headers ?? {};
|
|
83
|
+
const value = headers[name.toLowerCase()] ?? headers[name];
|
|
84
|
+
return Array.isArray(value) ? value[0] : value;
|
|
85
|
+
}
|
|
86
|
+
function getOpenApiJsonUrl(currentHostname, options = {}) {
|
|
87
|
+
const configuredUrl = options.openApiJsonUrl ?? "/openapi.json";
|
|
88
|
+
if (typeof configuredUrl !== "string" || configuredUrl.length === 0) return "/openapi.json";
|
|
89
|
+
if (/^[a-z]+:\/\//i.test(configuredUrl)) return configuredUrl;
|
|
90
|
+
if (configuredUrl.startsWith("/") && currentHostname) return `${currentHostname}${configuredUrl}`;
|
|
91
|
+
return configuredUrl;
|
|
92
|
+
}
|
|
93
|
+
function buildDokieConfig(options = {}, req) {
|
|
94
|
+
const getProtocol = () => {
|
|
95
|
+
if (!req) return "http";
|
|
96
|
+
if (typeof req.protocol === "string" && req.protocol.length > 0) return req.protocol;
|
|
97
|
+
const forwardedProto = getRequestHeader(req, "x-forwarded-proto");
|
|
98
|
+
if (typeof forwardedProto === "string" && forwardedProto.length > 0) return forwardedProto.split(",")[0].trim();
|
|
99
|
+
if (req.socket?.encrypted || req.connection?.encrypted) return "https";
|
|
100
|
+
return "http";
|
|
101
|
+
};
|
|
102
|
+
const currentHost = (() => {
|
|
103
|
+
if (!req) return;
|
|
104
|
+
if (typeof req.hostname === "string" && req.hostname.length > 0) {
|
|
105
|
+
const port = req.socket?.localPort;
|
|
106
|
+
return req.hostname.includes(":") || !port ? req.hostname : `${req.hostname}:${port}`;
|
|
107
|
+
}
|
|
108
|
+
const forwardedHost = getRequestHeader(req, "x-forwarded-host");
|
|
109
|
+
if (typeof forwardedHost === "string" && forwardedHost.length > 0) return forwardedHost.split(",")[0].trim();
|
|
110
|
+
const host = getRequestHeader(req, "host");
|
|
111
|
+
return typeof host === "string" && host.length > 0 ? host : void 0;
|
|
112
|
+
})();
|
|
113
|
+
const currentHostname = typeof options.currentHostname === "string" && options.currentHostname.length > 0 ? trimTrailingSlash(options.currentHostname) ?? "" : currentHost ? `${getProtocol()}://${currentHost}` : "";
|
|
114
|
+
return {
|
|
115
|
+
currentHostname,
|
|
116
|
+
openApiJsonUrl: getOpenApiJsonUrl(currentHostname, options),
|
|
117
|
+
hostnames: Array.isArray(options.hostnames) && options.hostnames.length > 0 ? options.hostnames : currentHostname ? [currentHostname] : [],
|
|
118
|
+
variables: options.variables ?? {},
|
|
119
|
+
headers: options.headers ?? {},
|
|
120
|
+
postscripts: options.postscripts ?? {},
|
|
121
|
+
bodies: options.bodies ?? {},
|
|
122
|
+
favorites: options.favorites ?? []
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function sendHtml(res, html) {
|
|
126
|
+
if (!res) throw new TypeError("A response object is required.");
|
|
127
|
+
if (typeof res.type === "function") res.type("html");
|
|
128
|
+
if (typeof res.setHeader === "function") res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
129
|
+
if (typeof res.send === "function") return res.send(html);
|
|
130
|
+
if (typeof res.end === "function") return res.end(html);
|
|
131
|
+
throw new TypeError("The response object must support send() or end().");
|
|
132
|
+
}
|
|
133
|
+
function createDokieServerExports(defaultAssetPath, readAsset) {
|
|
134
|
+
function getDokieAssetPath() {
|
|
135
|
+
return defaultAssetPath;
|
|
136
|
+
}
|
|
137
|
+
function renderDokieHtml(options = {}, req) {
|
|
138
|
+
const html = readAsset(options.assetPath ?? defaultAssetPath);
|
|
139
|
+
const dokieConfig = buildDokieConfig(options, req);
|
|
140
|
+
const finalHtml = html.replace("/*dokie-inject-area*/", `window.dokie = ${safeJson(dokieConfig)};`);
|
|
141
|
+
if (typeof options.title === "string" && options.title.trim().length > 0) return finalHtml.replace("<title>Dokie</title>", `<title>${escapeHtml(options.title)}</title>`);
|
|
142
|
+
return finalHtml;
|
|
143
|
+
}
|
|
144
|
+
function createDokieHandler(options = {}) {
|
|
145
|
+
return function dokieHandler(req, res) {
|
|
146
|
+
return sendHtml(res, renderDokieHtml(options, req));
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function registerDokieRoute(app, options = {}) {
|
|
150
|
+
if (!app || typeof app.get !== "function") throw new TypeError("registerDokieRoute expects an app with a get(path, handler) method.");
|
|
151
|
+
const routePath = options.routePath ?? "/dokie";
|
|
152
|
+
const handler = createDokieHandler(options);
|
|
153
|
+
app.get(routePath, handler);
|
|
154
|
+
return handler;
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
createDokieHandler,
|
|
158
|
+
createDokieMiddleware: createDokieHandler,
|
|
159
|
+
getDokieAssetPath,
|
|
160
|
+
registerDokieRoute,
|
|
161
|
+
renderDokieHtml
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/express.ts
|
|
166
|
+
function forExpress() {
|
|
167
|
+
return {
|
|
168
|
+
createDokieHandler: _coreExports.createDokieHandler,
|
|
169
|
+
createDokieMiddleware: _coreExports.createDokieHandler,
|
|
170
|
+
getDokieAssetPath: _coreExports.getDokieAssetPath,
|
|
171
|
+
registerDokieRoute: _coreExports.registerDokieRoute,
|
|
172
|
+
renderDokieHtml: _coreExports.renderDokieHtml
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/fastify.ts
|
|
177
|
+
function forFastify() {
|
|
178
|
+
function normalizeFastifyRequest(req) {
|
|
179
|
+
const header = (name) => {
|
|
180
|
+
const rawHeader = req.raw?.header?.(name);
|
|
181
|
+
if (typeof rawHeader === "string" && rawHeader.length > 0) return rawHeader;
|
|
182
|
+
const directHeader = req.header?.(name);
|
|
183
|
+
if (typeof directHeader === "string" && directHeader.length > 0) return directHeader;
|
|
184
|
+
const headers = req.headers ?? req.raw?.headers;
|
|
185
|
+
const value = headers?.[name.toLowerCase()] ?? headers?.[name];
|
|
186
|
+
return Array.isArray(value) ? value[0] : value;
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
connection: req.raw?.connection,
|
|
190
|
+
get: req.raw?.get?.bind(req.raw),
|
|
191
|
+
header,
|
|
192
|
+
headers: req.headers ?? req.raw?.headers,
|
|
193
|
+
hostname: req.hostname ?? req.raw?.hostname,
|
|
194
|
+
protocol: req.protocol ?? req.raw?.protocol,
|
|
195
|
+
socket: req.raw?.socket
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const renderDokieHtmlForFastify = (options = {}, req) => {
|
|
199
|
+
return _coreExports.renderDokieHtml(options, req ? normalizeFastifyRequest(req) : void 0);
|
|
200
|
+
};
|
|
201
|
+
function createDokieHandlerForFastify(options = {}) {
|
|
202
|
+
return function dokieFastifyHandler(req, reply) {
|
|
203
|
+
const html = renderDokieHtmlForFastify(options, req);
|
|
204
|
+
if (typeof reply.type === "function") reply.type("text/html; charset=utf-8");
|
|
205
|
+
if (typeof reply.header === "function") reply.header("Content-Type", "text/html; charset=utf-8");
|
|
206
|
+
if (typeof reply.send === "function") return reply.send(html);
|
|
207
|
+
throw new TypeError("The Fastify reply object must support send().");
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
createDokieHandler: createDokieHandlerForFastify,
|
|
212
|
+
createDokieMiddleware: createDokieHandlerForFastify,
|
|
213
|
+
getDokieAssetPath: _coreExports.getDokieAssetPath,
|
|
214
|
+
renderDokieHtml: renderDokieHtmlForFastify,
|
|
215
|
+
registerDokieRoute(app, options = {}) {
|
|
216
|
+
if (!app || typeof app.get !== "function") throw new TypeError("registerDokieRoute expects a Fastify instance with a get(path, handler) method.");
|
|
217
|
+
const routePath = options.routePath ?? "/dokie";
|
|
218
|
+
const handler = createDokieHandlerForFastify(options);
|
|
219
|
+
app.get(routePath, handler);
|
|
220
|
+
return handler;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/hono.ts
|
|
226
|
+
function forHono() {
|
|
227
|
+
function normalizeHonoRequest(req) {
|
|
228
|
+
const url = new URL(req.url);
|
|
229
|
+
return {
|
|
230
|
+
get: req.get?.bind(req),
|
|
231
|
+
header: req.header?.bind(req),
|
|
232
|
+
headers: req.raw ? Object.fromEntries(req.raw.headers.entries()) : void 0,
|
|
233
|
+
hostname: url.host,
|
|
234
|
+
protocol: url.protocol.replace(/:$/, "")
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function renderDokieHtmlForHono(options = {}, req) {
|
|
238
|
+
return _coreExports.renderDokieHtml(options, req ? normalizeHonoRequest(req) : void 0);
|
|
239
|
+
}
|
|
240
|
+
function createDokieHandlerForHono(options = {}) {
|
|
241
|
+
return function dokieHonoHandler(context) {
|
|
242
|
+
const html = renderDokieHtmlForHono(options, context.req);
|
|
243
|
+
if (typeof context.html === "function") return context.html(html);
|
|
244
|
+
return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
createDokieHandler: createDokieHandlerForHono,
|
|
249
|
+
createDokieMiddleware: createDokieHandlerForHono,
|
|
250
|
+
getDokieAssetPath: _coreExports.getDokieAssetPath,
|
|
251
|
+
renderDokieHtml: renderDokieHtmlForHono,
|
|
252
|
+
registerDokieRoute(app, options = {}) {
|
|
253
|
+
if (!app || typeof app.get !== "function") throw new TypeError("registerDokieRoute expects a Hono app with a get(path, handler) method.");
|
|
254
|
+
const routePath = options.routePath ?? "/dokie";
|
|
255
|
+
const handler = createDokieHandlerForHono(options);
|
|
256
|
+
app.get(routePath, handler);
|
|
257
|
+
return handler;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
exports.forCustomServer = forCustomServer;
|
|
263
|
+
exports.forExpress = forExpress;
|
|
264
|
+
exports.forFastify = forFastify;
|
|
265
|
+
exports.forFetch = forFetch;
|
|
266
|
+
exports.forHono = forHono;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//#region src/base.d.ts
|
|
2
|
+
type DokieRequestLike = {
|
|
3
|
+
connection?: {
|
|
4
|
+
encrypted?: boolean;
|
|
5
|
+
};
|
|
6
|
+
get?(name: string): string | undefined;
|
|
7
|
+
header?(name: string): string | undefined;
|
|
8
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
9
|
+
hostname?: string;
|
|
10
|
+
protocol?: string;
|
|
11
|
+
socket?: {
|
|
12
|
+
encrypted?: boolean;
|
|
13
|
+
localPort?: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type DokieResponseLike = {
|
|
17
|
+
end?(chunk?: string): unknown;
|
|
18
|
+
send?(body: string): unknown;
|
|
19
|
+
setHeader?(name: string, value: string): unknown;
|
|
20
|
+
type?(value: string): unknown;
|
|
21
|
+
};
|
|
22
|
+
type DokieAppLike = {
|
|
23
|
+
get(path: string, handler: (req: DokieRequestLike, res: DokieResponseLike) => unknown): unknown;
|
|
24
|
+
};
|
|
25
|
+
type DokieFetchRequestLike = Request;
|
|
26
|
+
type DokieOptions = {
|
|
27
|
+
bodies?: Record<string, string>;
|
|
28
|
+
currentHostname?: string;
|
|
29
|
+
favorites?: string[];
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
hostnames?: string[];
|
|
32
|
+
openApiJsonUrl?: string;
|
|
33
|
+
postscripts?: Record<string, string>;
|
|
34
|
+
title?: string;
|
|
35
|
+
variables?: Record<string, string>;
|
|
36
|
+
assetPath?: string;
|
|
37
|
+
routePath?: string;
|
|
38
|
+
};
|
|
39
|
+
declare function forCustomServer(): {
|
|
40
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
41
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
42
|
+
getDokieAssetPath: () => string;
|
|
43
|
+
registerDokieRoute: (app: DokieAppLike, options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
44
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieRequestLike) => string;
|
|
45
|
+
};
|
|
46
|
+
declare function forFetch(): {
|
|
47
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieFetchRequestLike) => Response;
|
|
48
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieFetchRequestLike) => Response;
|
|
49
|
+
getDokieAssetPath: () => string;
|
|
50
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieFetchRequestLike) => string;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/express.d.ts
|
|
54
|
+
declare function forExpress(): {
|
|
55
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
56
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
57
|
+
getDokieAssetPath: () => string;
|
|
58
|
+
registerDokieRoute: (app: DokieAppLike, options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
59
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieRequestLike) => string;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/fastify.d.ts
|
|
63
|
+
type FastifyRawRequestLike = DokieRequestLike & {
|
|
64
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
65
|
+
hostname?: string;
|
|
66
|
+
protocol?: string;
|
|
67
|
+
};
|
|
68
|
+
type FastifyRequestLike = {
|
|
69
|
+
header?(name: string): string | undefined;
|
|
70
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
71
|
+
hostname?: string;
|
|
72
|
+
protocol?: string;
|
|
73
|
+
raw?: FastifyRawRequestLike;
|
|
74
|
+
};
|
|
75
|
+
type FastifyReplyLike = {
|
|
76
|
+
header?(name: string, value: string): unknown;
|
|
77
|
+
send?(body: string): unknown;
|
|
78
|
+
type?(value: string): unknown;
|
|
79
|
+
};
|
|
80
|
+
type FastifyInstanceLike = {
|
|
81
|
+
get(path: string, handler: (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown): unknown;
|
|
82
|
+
};
|
|
83
|
+
declare function forFastify(): {
|
|
84
|
+
createDokieHandler: (options?: DokieOptions) => (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
85
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
86
|
+
getDokieAssetPath: () => string;
|
|
87
|
+
renderDokieHtml: (options?: DokieOptions, req?: FastifyRequestLike) => string;
|
|
88
|
+
registerDokieRoute(app: FastifyInstanceLike, options?: DokieOptions): (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/hono.d.ts
|
|
92
|
+
type HonoRequestLike = {
|
|
93
|
+
get?(name: string): string | undefined;
|
|
94
|
+
header?(name: string): string | undefined;
|
|
95
|
+
raw?: Request;
|
|
96
|
+
url: string;
|
|
97
|
+
};
|
|
98
|
+
type HonoContextLike = {
|
|
99
|
+
html?(html: string, status?: number): unknown;
|
|
100
|
+
req: HonoRequestLike;
|
|
101
|
+
};
|
|
102
|
+
type HonoAppLike = {
|
|
103
|
+
get(path: string, handler: (context: HonoContextLike) => unknown): unknown;
|
|
104
|
+
};
|
|
105
|
+
declare function forHono(): {
|
|
106
|
+
createDokieHandler: (options?: DokieOptions) => (context: HonoContextLike) => unknown;
|
|
107
|
+
createDokieMiddleware: (options?: DokieOptions) => (context: HonoContextLike) => unknown;
|
|
108
|
+
getDokieAssetPath: () => string;
|
|
109
|
+
renderDokieHtml: (options?: DokieOptions, req?: HonoRequestLike) => string;
|
|
110
|
+
registerDokieRoute(app: HonoAppLike, options?: DokieOptions): (context: HonoContextLike) => unknown;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { type DokieAppLike, type DokieFetchRequestLike, type DokieOptions, type DokieRequestLike, type DokieResponseLike, forCustomServer, forExpress, forFastify, forFetch, forHono };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//#region src/base.d.ts
|
|
2
|
+
type DokieRequestLike = {
|
|
3
|
+
connection?: {
|
|
4
|
+
encrypted?: boolean;
|
|
5
|
+
};
|
|
6
|
+
get?(name: string): string | undefined;
|
|
7
|
+
header?(name: string): string | undefined;
|
|
8
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
9
|
+
hostname?: string;
|
|
10
|
+
protocol?: string;
|
|
11
|
+
socket?: {
|
|
12
|
+
encrypted?: boolean;
|
|
13
|
+
localPort?: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type DokieResponseLike = {
|
|
17
|
+
end?(chunk?: string): unknown;
|
|
18
|
+
send?(body: string): unknown;
|
|
19
|
+
setHeader?(name: string, value: string): unknown;
|
|
20
|
+
type?(value: string): unknown;
|
|
21
|
+
};
|
|
22
|
+
type DokieAppLike = {
|
|
23
|
+
get(path: string, handler: (req: DokieRequestLike, res: DokieResponseLike) => unknown): unknown;
|
|
24
|
+
};
|
|
25
|
+
type DokieFetchRequestLike = Request;
|
|
26
|
+
type DokieOptions = {
|
|
27
|
+
bodies?: Record<string, string>;
|
|
28
|
+
currentHostname?: string;
|
|
29
|
+
favorites?: string[];
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
hostnames?: string[];
|
|
32
|
+
openApiJsonUrl?: string;
|
|
33
|
+
postscripts?: Record<string, string>;
|
|
34
|
+
title?: string;
|
|
35
|
+
variables?: Record<string, string>;
|
|
36
|
+
assetPath?: string;
|
|
37
|
+
routePath?: string;
|
|
38
|
+
};
|
|
39
|
+
declare function forCustomServer(): {
|
|
40
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
41
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
42
|
+
getDokieAssetPath: () => string;
|
|
43
|
+
registerDokieRoute: (app: DokieAppLike, options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
44
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieRequestLike) => string;
|
|
45
|
+
};
|
|
46
|
+
declare function forFetch(): {
|
|
47
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieFetchRequestLike) => Response;
|
|
48
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieFetchRequestLike) => Response;
|
|
49
|
+
getDokieAssetPath: () => string;
|
|
50
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieFetchRequestLike) => string;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/express.d.ts
|
|
54
|
+
declare function forExpress(): {
|
|
55
|
+
createDokieHandler: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
56
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
57
|
+
getDokieAssetPath: () => string;
|
|
58
|
+
registerDokieRoute: (app: DokieAppLike, options?: DokieOptions) => (req: DokieRequestLike, res: DokieResponseLike) => unknown;
|
|
59
|
+
renderDokieHtml: (options?: DokieOptions, req?: DokieRequestLike) => string;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/fastify.d.ts
|
|
63
|
+
type FastifyRawRequestLike = DokieRequestLike & {
|
|
64
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
65
|
+
hostname?: string;
|
|
66
|
+
protocol?: string;
|
|
67
|
+
};
|
|
68
|
+
type FastifyRequestLike = {
|
|
69
|
+
header?(name: string): string | undefined;
|
|
70
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
71
|
+
hostname?: string;
|
|
72
|
+
protocol?: string;
|
|
73
|
+
raw?: FastifyRawRequestLike;
|
|
74
|
+
};
|
|
75
|
+
type FastifyReplyLike = {
|
|
76
|
+
header?(name: string, value: string): unknown;
|
|
77
|
+
send?(body: string): unknown;
|
|
78
|
+
type?(value: string): unknown;
|
|
79
|
+
};
|
|
80
|
+
type FastifyInstanceLike = {
|
|
81
|
+
get(path: string, handler: (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown): unknown;
|
|
82
|
+
};
|
|
83
|
+
declare function forFastify(): {
|
|
84
|
+
createDokieHandler: (options?: DokieOptions) => (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
85
|
+
createDokieMiddleware: (options?: DokieOptions) => (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
86
|
+
getDokieAssetPath: () => string;
|
|
87
|
+
renderDokieHtml: (options?: DokieOptions, req?: FastifyRequestLike) => string;
|
|
88
|
+
registerDokieRoute(app: FastifyInstanceLike, options?: DokieOptions): (req: FastifyRequestLike, reply: FastifyReplyLike) => unknown;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/hono.d.ts
|
|
92
|
+
type HonoRequestLike = {
|
|
93
|
+
get?(name: string): string | undefined;
|
|
94
|
+
header?(name: string): string | undefined;
|
|
95
|
+
raw?: Request;
|
|
96
|
+
url: string;
|
|
97
|
+
};
|
|
98
|
+
type HonoContextLike = {
|
|
99
|
+
html?(html: string, status?: number): unknown;
|
|
100
|
+
req: HonoRequestLike;
|
|
101
|
+
};
|
|
102
|
+
type HonoAppLike = {
|
|
103
|
+
get(path: string, handler: (context: HonoContextLike) => unknown): unknown;
|
|
104
|
+
};
|
|
105
|
+
declare function forHono(): {
|
|
106
|
+
createDokieHandler: (options?: DokieOptions) => (context: HonoContextLike) => unknown;
|
|
107
|
+
createDokieMiddleware: (options?: DokieOptions) => (context: HonoContextLike) => unknown;
|
|
108
|
+
getDokieAssetPath: () => string;
|
|
109
|
+
renderDokieHtml: (options?: DokieOptions, req?: HonoRequestLike) => string;
|
|
110
|
+
registerDokieRoute(app: HonoAppLike, options?: DokieOptions): (context: HonoContextLike) => unknown;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { type DokieAppLike, type DokieFetchRequestLike, type DokieOptions, type DokieRequestLike, type DokieResponseLike, forCustomServer, forExpress, forFastify, forFetch, forHono };
|