Upgrade octokit to v4.1.2
This commit is contained in:
parent
dbbcbe019d
commit
c1745a9831
1214 changed files with 160765 additions and 0 deletions
57
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
Normal file
57
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import {
|
||||
createNodeMiddleware as oauthNodeMiddleware,
|
||||
sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
} from "@octokit/oauth-app";
|
||||
import { createNodeMiddleware as webhooksNodeMiddleware } from "@octokit/webhooks";
|
||||
function noop() {
|
||||
}
|
||||
function createNodeMiddleware(app, options = {}) {
|
||||
const log = Object.assign(
|
||||
{
|
||||
debug: noop,
|
||||
info: noop,
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
},
|
||||
options.log
|
||||
);
|
||||
const optionsWithDefaults = {
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log
|
||||
};
|
||||
const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log
|
||||
});
|
||||
const oauthMiddleware = oauthNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth"
|
||||
});
|
||||
return middleware.bind(
|
||||
null,
|
||||
optionsWithDefaults.pathPrefix,
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
);
|
||||
}
|
||||
async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) {
|
||||
const { pathname } = new URL(request.url, "http://localhost");
|
||||
if (pathname.startsWith(`${pathPrefix}/`)) {
|
||||
if (pathname === `${pathPrefix}/webhooks`) {
|
||||
webhooksMiddleware(request, response);
|
||||
} else if (pathname.startsWith(`${pathPrefix}/oauth/`)) {
|
||||
oauthMiddleware(request, response);
|
||||
} else {
|
||||
sendNodeResponse(unknownRouteResponse(request), response);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export {
|
||||
createNodeMiddleware,
|
||||
middleware
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue