Initial commit

This commit is contained in:
2026-06-30 17:06:06 +02:00
commit d0bb893522
19 changed files with 1333 additions and 0 deletions

38
ts/main.ts Normal file
View File

@@ -0,0 +1,38 @@
import { BambuddyAddress } from './constants';
import { login } from './login';
import { getPrinterDetails } from './printer';
import { getStreamToken } from './streamToken';
import * as express from 'express';
import { Request, Response } from 'express';
async function getToken() {
const loginResponse = await login('screen', 'e8$o$u@F8XtHt#');
console.log('Login response:', loginResponse);
const streamToken = await getStreamToken(
loginResponse?.access_token as string,
);
return streamToken?.token;
}
const app = express();
app.get('/', async (req: Request, res: Response) => {
res.send(
'Bambuddy Camera Bridge is running. Use /:printerId to access the camera stream.',
);
});
app.get('/:printerId', async (req: Request, res: Response) => {
const token = await getToken();
res.redirect(
`${BambuddyAddress}/api/v1/printers/${req.params.printerId}/camera/stream?fps=15&t=${Date.now()}&token=${token}`,
);
});
app.listen(3838, () => {
console.log('Server is running on port 3838');
});