MCPcopy Create free account
hub / github.com/EvoMap/evolver / rawPost

Function rawPost

test/v1Messages.test.js:13–42  ·  view source on GitHub ↗
(url, token, body)

Source from the content-addressed store, hash-verified

11const { buildMessagesHandler } = require('../src/proxy/router/messages_route');
12
13function rawPost(url, token, body) {
14 return new Promise((resolve, reject) => {
15 const u = new URL(url);
16 const payload = JSON.stringify(body || {});
17 const req = http.request({
18 hostname: u.hostname,
19 port: u.port,
20 path: u.pathname,
21 method: 'POST',
22 headers: {
23 'Authorization': 'Bearer ' + token,
24 'Content-Type': 'application/json',
25 'Content-Length': Buffer.byteLength(payload),
26 'x-api-key': 'sk-test',
27 'anthropic-version': '2023-06-01',
28 },
29 }, (res) => {
30 const chunks = [];
31 res.on('data', (c) => chunks.push(c));
32 res.on('end', () => resolve({
33 status: res.statusCode,
34 headers: res.headers,
35 body: Buffer.concat(chunks).toString(),
36 }));
37 });
38 req.on('error', reject);
39 req.write(payload);
40 req.end();
41 });
42}
43
44function startStubAnthropic(handler) {
45 return new Promise((resolve) => {

Callers 1

v1Messages.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected