-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
48 lines (41 loc) · 1.35 KB
/
server.js
File metadata and controls
48 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import connectDB from "./database/db.js";
import { app } from "./app.js";
import "dotenv/config";
import { ExpressAdapter } from "@bull-board/express";
import { createBullBoard } from "@bull-board/api";
import { BullMQAdapter } from "@bull-board/api/bullMQAdapter";
import { cloudinaryImageUploaderQueue } from "./queues/cloudinaryImageQueue.js";
import { cloudinaryDeleteImageQueue } from "./queues/cloudinaryDeleteImageQueue.js";
//#region Constants
const PORT = process.env.PORT || 3000;
//#endregion
//#region Bull Board
// NOTE: Create a server adapter for Bull Board - similiar to our test project
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath("/admin/queues");
// NOTE: Attach the queues to the dashboard
createBullBoard({
queues: [
new BullMQAdapter(cloudinaryImageUploaderQueue),
new BullMQAdapter(cloudinaryDeleteImageQueue),
],
serverAdapter,
});
// NOTE: Mount the dashboard route
app.use("/admin/queues", serverAdapter.getRouter());
//#endregion
//#region 404 Handler
app.use((req, res) => {
res.status(404).json({
status: "error",
message: "Route not found",
});
});
//#endregion;
//#region DB Connection
await connectDB();
app.listen(PORT, () => {
console.log(`Server is listening on: http://localhost:${PORT}`);
console.log(`Bull Board available at: http://localhost:${PORT}/admin/queues`);
});
//#endregion