Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions packages/backend/server/routes/publish.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { generateTemplateHtml } from "~/utils/template";

export default eventHandler(async (event) => {
const origin = getRequestURL(event).origin;

const {
"sb-commit-timestamp": commitTimestampHeader,
"sb-key": key,
Expand All @@ -24,15 +24,19 @@ export default eventHandler(async (event) => {
const workflowsBucket = useWorkflowsBucket(event);
const workflowData = (await workflowsBucket.getItem(key))!;

const whitelisted = await isWhitelisted(workflowData.owner, workflowData.repo)
const whitelisted = await isWhitelisted(
workflowData.owner,
workflowData.repo,
);
const contentLength = Number(getHeader(event, "content-length"));

// 20mb limit for now
if (!whitelisted && contentLength > 1024 * 1024 * 20) {
// Payload too large
throw createError({
statusCode: 413,
message: "Max payload limit is 20mb! Feel free to apply for the whitelist: https://github.com/stackblitz-labs/pkg.pr.new/blob/main/.whitelist",
message:
"Max payload limit is 20mb! Feel free to apply for the whitelist: https://github.com/stackblitz-labs/pkg.pr.new/blob/main/.whitelist",
});
}

Expand Down Expand Up @@ -64,8 +68,6 @@ export default eventHandler(async (event) => {

const commitTimestamp = Number(commitTimestampHeader);



const sha = abbreviateCommitHash(workflowData.sha);
const baseKey = `${workflowData.owner}:${workflowData.repo}`;

Expand Down Expand Up @@ -203,15 +205,25 @@ export default eventHandler(async (event) => {
owner: workflowData.owner,
repo: workflowData.repo,
comment_id: prevComment.id,
body: generatePullRequestPublishMessage(
origin,
templatesHtmlMap,
packagesWithoutPrefix,
workflowData,
compact,
),
body:
JSON.stringify(installationData.permissions, null, 2) +
"\n" +
generatePullRequestPublishMessage(
origin,
templatesHtmlMap,
packagesWithoutPrefix,
workflowData,
compact,
),
},
);

await installation.request("POST /repos/{owner}/{repo}/deployments", {
owner: workflowData.owner,
repo: workflowData.repo,
ref: sha,
description: "Deploy request from hubot",
});
} else {
await installation.request(
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
Expand Down