MCPcopy
hub / github.com/browserless/browserless / jsonResponse

Function jsonResponse

src/utils.ts:218–234  ·  view source on GitHub ↗
(
  response: ServerResponse,
  httpCode: keyof typeof codes = 200,
  json: unknown = {},
  allowNull = true,
)

Source from the content-addressed store, hash-verified

216};
217
218export const jsonResponse = (
219 response: ServerResponse,
220 httpCode: keyof typeof codes = 200,
221 json: unknown = {},
222 allowNull = true,
223): void => {
224 const httpMessage = codes[httpCode];
225 const CTTHeader = `${contentTypes.json}; charset=${encodings.utf8}`;
226
227 if (!response.headersSent) {
228 response.writeHead(httpMessage.code, { 'Content-Type': CTTHeader });
229 response.end(removeNullStringify(json, allowNull));
230 return;
231 }
232
233 return;
234};
235
236export const fetchJson = (
237 url: string,

Callers 10

handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85
handlerMethod · 0.85

Calls 1

removeNullStringifyFunction · 0.85

Tested by

no test coverage detected