mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 09:48:18 -05:00
* chore: convert rendering tests to es6 * chore: fix cjs config usage * chore: fix cjs config usage * chore: fix verify translations * chore: babel and jest es6 * chore: aw cjs * chore: aw cjs * chore: aw cjs * chore: fix path
38 lines
847 B
JavaScript
38 lines
847 B
JavaScript
import express from 'express';
|
|
import path, { dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const FN = fileURLToPath(import.meta.url);
|
|
const DN = dirname(FN);
|
|
|
|
export default async function startServer(port) {
|
|
const app = express();
|
|
// const port = 8050;
|
|
const url = `http://localhost:${port}`;
|
|
app.use(express.static(path.resolve(DN)));
|
|
app.use('/apis', express.static(path.resolve(DN, '../../apis')));
|
|
app.use('/node_modules', express.static(path.resolve(DN, '../../node_modules')));
|
|
|
|
let server;
|
|
|
|
await new Promise((resolve) => {
|
|
server = app.listen(port, () => {
|
|
console.log(`Running rendering server at ${url}`);
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
const destroy = () => {
|
|
server.close();
|
|
};
|
|
|
|
return {
|
|
url,
|
|
destroy,
|
|
};
|
|
}
|
|
|
|
export function getPaths(dir) {
|
|
return path.join(DN, dir);
|
|
}
|