Skip to content

Commit

Permalink
feat: added github hook
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed May 25, 2024
1 parent 449d32f commit 9ae1cfe
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 234 deletions.
50 changes: 26 additions & 24 deletions api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,28 @@ model Document {
documentType String
syncronizationUnits SyncronizationUnit[]
state String?
@@id([id, driveId])
}

model Operation {
id String @id @default(uuid())
driveId String
Document Document? @relation(fields: [driveId, documentId], references: [driveId, id], onDelete: Cascade)
documentId String
scope String
branch String
index Int
skip Int
hash String
timestamp DateTime
input Json
type String
attachments Attachment[]
syncId String?
clipboard Boolean? @default(false)
context Json?
resultingState String?
id String @id @default(uuid())
driveId String
Document Document? @relation(fields: [driveId, documentId], references: [driveId, id], onDelete: Cascade)
documentId String
scope String
branch String
index Int
skip Int
hash String
timestamp DateTime
input Json
type String
attachments Attachment[]
syncId String?
clipboard Boolean? @default(false)
context Json?
resultingState String?
SyncronizationUnit SyncronizationUnit? @relation(fields: [syncId, driveId], references: [id, driveId], onDelete: Cascade)
@@unique([driveId, documentId, scope, branch, index], name: "unique_operation")
Expand Down Expand Up @@ -331,13 +332,14 @@ model RWABaseTransactionOnGroupTransaction {
}

model ScopeOfWorkDeliverable {
driveId String
documentId String
id String
title String
description String
status String
driveId String
documentId String
id String
title String
description String
status String
githubCreated Boolean
githubId Int?
@@id([id, driveId, documentId])
}
}
15 changes: 15 additions & 0 deletions api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import * as Sentry from "@sentry/node";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
import bodyParser from 'body-parser';
import prisma from './database';


const logger = getChildLogger({ msgPrefix: 'APP' });
Expand Down Expand Up @@ -78,6 +79,20 @@ export const createApp = (): { app: Express, router: express.Router } => {
}
);

// Hooks
router.post('/h/github', async (req, res) => {
const issueId = req.body?.issue?.number;
if (!issueId) {
throw new Error('Issue number not found in request body')
}

const result = await prisma.document.closeScopeOfWorkIssue(req.body.issue.number)
if (!result) {
throw new Error('Failed to close issue')
}
res.sendStatus(200).send(result);
});

const basePath = process.env.BASE_PATH || '/';
app.use(basePath, router);

Expand Down
Loading

0 comments on commit 9ae1cfe

Please sign in to comment.