mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
28 lines
813 B
JavaScript
28 lines
813 B
JavaScript
import express from 'express';
|
|
import unpackByOutpoint from './unpackByOutpoint';
|
|
|
|
// Polyfills and `lbry-redux`
|
|
global.fetch = require('node-fetch');
|
|
|
|
global.window = global;
|
|
// eslint-disable-next-line import/no-commonjs,global-require
|
|
const { Lbry } = require('lbry-redux');
|
|
|
|
delete global.window;
|
|
|
|
export default async function startSandbox() {
|
|
const sandbox = express();
|
|
const port = 5278;
|
|
|
|
sandbox.get('/set/:outpoint', async (req, res) => {
|
|
const { outpoint } = req.params;
|
|
const resolvedPath = await unpackByOutpoint(Lbry, outpoint);
|
|
|
|
sandbox.use(`/sandbox/${outpoint}/`, express.static(resolvedPath));
|
|
|
|
res.send(`/sandbox/${outpoint}/`);
|
|
});
|
|
|
|
// eslint-disable-next-line no-console
|
|
sandbox.listen(port, 'localhost', () => console.log(`Sandbox listening on port ${port}.`));
|
|
}
|