@cvfile/server 0.1.0
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 +190 -0
- package/dist/express.cjs +254 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +7 -0
- package/dist/express.d.ts +7 -0
- package/dist/express.js +252 -0
- package/dist/express.js.map +1 -0
- package/dist/fastify.cjs +255 -0
- package/dist/fastify.cjs.map +1 -0
- package/dist/fastify.d.cts +10 -0
- package/dist/fastify.d.ts +10 -0
- package/dist/fastify.js +250 -0
- package/dist/fastify.js.map +1 -0
- package/dist/handler-DGnThUpM.d.cts +12 -0
- package/dist/handler-DGnThUpM.d.ts +12 -0
- package/dist/hono.cjs +190 -0
- package/dist/hono.cjs.map +1 -0
- package/dist/hono.d.cts +9 -0
- package/dist/hono.d.ts +9 -0
- package/dist/hono.js +188 -0
- package/dist/hono.js.map +1 -0
- package/dist/index.cjs +246 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +237 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { stat, readFile } from 'fs/promises';
|
|
2
|
+
import { resolve, normalize, sep } from 'path';
|
|
3
|
+
import { extract, isCvFile } from '@cvfile/sdk';
|
|
4
|
+
|
|
5
|
+
// src/handler.ts
|
|
6
|
+
|
|
7
|
+
// src/conneg.ts
|
|
8
|
+
var FORMAT_BY_MIME = {
|
|
9
|
+
"text/markdown": "markdown",
|
|
10
|
+
"text/x-markdown": "markdown",
|
|
11
|
+
"text/html": "html",
|
|
12
|
+
"application/xhtml+xml": "html",
|
|
13
|
+
"application/pdf": "pdf",
|
|
14
|
+
"application/vnd.cv+pdf": "pdf"
|
|
15
|
+
};
|
|
16
|
+
var FORMAT_BY_QUERY = {
|
|
17
|
+
md: "markdown",
|
|
18
|
+
markdown: "markdown",
|
|
19
|
+
html: "html",
|
|
20
|
+
pdf: "pdf",
|
|
21
|
+
cv: "pdf"
|
|
22
|
+
};
|
|
23
|
+
function parseAccept(header) {
|
|
24
|
+
if (!header) return [];
|
|
25
|
+
return header.split(",").map((part) => {
|
|
26
|
+
const [type, ...params] = part.trim().split(";").map((s) => s.trim());
|
|
27
|
+
let q = 1;
|
|
28
|
+
for (const p of params) {
|
|
29
|
+
const m = p.match(/^q\s*=\s*(\d*\.?\d+)/i);
|
|
30
|
+
if (m) q = Number(m[1]);
|
|
31
|
+
}
|
|
32
|
+
return { type: (type ?? "").toLowerCase(), q };
|
|
33
|
+
}).filter((p) => p.type).sort((a, b) => b.q - a.q);
|
|
34
|
+
}
|
|
35
|
+
function parseAcceptLanguage(header) {
|
|
36
|
+
if (!header) return [];
|
|
37
|
+
return header.split(",").map((part) => {
|
|
38
|
+
const [tag, ...params] = part.trim().split(";").map((s) => s.trim());
|
|
39
|
+
let q = 1;
|
|
40
|
+
for (const p of params) {
|
|
41
|
+
const m = p.match(/^q\s*=\s*(\d*\.?\d+)/i);
|
|
42
|
+
if (m) q = Number(m[1]);
|
|
43
|
+
}
|
|
44
|
+
return { tag: (tag ?? "").toLowerCase(), q };
|
|
45
|
+
}).filter((p) => p.tag && p.tag !== "*").sort((a, b) => b.q - a.q).map((p) => p.tag);
|
|
46
|
+
}
|
|
47
|
+
function negotiate(input) {
|
|
48
|
+
const language = parseAcceptLanguage(input.acceptLanguage)[0];
|
|
49
|
+
if (input.formatQuery) {
|
|
50
|
+
const fromQuery = FORMAT_BY_QUERY[input.formatQuery.toLowerCase()];
|
|
51
|
+
if (fromQuery) {
|
|
52
|
+
return { format: fromQuery, language };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const accepts = parseAccept(input.accept);
|
|
56
|
+
for (const a of accepts) {
|
|
57
|
+
const direct = FORMAT_BY_MIME[a.type];
|
|
58
|
+
if (direct) {
|
|
59
|
+
return { format: direct, language };
|
|
60
|
+
}
|
|
61
|
+
if (a.type === "*/*" || a.type === "application/*") {
|
|
62
|
+
return { format: "pdf", language };
|
|
63
|
+
}
|
|
64
|
+
if (a.type === "text/*") {
|
|
65
|
+
return { format: "html", language };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { format: "pdf", language };
|
|
69
|
+
}
|
|
70
|
+
function buildLinkHeader({ selfUrl, cvMime = "application/vnd.cv+pdf" }) {
|
|
71
|
+
const sep2 = selfUrl.includes("?") ? "&" : "?";
|
|
72
|
+
return [
|
|
73
|
+
`<${selfUrl}>; rel="alternate"; type="${cvMime}"`,
|
|
74
|
+
`<${selfUrl}${sep2}format=md>; rel="alternate"; type="text/markdown"`,
|
|
75
|
+
`<${selfUrl}${sep2}format=html>; rel="alternate"; type="text/html"`
|
|
76
|
+
].join(", ");
|
|
77
|
+
}
|
|
78
|
+
var PDF_PRIMARY_MIME = "application/vnd.cv+pdf";
|
|
79
|
+
var PDF_FALLBACK_MIME = "application/pdf";
|
|
80
|
+
var ENCODER = new TextEncoder();
|
|
81
|
+
async function serveCv(req) {
|
|
82
|
+
const decision = negotiate({
|
|
83
|
+
accept: req.accept,
|
|
84
|
+
acceptLanguage: req.acceptLanguage,
|
|
85
|
+
formatQuery: req.formatQuery
|
|
86
|
+
});
|
|
87
|
+
if (decision.format === "pdf") {
|
|
88
|
+
return {
|
|
89
|
+
format: "pdf",
|
|
90
|
+
contentType: "application/vnd.cv+pdf",
|
|
91
|
+
...decision.language !== void 0 ? { language: decision.language } : {},
|
|
92
|
+
body: req.bytes
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const file = await extract(req.bytes);
|
|
96
|
+
const preferLang = decision.language ?? file.metadata.primaryLanguage;
|
|
97
|
+
if (decision.format === "markdown") {
|
|
98
|
+
const md = pickPayload(file, "text/markdown", preferLang);
|
|
99
|
+
if (md) {
|
|
100
|
+
return {
|
|
101
|
+
format: "markdown",
|
|
102
|
+
contentType: `text/markdown; charset=utf-8; cv-language=${md.language ?? preferLang}`,
|
|
103
|
+
...md.language !== void 0 ? { language: md.language } : {},
|
|
104
|
+
body: md.bytes
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return fallbackToPdf(req.bytes);
|
|
108
|
+
}
|
|
109
|
+
if (decision.format === "html") {
|
|
110
|
+
const html = pickPayload(file, "text/html", preferLang);
|
|
111
|
+
if (html) {
|
|
112
|
+
return {
|
|
113
|
+
format: "html",
|
|
114
|
+
contentType: `text/html; charset=utf-8; cv-language=${html.language ?? preferLang}`,
|
|
115
|
+
...html.language !== void 0 ? { language: html.language } : {},
|
|
116
|
+
body: html.bytes
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const md = pickPayload(file, "text/markdown", preferLang);
|
|
120
|
+
if (md) {
|
|
121
|
+
const body = ENCODER.encode(renderMarkdownAsHtml(md.text(), file));
|
|
122
|
+
return {
|
|
123
|
+
format: "html",
|
|
124
|
+
contentType: "text/html; charset=utf-8",
|
|
125
|
+
...md.language !== void 0 ? { language: md.language } : {},
|
|
126
|
+
body
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return fallbackToPdf(req.bytes);
|
|
130
|
+
}
|
|
131
|
+
return fallbackToPdf(req.bytes);
|
|
132
|
+
}
|
|
133
|
+
function pickPayload(file, mimeType, preferLang) {
|
|
134
|
+
const matches = file.payloads.filter((p) => p.mimeType === mimeType);
|
|
135
|
+
if (matches.length === 0) return void 0;
|
|
136
|
+
return matches.find((p) => p.language === preferLang) ?? matches[0];
|
|
137
|
+
}
|
|
138
|
+
function fallbackToPdf(bytes) {
|
|
139
|
+
return { format: "pdf", contentType: "application/vnd.cv+pdf", body: bytes };
|
|
140
|
+
}
|
|
141
|
+
function renderMarkdownAsHtml(md, file) {
|
|
142
|
+
const safe = md.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
143
|
+
return `<!doctype html>
|
|
144
|
+
<html lang="${file.metadata.primaryLanguage}">
|
|
145
|
+
<head>
|
|
146
|
+
<meta charset="utf-8">
|
|
147
|
+
<title>${file.metadata.primaryPayload}</title>
|
|
148
|
+
</head>
|
|
149
|
+
<body>
|
|
150
|
+
<pre>${safe}</pre>
|
|
151
|
+
</body>
|
|
152
|
+
</html>`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/handler.ts
|
|
156
|
+
function cvHandler(options = {}) {
|
|
157
|
+
const { root, loader, cacheControl = "public, max-age=300", defaultFormat } = options;
|
|
158
|
+
if (!root && !loader) {
|
|
159
|
+
throw new Error("cvHandler requires either { root } or { loader }");
|
|
160
|
+
}
|
|
161
|
+
const baseRoot = root ? resolve(root) : null;
|
|
162
|
+
return async (req, res) => {
|
|
163
|
+
try {
|
|
164
|
+
const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
165
|
+
const logical = decodeURIComponent(url.pathname);
|
|
166
|
+
const formatQuery = url.searchParams.get("format") ?? defaultFormat;
|
|
167
|
+
const bytes = await load(logical, { baseRoot, loader });
|
|
168
|
+
if (!bytes) {
|
|
169
|
+
res.statusCode = 404;
|
|
170
|
+
res.end("Not found");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!await isCvFile(bytes)) {
|
|
174
|
+
res.statusCode = 415;
|
|
175
|
+
res.end("Not a .cv file");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const result = await serveCv({
|
|
179
|
+
bytes,
|
|
180
|
+
accept: req.headers["accept"],
|
|
181
|
+
acceptLanguage: req.headers["accept-language"],
|
|
182
|
+
formatQuery: formatQuery ?? void 0
|
|
183
|
+
});
|
|
184
|
+
const link = buildLinkHeader({ selfUrl: url.pathname, cvMime: PDF_PRIMARY_MIME });
|
|
185
|
+
res.setHeader("Content-Type", result.contentType);
|
|
186
|
+
res.setHeader("Content-Length", String(result.body.length));
|
|
187
|
+
res.setHeader("Vary", "Accept, Accept-Language");
|
|
188
|
+
res.setHeader("Link", link);
|
|
189
|
+
res.setHeader("Cache-Control", cacheControl);
|
|
190
|
+
if (result.language) {
|
|
191
|
+
res.setHeader("Content-Language", result.language);
|
|
192
|
+
}
|
|
193
|
+
const filename = filenameForFormat(logical, result.format);
|
|
194
|
+
res.setHeader("Content-Disposition", `inline; filename="${filename}"`);
|
|
195
|
+
res.statusCode = 200;
|
|
196
|
+
res.end(Buffer.from(result.body));
|
|
197
|
+
} catch (err) {
|
|
198
|
+
res.statusCode = 500;
|
|
199
|
+
res.end(`cvHandler error: ${err.message}`);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async function load(logicalPath, { baseRoot, loader }) {
|
|
204
|
+
if (loader) {
|
|
205
|
+
const bytes = await loader(logicalPath);
|
|
206
|
+
return bytes ?? null;
|
|
207
|
+
}
|
|
208
|
+
if (!baseRoot) return null;
|
|
209
|
+
const safe = normalize(logicalPath).replace(/^[/\\]+/, "");
|
|
210
|
+
const full = resolve(baseRoot, safe);
|
|
211
|
+
if (!isWithin(baseRoot, full)) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const s = await stat(full);
|
|
216
|
+
if (!s.isFile()) return null;
|
|
217
|
+
return new Uint8Array(await readFile(full));
|
|
218
|
+
} catch {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function isWithin(parent, child) {
|
|
223
|
+
const rel = resolve(child);
|
|
224
|
+
const base = resolve(parent);
|
|
225
|
+
return rel === base || rel.startsWith(base + sep);
|
|
226
|
+
}
|
|
227
|
+
function filenameForFormat(logical, format) {
|
|
228
|
+
const base = logical.split("/").pop() ?? "document";
|
|
229
|
+
const stem = base.replace(/\.cv$/i, "").replace(/\.(pdf|md|html)$/i, "") || "document";
|
|
230
|
+
if (format === "markdown") return `${stem}.md`;
|
|
231
|
+
if (format === "html") return `${stem}.html`;
|
|
232
|
+
return `${stem}.cv`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { PDF_FALLBACK_MIME, PDF_PRIMARY_MIME, buildLinkHeader, cvHandler, negotiate, parseAccept, parseAcceptLanguage, serveCv };
|
|
236
|
+
//# sourceMappingURL=index.js.map
|
|
237
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/conneg.ts","../src/serve.ts","../src/handler.ts"],"names":["sep"],"mappings":";;;;;;;AAaA,IAAM,cAAA,GAA8C;AAAA,EAClD,eAAA,EAAiB,UAAA;AAAA,EACjB,iBAAA,EAAmB,UAAA;AAAA,EACnB,WAAA,EAAa,MAAA;AAAA,EACb,uBAAA,EAAyB,MAAA;AAAA,EACzB,iBAAA,EAAmB,KAAA;AAAA,EACnB,wBAAA,EAA0B;AAC5B,CAAA;AAEA,IAAM,eAAA,GAA+C;AAAA,EACnD,EAAA,EAAI,UAAA;AAAA,EACJ,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,KAAA;AAAA,EACL,EAAA,EAAI;AACN,CAAA;AAOO,SAAS,YAAY,MAAA,EAAmD;AAC7E,EAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,EAAC;AACrB,EAAA,OAAO,OACJ,KAAA,CAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KAAS;AACb,IAAA,MAAM,CAAC,IAAA,EAAM,GAAG,MAAM,CAAA,GAAI,KAAK,IAAA,EAAK,CAAE,KAAA,CAAM,GAAG,EAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,MAAM,CAAA;AACpE,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,KAAA,MAAW,KAAK,MAAA,EAAQ;AACtB,MAAA,MAAM,CAAA,GAAI,CAAA,CAAE,KAAA,CAAM,uBAAuB,CAAA;AACzC,MAAA,IAAI,CAAA,EAAG,CAAA,GAAI,MAAA,CAAO,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,IACxB;AACA,IAAA,OAAO,EAAE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A,CAAS,QAAA,EAAU,IAAI,CAAA,EAAG;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,MAAM,CAAA,GAAI,MAAM,IAAA,CAAK,IAAI,CAAA;AACzB,IAAA,IAAI,CAAC,CAAA,CAAE,MAAA,EAAO,EAAG,OAAO,IAAA;AACxB,IAAA,OAAO,IAAI,UAAA,CAAW,MAAM,QAAA,CAAS,IAAI,CAAC,CAAA;AAAA,EAC5C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAA,CAAS,QAAgB,KAAA,EAAwB;AACxD,EAAA,MAAM,GAAA,GAAM,QAAQ,KAAK,CAAA;AACzB,EAAA,MAAM,IAAA,GAAO,QAAQ,MAAM,CAAA;AAC3B,EAAA,OAAO,GAAA,KAAQ,IAAA,IAAQ,GAAA,CAAI,UAAA,CAAW,OAAO,GAAG,CAAA;AAClD;AAEA,SAAS,iBAAA,CAAkB,SAAiB,MAAA,EAA6C;AACvF,EAAA,MAAM,OAAO,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,KAAI,IAAK,UAAA;AACzC,EAAA,MAAM,IAAA,GAAO,KAAK,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA,CAAE,OAAA,CAAQ,mBAAA,EAAqB,EAAE,CAAA,IAAK,UAAA;AAC5E,EAAA,IAAI,MAAA,KAAW,UAAA,EAAY,OAAO,CAAA,EAAG,IAAI,CAAA,GAAA,CAAA;AACzC,EAAA,IAAI,MAAA,KAAW,MAAA,EAAQ,OAAO,CAAA,EAAG,IAAI,CAAA,KAAA,CAAA;AACrC,EAAA,OAAO,GAAG,IAAI,CAAA,GAAA,CAAA;AAChB","file":"index.js","sourcesContent":["export type ServeFormat = 'pdf' | 'markdown' | 'html';\n\nexport interface NegotiationInput {\n accept?: string | undefined;\n acceptLanguage?: string | undefined;\n formatQuery?: string | undefined;\n}\n\nexport interface NegotiationResult {\n format: ServeFormat;\n language: string | undefined;\n}\n\nconst FORMAT_BY_MIME: Record<string, ServeFormat> = {\n 'text/markdown': 'markdown',\n 'text/x-markdown': 'markdown',\n 'text/html': 'html',\n 'application/xhtml+xml': 'html',\n 'application/pdf': 'pdf',\n 'application/vnd.cv+pdf': 'pdf',\n};\n\nconst FORMAT_BY_QUERY: Record<string, ServeFormat> = {\n md: 'markdown',\n markdown: 'markdown',\n html: 'html',\n pdf: 'pdf',\n cv: 'pdf',\n};\n\ninterface ParsedAccept {\n type: string;\n q: number;\n}\n\nexport function parseAccept(header: string | undefined | null): ParsedAccept[] {\n if (!header) return [];\n return header\n .split(',')\n .map((part) => {\n const [type, ...params] = part.trim().split(';').map((s) => s.trim());\n let q = 1;\n for (const p of params) {\n const m = p.match(/^q\\s*=\\s*(\\d*\\.?\\d+)/i);\n if (m) q = Number(m[1]);\n }\n return { type: (type ?? '').toLowerCase(), q };\n })\n .filter((p) => p.type)\n .sort((a, b) => b.q - a.q);\n}\n\nexport function parseAcceptLanguage(header: string | undefined | null): string[] {\n if (!header) return [];\n return header\n .split(',')\n .map((part) => {\n const [tag, ...params] = part.trim().split(';').map((s) => s.trim());\n let q = 1;\n for (const p of params) {\n const m = p.match(/^q\\s*=\\s*(\\d*\\.?\\d+)/i);\n if (m) q = Number(m[1]);\n }\n return { tag: (tag ?? '').toLowerCase(), q };\n })\n .filter((p) => p.tag && p.tag !== '*')\n .sort((a, b) => b.q - a.q)\n .map((p) => p.tag);\n}\n\nexport function negotiate(input: NegotiationInput): NegotiationResult {\n const language = parseAcceptLanguage(input.acceptLanguage)[0];\n\n if (input.formatQuery) {\n const fromQuery = FORMAT_BY_QUERY[input.formatQuery.toLowerCase()];\n if (fromQuery) {\n return { format: fromQuery, language };\n }\n }\n\n const accepts = parseAccept(input.accept);\n for (const a of accepts) {\n const direct = FORMAT_BY_MIME[a.type];\n if (direct) {\n return { format: direct, language };\n }\n if (a.type === '*/*' || a.type === 'application/*') {\n return { format: 'pdf', language };\n }\n if (a.type === 'text/*') {\n return { format: 'html', language };\n }\n }\n\n return { format: 'pdf', language };\n}\n\nexport interface BuildLinkHeaderInput {\n selfUrl: string;\n cvMime?: string;\n}\n\nexport function buildLinkHeader({ selfUrl, cvMime = 'application/vnd.cv+pdf' }: BuildLinkHeaderInput): string {\n const sep = selfUrl.includes('?') ? '&' : '?';\n return [\n `<${selfUrl}>; rel=\"alternate\"; type=\"${cvMime}\"`,\n `<${selfUrl}${sep}format=md>; rel=\"alternate\"; type=\"text/markdown\"`,\n `<${selfUrl}${sep}format=html>; rel=\"alternate\"; type=\"text/html\"`,\n ].join(', ');\n}\n\nexport const PDF_PRIMARY_MIME = 'application/vnd.cv+pdf';\nexport const PDF_FALLBACK_MIME = 'application/pdf';\n","import { extract } from '@cvfile/sdk';\nimport type { CvFile, ExtractedPayload } from '@cvfile/sdk';\nimport { negotiate, type ServeFormat } from './conneg.js';\n\nexport interface ServeRequest {\n bytes: Uint8Array;\n accept?: string | undefined;\n acceptLanguage?: string | undefined;\n formatQuery?: string | undefined;\n}\n\nexport interface ServeResponse {\n format: ServeFormat;\n contentType: string;\n language?: string | undefined;\n body: Uint8Array;\n}\n\nconst ENCODER = new TextEncoder();\n\nexport async function serveCv(req: ServeRequest): Promise<ServeResponse> {\n const decision = negotiate({\n accept: req.accept,\n acceptLanguage: req.acceptLanguage,\n formatQuery: req.formatQuery,\n });\n\n if (decision.format === 'pdf') {\n return {\n format: 'pdf',\n contentType: 'application/vnd.cv+pdf',\n ...(decision.language !== undefined ? { language: decision.language } : {}),\n body: req.bytes,\n };\n }\n\n const file = await extract(req.bytes);\n const preferLang = decision.language ?? file.metadata.primaryLanguage;\n\n if (decision.format === 'markdown') {\n const md = pickPayload(file, 'text/markdown', preferLang);\n if (md) {\n return {\n format: 'markdown',\n contentType: `text/markdown; charset=utf-8; cv-language=${md.language ?? preferLang}`,\n ...(md.language !== undefined ? { language: md.language } : {}),\n body: md.bytes,\n };\n }\n return fallbackToPdf(req.bytes);\n }\n\n if (decision.format === 'html') {\n const html = pickPayload(file, 'text/html', preferLang);\n if (html) {\n return {\n format: 'html',\n contentType: `text/html; charset=utf-8; cv-language=${html.language ?? preferLang}`,\n ...(html.language !== undefined ? { language: html.language } : {}),\n body: html.bytes,\n };\n }\n const md = pickPayload(file, 'text/markdown', preferLang);\n if (md) {\n const body = ENCODER.encode(renderMarkdownAsHtml(md.text(), file));\n return {\n format: 'html',\n contentType: 'text/html; charset=utf-8',\n ...(md.language !== undefined ? { language: md.language } : {}),\n body,\n };\n }\n return fallbackToPdf(req.bytes);\n }\n\n return fallbackToPdf(req.bytes);\n}\n\nfunction pickPayload(file: CvFile, mimeType: string, preferLang: string): ExtractedPayload | undefined {\n const matches = file.payloads.filter((p) => p.mimeType === mimeType);\n if (matches.length === 0) return undefined;\n return matches.find((p) => p.language === preferLang) ?? matches[0];\n}\n\nfunction fallbackToPdf(bytes: Uint8Array): ServeResponse {\n return { format: 'pdf', contentType: 'application/vnd.cv+pdf', body: bytes };\n}\n\nfunction renderMarkdownAsHtml(md: string, file: CvFile): string {\n const safe = md\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n return `<!doctype html>\n<html lang=\"${file.metadata.primaryLanguage}\">\n<head>\n<meta charset=\"utf-8\">\n<title>${file.metadata.primaryPayload}</title>\n</head>\n<body>\n<pre>${safe}</pre>\n</body>\n</html>`;\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http';\nimport { readFile, stat } from 'node:fs/promises';\nimport { normalize, resolve, sep } from 'node:path';\nimport { isCvFile } from '@cvfile/sdk';\nimport { buildLinkHeader, PDF_PRIMARY_MIME } from './conneg.js';\nimport { serveCv } from './serve.js';\n\nexport interface CvHandlerOptions {\n root?: string;\n loader?: (logicalPath: string) => Promise<Uint8Array | null>;\n cacheControl?: string;\n defaultFormat?: 'pdf' | 'markdown' | 'html';\n}\n\nexport type CvHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;\n\nexport function cvHandler(options: CvHandlerOptions = {}): CvHandler {\n const { root, loader, cacheControl = 'public, max-age=300', defaultFormat } = options;\n if (!root && !loader) {\n throw new Error('cvHandler requires either { root } or { loader }');\n }\n\n const baseRoot = root ? resolve(root) : null;\n\n return async (req, res) => {\n try {\n const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);\n const logical = decodeURIComponent(url.pathname);\n const formatQuery = url.searchParams.get('format') ?? defaultFormat;\n\n const bytes = await load(logical, { baseRoot, loader });\n if (!bytes) {\n res.statusCode = 404;\n res.end('Not found');\n return;\n }\n\n if (!(await isCvFile(bytes))) {\n res.statusCode = 415;\n res.end('Not a .cv file');\n return;\n }\n\n const result = await serveCv({\n bytes,\n accept: req.headers['accept'],\n acceptLanguage: req.headers['accept-language'],\n formatQuery: formatQuery ?? undefined,\n });\n\n const link = buildLinkHeader({ selfUrl: url.pathname, cvMime: PDF_PRIMARY_MIME });\n\n res.setHeader('Content-Type', result.contentType);\n res.setHeader('Content-Length', String(result.body.length));\n res.setHeader('Vary', 'Accept, Accept-Language');\n res.setHeader('Link', link);\n res.setHeader('Cache-Control', cacheControl);\n if (result.language) {\n res.setHeader('Content-Language', result.language);\n }\n const filename = filenameForFormat(logical, result.format);\n res.setHeader('Content-Disposition', `inline; filename=\"${filename}\"`);\n res.statusCode = 200;\n res.end(Buffer.from(result.body));\n } catch (err) {\n res.statusCode = 500;\n res.end(`cvHandler error: ${(err as Error).message}`);\n }\n };\n}\n\ninterface LoadOpts {\n baseRoot: string | null;\n loader?: ((logicalPath: string) => Promise<Uint8Array | null>) | undefined;\n}\n\nasync function load(logicalPath: string, { baseRoot, loader }: LoadOpts): Promise<Uint8Array | null> {\n if (loader) {\n const bytes = await loader(logicalPath);\n return bytes ?? null;\n }\n if (!baseRoot) return null;\n const safe = normalize(logicalPath).replace(/^[/\\\\]+/, '');\n const full = resolve(baseRoot, safe);\n if (!isWithin(baseRoot, full)) {\n return null;\n }\n try {\n const s = await stat(full);\n if (!s.isFile()) return null;\n return new Uint8Array(await readFile(full));\n } catch {\n return null;\n }\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n const rel = resolve(child);\n const base = resolve(parent);\n return rel === base || rel.startsWith(base + sep);\n}\n\nfunction filenameForFormat(logical: string, format: 'pdf' | 'markdown' | 'html'): string {\n const base = logical.split('/').pop() ?? 'document';\n const stem = base.replace(/\\.cv$/i, '').replace(/\\.(pdf|md|html)$/i, '') || 'document';\n if (format === 'markdown') return `${stem}.md`;\n if (format === 'html') return `${stem}.html`;\n return `${stem}.cv`;\n}\n\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cvfile/server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Server middleware that serves .cv files with HTTP Link header content negotiation. Express, Fastify, Hono adapters.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://cvfile.org",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/cvfile/cv",
|
|
10
|
+
"directory": "packages/server-middleware-node"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./express": {
|
|
23
|
+
"types": "./dist/express.d.ts",
|
|
24
|
+
"import": "./dist/express.js",
|
|
25
|
+
"require": "./dist/express.cjs"
|
|
26
|
+
},
|
|
27
|
+
"./fastify": {
|
|
28
|
+
"types": "./dist/fastify.d.ts",
|
|
29
|
+
"import": "./dist/fastify.js",
|
|
30
|
+
"require": "./dist/fastify.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./hono": {
|
|
33
|
+
"types": "./dist/hono.d.ts",
|
|
34
|
+
"import": "./dist/hono.js",
|
|
35
|
+
"require": "./dist/hono.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@cvfile/sdk": "0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/express": "^5.0.0",
|
|
48
|
+
"@types/node": "^22.0.0",
|
|
49
|
+
"express": "^5.0.0",
|
|
50
|
+
"fastify": "^5.0.0",
|
|
51
|
+
"hono": "^4.6.0",
|
|
52
|
+
"pdf-lib": "^1.17.1",
|
|
53
|
+
"tsup": "^8.3.0",
|
|
54
|
+
"typescript": "^5.6.0",
|
|
55
|
+
"vitest": "^2.1.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"express": "^4 || ^5",
|
|
59
|
+
"fastify": "^4 || ^5",
|
|
60
|
+
"hono": "^4"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"express": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"fastify": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"hono": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "tsup",
|
|
75
|
+
"test": "vitest run",
|
|
76
|
+
"typecheck": "tsc --noEmit",
|
|
77
|
+
"clean": "rm -rf dist .turbo"
|
|
78
|
+
}
|
|
79
|
+
}
|