mock.ts 382 B

123456789101112131415161718
  1. import express from "express";
  2. import path from "path";
  3. const staticDir = path.resolve(__dirname, "test");
  4. console.log(staticDir);
  5. let startup = false;
  6. export async function createServer(port: number) {
  7. if (startup) {
  8. return;
  9. }
  10. const app = express();
  11. app.use(express.static(staticDir));
  12. app.listen(port);
  13. startup = true;
  14. console.log("模拟环境已开启");
  15. }