mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-18 05:02:24 +08:00
19 lines
449 B
TypeScript
19 lines
449 B
TypeScript
|
import express from 'express';
|
||
|
import serveStatic from 'serve-static';
|
||
|
import { Server } from 'http';
|
||
|
|
||
|
export const serve = async (location: string, port: string): Promise<Server> => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
const app = express();
|
||
|
|
||
|
app.use(serveStatic(location));
|
||
|
const server = app.listen(port, (error) => {
|
||
|
if (error) {
|
||
|
reject(error);
|
||
|
} else {
|
||
|
resolve(server);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
};
|