(contentDir: string)
| 302 | } |
| 303 | |
| 304 | async function startWithAssets(contentDir: string): Promise<{ port: number }> { |
| 305 | const httpServer = createServer(); |
| 306 | const filter = { |
| 307 | isPathIgnored: (rel: string) => rel.startsWith('.ok/') || rel === 'excluded.png', |
| 308 | }; |
| 309 | const mount = mountMcpAndApi({ |
| 310 | httpServer, |
| 311 | hocuspocus, |
| 312 | log, |
| 313 | contentAssetMiddleware: createAssetServeMiddleware({ |
| 314 | contentFilter: filter, |
| 315 | contentSirv: sirv(contentDir, { dev: true, dotfiles: false }), |
| 316 | inlineExtensions: INLINE_RENDERABLE_EXTENSIONS, |
| 317 | assetExtensions: ASSET_EXTENSIONS, |
| 318 | blocklistExtensions: EXECUTABLE_BLOCKLIST_EXTENSIONS, |
| 319 | }), |
| 320 | }); |
| 321 | const port = await getFreeLoopbackPort(); |
| 322 | await new Promise<void>((resolve) => httpServer.listen(port, '127.0.0.1', () => resolve())); |
| 323 | servers.push({ httpServer, mount }); |
| 324 | return { port }; |
| 325 | } |
| 326 | |
| 327 | test('serves a content asset with inline disposition + nosniff', async () => { |
| 328 | const contentDir = makeContentDir(); |
no test coverage detected