MCPcopy
hub / github.com/tinyhttp/tinyhttp / createServer

Function createServer

__tests__/wares/favicon.test.ts:9–21  ·  view source on GitHub ↗
(path?: string | Buffer, opts?: Omit<FaviconOptions, 'path'>)

Source from the content-addressed store, hash-verified

7const FAVICON_PATH = path.join(__dirname, '../fixtures/favicon.ico')
8
9function createServer(path?: string | Buffer, opts?: Omit<FaviconOptions, 'path'>) {
10 const _path = path || FAVICON_PATH
11 const _favicon = favicon(_path, opts)
12 const server = http.createServer(
13 async (req, res) =>
14 void _favicon(req, res, (err) => {
15 res.statusCode = err ? err.status || 500 : 404
16 res.end(err ? err.message : 'oops')
17 })
18 )
19
20 return server
21}
22
23describe('favicon function test', () => {
24 describe('args', () => {

Callers 6

cors.test.tsFile · 0.70
favicon.test.tsFile · 0.70
InitAppAndTestUnlessFunction · 0.70
listenMethod · 0.50
runServerFunction · 0.50
server.jsFile · 0.50

Calls 1

faviconFunction · 0.90

Tested by

no test coverage detected