-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(server): gendo IoC #1 - prep/cleanup before getting started
- Loading branch information
Showing
11 changed files
with
58 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import { Nullable } from '@speckle/shared' | ||
|
||
export type GendoAIRenderRecord = { | ||
id: string | ||
userId: string | ||
projectId: string | ||
modelId: string | ||
versionId: string | ||
createdAt: string | ||
updatedAt: string | ||
gendoGenerationId: string | ||
createdAt: Date | ||
updatedAt: Date | ||
gendoGenerationId: Nullable<string> | ||
status: string | ||
prompt: string | ||
camera: Record<string, unknown> | ||
/** References a blobId, weakly */ | ||
baseImage: string | ||
/** References a blobId, weakly */ | ||
responseImage: string | ||
responseImage: Nullable<string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { corsMiddleware } from '@/modules/core/configs/cors' | ||
import { getGendoAIResponseKey } from '@/modules/shared/helpers/envHelper' | ||
import { updateGendoAIRenderRequest } from '@/modules/gendo/services' | ||
import type express from 'express' | ||
|
||
export default function (app: express.Express) { | ||
const responseToken = getGendoAIResponseKey() | ||
|
||
// Gendo api calls hit these endpoints w/ the results | ||
app.options('/api/thirdparty/gendo', corsMiddleware()) | ||
app.post('/api/thirdparty/gendo', corsMiddleware(), async (req, res) => { | ||
if (req.headers['x-gendo-authorization'] !== responseToken) { | ||
return res.status(401).send('Speckle says you are not authorized 😠') | ||
} | ||
|
||
const responseImage = req.body.generated_image | ||
const status = req.body.status | ||
const gendoGenerationId = req.body.generationId | ||
|
||
await updateGendoAIRenderRequest({ | ||
gendoGenerationId, | ||
status, | ||
responseImage | ||
}) | ||
|
||
res.status(200).send('Speckle says thank you 💖') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters