AutoCallManu/web.js

36 lines
1018 B
JavaScript
Raw Normal View History

import express from "express";
import session from "express-session";
import { deployHandler } from "./utils/handler.js";
import favicon from "serve-favicon";
import vhost from "vhost";
2023-12-06 08:46:58 +01:00
async function launchWeb() {
2023-12-06 08:46:58 +01:00
const app = express();
const routerApp = express();
2023-12-06 08:46:58 +01:00
app.use(express.json()); // Used to parse JSON bodies
app.use(express.urlencoded({ extended: false })); //Parse URL-encoded bodies
app.use(
session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: true,
}),
);
routerApp.use(vhost(`${process.env.SERVER_URL}`, app));
2023-12-06 08:46:58 +01:00
app.use("/assets", express.static(`${process.env.WWW}/assets`));
app.use(favicon(`${process.env.WWW}/assets/images/favicon.ico`));
2023-12-06 08:46:58 +01:00
await deployHandler(app);
2023-12-06 08:46:58 +01:00
const PORT = process.env.PORT || 3000;
routerApp.listen(PORT, () => {
console.log(
`App available at http://${process.env.SERVER_URL}:${PORT}`,
);
});
}
export { launchWeb };