15 lines
374 B
TypeScript
Raw Normal View History

2020-05-09 11:34:50 +02:00
import express from 'express';
import serveStatic from 'serve-static';
2022-11-07 17:20:42 +11:00
import type { Server } from 'http';
2020-05-09 11:34:50 +02:00
export const serve = async (location: string, port: string): Promise<Server> => {
2020-11-26 16:55:47 +01:00
return new Promise((resolve) => {
2020-05-09 11:34:50 +02:00
const app = express();
app.use(serveStatic(location));
2020-11-26 16:55:47 +01:00
const server = app.listen(port, () => {
resolve(server);
2020-05-09 11:34:50 +02:00
});
});
};