feat: implement bug report submission with server upload functionality
- Updated documentation to include new API server details and configuration options. - Enhanced `SubmitBugReport` method to attempt server upload and handle errors gracefully. - Added `UploadBugReport` method to handle multipart file uploads to the API server. - Introduced new API server with MySQL backend for managing bug reports. - Implemented rate limiting and authentication for the API. - Created database schema and migration scripts for bug report storage. - Added admin routes for managing bug reports and files. - Updated frontend to reflect changes in bug report submission and success/error messages.
This commit is contained in:
43
server/src/index.ts
Normal file
43
server/src/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Elysia } from "elysia";
|
||||
import { config, validateConfig } from "./config";
|
||||
import { runMigrations } from "./db/migrate";
|
||||
import { closePool } from "./db/connection";
|
||||
import { bugReportRoutes } from "./routes/bugReports";
|
||||
import { adminRoutes } from "./routes/admin";
|
||||
|
||||
// Validate environment
|
||||
validateConfig();
|
||||
|
||||
// Run database migrations
|
||||
await runMigrations();
|
||||
|
||||
const app = new Elysia()
|
||||
.onError(({ error, set }) => {
|
||||
console.error("Unhandled error:", error);
|
||||
set.status = 500;
|
||||
return { success: false, message: "Internal server error" };
|
||||
})
|
||||
.get("/health", () => ({ status: "ok", timestamp: new Date().toISOString() }))
|
||||
.use(bugReportRoutes)
|
||||
.use(adminRoutes)
|
||||
.listen({
|
||||
port: config.port,
|
||||
maxBody: 50 * 1024 * 1024, // 50MB
|
||||
});
|
||||
|
||||
console.log(
|
||||
`EMLy Bug Report API running on http://localhost:${app.server?.port}`
|
||||
);
|
||||
|
||||
// Graceful shutdown
|
||||
process.on("SIGINT", async () => {
|
||||
console.log("Shutting down...");
|
||||
await closePool();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", async () => {
|
||||
console.log("Shutting down...");
|
||||
await closePool();
|
||||
process.exit(0);
|
||||
});
|
||||
Reference in New Issue
Block a user