Skip to content

Commit

Permalink
Update Gemini dev server and serve 4.17 (#5199)
Browse files Browse the repository at this point in the history
* Update dev server and use 4.17

* Add Node.js 16 requirements
  • Loading branch information
compulim authored Jun 3, 2024
1 parent 6ff90db commit 157a8cb
Show file tree
Hide file tree
Showing 6 changed files with 752 additions and 1,699 deletions.
42 changes: 0 additions & 42 deletions packages/embed/hostDevServer.js

This file was deleted.

37 changes: 37 additions & 0 deletions packages/embed/hostDevServer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { join } from 'path';
import { fileURLToPath } from 'url';

const { PORT = 5002 } = process.env;
const DEFAULT_BOT_ID = 'webchat-mockbot';

const app = express();

app.get('/', async (_, res) => {
const tokenRes = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });

if (!tokenRes.ok) {
return res.send(500);
}

const { token } = await tokenRes.json();

const redirectURL = new URL(DEFAULT_BOT_ID, 'http://localhost/embed/');

redirectURL.searchParams.set('b', DEFAULT_BOT_ID);
redirectURL.searchParams.set('t', token);

res.status(302);
res.header('location', redirectURL.pathname + redirectURL.search);

return res.end();
});

app.get('/embed/:bot', async (_, res) =>
res.setHeader('content-type', 'text/html').sendFile(join(fileURLToPath(import.meta.url), '../dist/gemini.html'))
);

app.get('/embed/:bot/config', createProxyMiddleware({ changeOrigin: true, target: 'https://webchat.botframework.com/' }));

app.listen(PORT, () => console.log(`Embed dev server is listening to port ${PORT}`));
Loading

0 comments on commit 157a8cb

Please sign in to comment.