fal-js/apps/demo-app/pages/api/generateImage.ts
Daniel Rochetti 6553779987
chore: configure new monorepo and build workflow
* prepare monorepo and move client to its package

* create nx workspace

* workspace cleanup and updates

* upgrade nx workspace and fix client package

* add basic codegen logic

* first working build script

* update nextjs app

* update generated code

* add koldstart core and client foundation

* add basic fetch implementation to client

* add stable diffusion example

* remove local output image

* remove keys

* remove more keys

* update client usage and samples

* remove grpc client code and dependencies

* rename base package

* remove core package

* continue package refactor

* rename koldstart apis

* refactor main function run api

* add listen function stub

* removed more koldstart references

* build workflow added

* minor doc updates - trigger workflow

* nx workflow action
2023-03-29 12:49:55 -03:00

22 lines
585 B
TypeScript

import {
generateImage,
GenerateImageInput,
} from '../../services/generateImage';
export default async function handler(req, res) {
if (req.method === 'POST') {
// not really type-safe, force cast because I can =P
const prompt = req.body as GenerateImageInput;
try {
const imageUrl = await generateImage(prompt);
res.status(200).json({ imageUrl });
} catch (error) {
res
.status(500)
.json({ error: 'Failed to update image', causedBy: error });
}
} else {
res.status(405).json({ error: 'Method not allowed' });
}
}