Kuba Orlik 711b52562f Run compiled code in vitest instead of the source typescript
Summary: to avoid troubles with sealcode ts loaders not present in vitest

Reviewers: #reviewers

Subscribers: jenkins-user

Differential Revision: https://hub.sealcode.org/D1431
2024-04-12 22:25:12 +02:00

32 lines
795 B
TypeScript

import kill from "kill-port";
import _locreq from "locreq";
import TheApp from "./app.js";
import { PORT, SEALIOUS_SANITY } from "./config.js";
import { mainRouter } from "./routes/index.js";
import { module_dirname } from "./utils/module_dirname.js";
const locreq = _locreq(module_dirname(import.meta.url));
export const the_app = new TheApp();
void (async function () {
await kill(PORT);
await kill(PORT);
try {
the_app.HTTPServer.addStaticRoute("/", locreq.resolve("public"));
await the_app.start();
if (SEALIOUS_SANITY) {
console.error("Exiting with error code 0");
process.exit(0);
}
mainRouter(the_app.HTTPServer.router);
} catch (error) {
console.error(error);
if (SEALIOUS_SANITY) {
console.error("EXITING WITH STATUS 1");
process.exit(1);
}
}
})();