MCPcopy
hub / github.com/QwikDev/qwik / staticFile

Function staticFile

packages/qwik-city/src/middleware/deno/index.ts:153–178  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

151 };
152
153 const staticFile = async (request: Request) => {
154 try {
155 const url = getRequestUrl(request, opts);
156
157 if (isStaticPath(request.method || 'GET', url)) {
158 const { filePath, content } = await openStaticFile(url);
159 const ext = extname(filePath).replace(/^\./, '');
160
161 return new Response(content.readable, {
162 status: 200,
163 headers: {
164 'content-type': MIME_TYPES[ext] || 'text/plain; charset=utf-8',
165 'Cache-Control': opts.static?.cacheControl || 'max-age=3600',
166 },
167 });
168 }
169
170 return null;
171 } catch (e) {
172 console.error(e);
173 return new Response(String(e || 'Error'), {
174 status: 500,
175 headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Error': 'deno-server' },
176 });
177 }
178 };
179
180 return {
181 router,

Callers

nothing calls this directly

Calls 4

extnameFunction · 0.90
isStaticPathFunction · 0.85
getRequestUrlFunction · 0.70
openStaticFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…