MCPcopy
hub / github.com/npmx-dev/npmx.dev / requireAuth

Function requireAuth

cli/src/mock-app.ts:55–67  ·  view source on GitHub ↗
(event: H3Event)

Source from the content-addressed store, hash-verified

53 })
54
55 function requireAuth(event: H3Event): void {
56 const authHeader = event.req.headers.get('authorization')
57 if (!authHeader || !authHeader.startsWith('Bearer ')) {
58 throw new HTTPError({ statusCode: 401, message: 'Authorization required' })
59 }
60 const token = authHeader.slice(7)
61 if (token !== stateManager.token) {
62 throw new HTTPError({ statusCode: 401, message: 'Invalid token' })
63 }
64 if (!stateManager.isConnected()) {
65 throw new HTTPError({ statusCode: 401, message: 'Not connected' })
66 }
67 }
68
69 // POST /connect
70 app.post('/connect', async (event: H3Event) => {

Callers 1

createMockConnectorAppFunction · 0.85

Calls 2

isConnectedMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected