MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / collectServableFiles

Function collectServableFiles

apps/api/src/templates/email/preview.ts:299–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

297 * derived from `req.url`.
298 */
299const collectServableFiles = (): Map<string, string> => {
300 const map = new Map<string, string>();
301
302 const walk = (dir: string): void => {
303 if (!fs.existsSync(dir)) {
304 return;
305 }
306
307 for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
308 const abs = path.join(dir, entry.name);
309
310 if (entry.isDirectory()) {
311 walk(abs);
312 } else if (entry.isFile()) {
313 const rel = path.relative(PREVIEW_DIR, abs).split(path.sep).join("/");
314
315 map.set(`/${rel}`, abs);
316 }
317 }
318 };
319
320 walk(PREVIEW_DIR);
321
322 return map;
323};
324
325const CONTENT_TYPES: Record<string, string> = {
326 ".html": "text/html",

Callers 1

startServerFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected