MCPcopy Create free account
hub / github.com/openai/plugins / handleRequest

Function handleRequest

plugins/superpowers/skills/brainstorming/scripts/server.cjs:129–161  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

127// ========== HTTP Request Handler ==========
128
129function handleRequest(req, res) {
130 touchActivity();
131 if (req.method === 'GET' && req.url === '/') {
132 const screenFile = getNewestScreen();
133 let html = screenFile
134 ? (raw => isFullDocument(raw) ? raw : wrapInFrame(raw))(fs.readFileSync(screenFile, 'utf-8'))
135 : WAITING_PAGE;
136
137 if (html.includes('</body>')) {
138 html = html.replace('</body>', helperInjection + '\n</body>');
139 } else {
140 html += helperInjection;
141 }
142
143 res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
144 res.end(html);
145 } else if (req.method === 'GET' && req.url.startsWith('/files/')) {
146 const fileName = req.url.slice(7);
147 const filePath = path.join(CONTENT_DIR, path.basename(fileName));
148 if (!fs.existsSync(filePath)) {
149 res.writeHead(404);
150 res.end('Not found');
151 return;
152 }
153 const ext = path.extname(filePath).toLowerCase();
154 const contentType = MIME_TYPES[ext] || 'application/octet-stream';
155 res.writeHead(200, { 'Content-Type': contentType });
156 res.end(fs.readFileSync(filePath));
157 } else {
158 res.writeHead(404);
159 res.end('Not found');
160 }
161}
162
163// ========== WebSocket Connection Handling ==========
164

Callers

nothing calls this directly

Calls 4

touchActivityFunction · 0.85
getNewestScreenFunction · 0.85
isFullDocumentFunction · 0.85
wrapInFrameFunction · 0.85

Tested by

no test coverage detected