MCPcopy Create free account
hub / github.com/chartbrew/chartbrew / executeRouteHandlers

Function executeRouteHandlers

server/tests/integration/updateRunRoute.test.js:49–80  ·  view source on GitHub ↗
(handlers, requestOverrides = {})

Source from the content-addressed store, hash-verified

47}
48
49async function executeRouteHandlers(handlers, requestOverrides = {}) {
50 const req = {
51 headers: {},
52 params: {},
53 query: {},
54 ...requestOverrides,
55 };
56 const res = createMockResponse();
57
58 const dispatch = async (index) => {
59 if (index >= handlers.length) {
60 return;
61 }
62
63 await handlers[index](req, res, (error) => {
64 if (error) {
65 return Promise.reject(error);
66 }
67
68 return dispatch(index + 1);
69 });
70 };
71
72 await dispatch(0);
73
74 return {
75 req,
76 res,
77 statusCode: res.statusCode,
78 body: res.body,
79 };
80}
81
82function createAuthorizationHeader(token) {
83 return {

Callers 1

Calls 2

createMockResponseFunction · 0.70
dispatchFunction · 0.70

Tested by

no test coverage detected