MCPcopy Create free account
hub / github.com/dailydotdev/apps / handleMarkdownRequest

Function handleMarkdownRequest

packages/webapp/proxy.ts:73–102  ·  view source on GitHub ↗
(
  req: NextRequest,
)

Source from the content-addressed store, hash-verified

71};
72
73const handleMarkdownRequest = async (
74 req: NextRequest,
75): Promise<NextResponse> => {
76 const deviceId = req.cookies.get('da2')?.value ?? generateTrackingId();
77 const wall = await evaluateAgentSignupWall(deviceId);
78 const { allocation } = wall;
79 if (allocation) {
80 after(async () => {
81 await trackAgentSignupWallAllocation(deviceId, allocation);
82 });
83 }
84 if (!wall.enabled) {
85 return getMarkdownResponse(req);
86 }
87
88 const hasToken = await hasValidAgentMarkdownToken(
89 req.headers.get('authorization'),
90 );
91 if (hasToken) {
92 return getMarkdownResponse(req);
93 }
94
95 return new NextResponse(getAgentSignupRequiredBody(), {
96 status: 401,
97 headers: {
98 'cache-control': 'private, no-store',
99 'content-type': 'text/markdown; charset=utf-8',
100 },
101 });
102};
103
104const isMarkdownRequest = (req: NextRequest): boolean => {
105 const { pathname } = req.nextUrl;

Callers 1

proxyFunction · 0.85

Calls 6

evaluateAgentSignupWallFunction · 0.90
generateTrackingIdFunction · 0.85
getMarkdownResponseFunction · 0.85

Tested by

no test coverage detected