* fix: connection state handling * chore: reset token expiration * feat: state machine experiment * feat: new realtime state machine impl * chore: update client to 0.7.0 before release * fix: error handling x-fal-error * chore(client): release v0.7.0 * fix(client): strict type check error
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* This is not a production server yet!
|
|
* This is only a minimal backend to get started.
|
|
*/
|
|
|
|
import * as fal from '@fal-ai/serverless-client';
|
|
import * as falProxy from '@fal-ai/serverless-proxy/express';
|
|
import cors from 'cors';
|
|
import { configDotenv } from 'dotenv';
|
|
import express from 'express';
|
|
import * as path from 'path';
|
|
|
|
configDotenv({ path: './env.local' });
|
|
|
|
const app = express();
|
|
|
|
// Middlewares
|
|
app.use('/assets', express.static(path.join(__dirname, 'assets')));
|
|
app.use(express.json());
|
|
|
|
// fal.ai client proxy
|
|
app.all(falProxy.route, cors(), falProxy.handler);
|
|
|
|
// Your API endpoints
|
|
app.get('/api', (req, res) => {
|
|
res.send({ message: 'Welcome to demo-express-app!' });
|
|
});
|
|
|
|
app.get('/fal-on-server', async (req, res) => {
|
|
const result = await fal.run('110602490-lcm', {
|
|
input: {
|
|
prompt:
|
|
'a black cat with glowing eyes, cute, adorable, disney, pixar, highly detailed, 8k',
|
|
},
|
|
});
|
|
res.send(result);
|
|
});
|
|
|
|
const port = process.env.PORT || 3333;
|
|
const server = app.listen(port, () => {
|
|
console.log(`Listening at http://localhost:${port}/api`);
|
|
});
|
|
server.on('error', console.error);
|