35ed179799
* feat(gendo): scaffolding * feat(gendo): wip * feat(gendo): wip * feat(gendo): wip * feat(gendo): wip * feat(gendo): wip * feat(gendo): it's alive * feat(gendo): wip * feat(gendo): blobifies responses to make gergo happy * feat(gendo): ratelimiting + lints * feat(gendo): prettier fix * feat(gendo): last fixes * feat(gendo): clarifications * feat(gendo): helm base * update helm values and deployment to use secrets and allow them to be configured * Allow the rate limiter to be configured * Use valid Gendo AI api as default * fix(helm chart): environment variables should be strings --------- Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper'
|
|
import { moduleLogger } from '@/logging/logging'
|
|
import { corsMiddleware } from '@/modules/core/configs/cors'
|
|
import { getGendoAIResponseKey } from '@/modules/shared/helpers/envHelper'
|
|
import { updateGendoAIRenderRequest } from '@/modules/gendo/services'
|
|
|
|
const responseToken = getGendoAIResponseKey()
|
|
|
|
export = {
|
|
async init(app) {
|
|
moduleLogger.info('🪞 Init Gendo AI render module')
|
|
|
|
// Gendo api calls back in here with the result.
|
|
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 💖')
|
|
})
|
|
},
|
|
async shutdown() {}
|
|
} as SpeckleModule
|