dashboard.accords-library.com/src/server.ts

31 lines
677 B
TypeScript
Raw Normal View History

2023-07-14 11:03:01 +00:00
import express from "express";
import payload from "payload";
2023-07-22 18:32:18 +00:00
import "dotenv/config";
import path from "path";
2023-07-14 11:03:01 +00:00
const app = express();
// Redirect root to Admin panel
app.get("/", (_, res) => {
res.redirect("/admin");
});
const start = async () => {
// Initialize Payload
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
// Add your own express routes here
2023-07-22 18:32:18 +00:00
app.use("/public", express.static(path.join(__dirname, "../public")));
2023-07-14 11:03:01 +00:00
2023-07-22 19:12:41 +00:00
app.listen(process.env.PAYLOAD_PORT);
2023-07-14 11:03:01 +00:00
};
start();