2024-06-14 11:09:53 +00:00
|
|
|
import VmAPI from "./API/VM";
|
|
|
|
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
|
|
|
import Express, { ExpressApplication } from "CommonServer/Utils/Express";
|
|
|
|
import logger from "CommonServer/Utils/Logger";
|
|
|
|
import App from "CommonServer/Utils/StartServer";
|
2024-08-02 22:35:09 +00:00
|
|
|
import Telemetry from "CommonServer/Utils/Telemetry";
|
2024-06-14 11:09:53 +00:00
|
|
|
import process from "process";
|
2024-04-05 17:33:52 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
const APP_NAME: string = "isolated-vm";
|
2024-04-05 17:22:29 +00:00
|
|
|
|
2024-04-06 13:47:00 +00:00
|
|
|
const app: ExpressApplication = Express.getExpressApp();
|
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
app.use([`/${APP_NAME}`, "/"], VmAPI);
|
2024-04-06 13:47:00 +00:00
|
|
|
|
2024-04-05 17:22:29 +00:00
|
|
|
const init: PromiseVoidFunction = async (): Promise<void> => {
|
2024-06-14 11:09:53 +00:00
|
|
|
try {
|
2024-08-02 22:35:09 +00:00
|
|
|
// Initialize telemetry
|
|
|
|
Telemetry.init({
|
|
|
|
serviceName: APP_NAME,
|
|
|
|
});
|
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
// init the app
|
|
|
|
await App.init({
|
|
|
|
appName: APP_NAME,
|
|
|
|
port: undefined,
|
|
|
|
isFrontendApp: false,
|
|
|
|
statusOptions: {
|
|
|
|
liveCheck: async () => {},
|
|
|
|
readyCheck: async () => {},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
logger.debug("App Init Success");
|
2024-04-24 16:44:29 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
// add default routes
|
|
|
|
await App.addDefaultRoutes();
|
|
|
|
} catch (err) {
|
|
|
|
logger.error("App Init Failed:");
|
|
|
|
logger.error(err);
|
|
|
|
throw err;
|
|
|
|
}
|
2024-04-05 17:22:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
init().catch((err: Error) => {
|
2024-06-14 11:09:53 +00:00
|
|
|
logger.error(err);
|
|
|
|
logger.error("Exiting node process");
|
|
|
|
process.exit(1);
|
2024-04-05 17:22:29 +00:00
|
|
|
});
|