(request: Request)
| 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…