2023-12-07 01:28:39 +01:00
|
|
|
import express from "express";
|
|
|
|
import session from "express-session";
|
|
|
|
import { deployHandler } from "./utils/handler.js";
|
|
|
|
import favicon from "serve-favicon";
|
2023-12-12 13:43:47 +01:00
|
|
|
import vhost from "vhost";
|
2023-12-06 08:46:58 +01:00
|
|
|
|
2023-12-07 01:28:39 +01:00
|
|
|
async function launchWeb() {
|
2023-12-06 08:46:58 +01:00
|
|
|
const app = express();
|
2023-12-12 13:43:47 +01:00
|
|
|
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
|
2023-12-06 19:11:14 +01:00
|
|
|
app.use(
|
|
|
|
session({
|
|
|
|
secret: process.env.SECRET,
|
|
|
|
resave: false,
|
|
|
|
saveUninitialized: true,
|
|
|
|
}),
|
|
|
|
);
|
2023-12-12 13:43:47 +01:00
|
|
|
routerApp.use(vhost(`${process.env.SERVER_URL}`, app));
|
2023-12-06 08:46:58 +01:00
|
|
|
|
2023-12-06 19:11:14 +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
|
|
|
|
2023-12-07 23:50:39 +01:00
|
|
|
await deployHandler(app);
|
2023-12-06 08:46:58 +01:00
|
|
|
|
|
|
|
const PORT = process.env.PORT || 3000;
|
2023-12-12 13:43:47 +01:00
|
|
|
routerApp.listen(PORT, () => {
|
|
|
|
console.log(
|
|
|
|
`App available at http://${process.env.SERVER_URL}:${PORT}`,
|
|
|
|
);
|
2023-12-06 19:11:14 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-07 01:28:39 +01:00
|
|
|
export { launchWeb };
|