Duffer Derek
import express from "express";
import dbConnection from "./src/configs/dbConnection.js";
import cron from "./src/routes/cron.js";
import test from "./src/routes/test.js";
import api from "./src/routes/api.js";
import auth from "./src/routes/auth.js";
import hook from "./src/routes/hooks.js";
import cors from "cors";
import * as Sentry from "@sentry/node";
const app = express();
const port = process.env.PORT || 3005;
// Middleware to parse JSON requests
app.use(express.json());
app.get("/", (req, res) => {
res.send("Hello World!");
});
app.get("/test", (req, res) => {
res.json({
name: "test task",
date: "12-12-2024",
details: [
{
start: "12-12-2024",
end: "14-12-2024",
description: "test"
}
]
});
});
app.use("/auth", cors(), auth);
app.use("/api", cors(), api);
app.use("/hooks", cors(), hook);
app.use("/cron", cron);
app.use("/test", test);
//static file path
app.use("/files", express.static("src/storage/public/files"));
app.use("/file", express.static("src/storage/public/file"));
app.get("/debug-sentry", function mainHandler(req, res) {
throw new Error("error ");
});
Sentry.init({
dsn: process.env.SENTRY_DNS,
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// enable Express.js middleware tracing
new Sentry.Integrations.Express({ app }),
],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.use(Sentry.Handlers.errorHandler());
app.use(function onError(err, req, res, next) {
res.status(500).json({
status: 500,
message: err.message, // Use err.message instead of just err
});
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists