MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / integrationMiddleware

Function integrationMiddleware

packages/sdk/src/middleware.ts:7–23  ·  view source on GitHub ↗
(INTERNAL_API_KEY: string)

Source from the content-addressed store, hash-verified

5}
6
7export function integrationMiddleware(INTERNAL_API_KEY: string) {
8 return async (req: any, _: any, next: any) => {
9 try {
10 const apiKeyRaw = getInternalApiKey(req);
11 if (!apiKeyRaw) {
12 return next(new Error('missing api key'));
13 }
14 if (INTERNAL_API_KEY !== apiKeyRaw) {
15 return next(new Error('api key does not match'));
16 }
17 return next();
18 } catch (error) {
19 console.error(error);
20 return next(new Error('internal server error'));
21 }
22 };
23}

Callers

nothing calls this directly

Calls 2

getInternalApiKeyFunction · 0.70
errorMethod · 0.65

Tested by

no test coverage detected