WIP quickbooks testing.

This commit is contained in:
Patrick Fic
2025-03-27 11:57:57 -07:00
parent e2ccbf7007
commit 7d59796f49
10 changed files with 755 additions and 1040 deletions

View File

@@ -2,6 +2,8 @@ import cors from "cors";
import { app } from "electron";
import log from "electron-log/main";
import express from "express";
import { handleQuickBookRequest } from "../quickbooks-desktop/quickbooks-desktop";
import errorTypeCheck from "../../util/errorTypeCheck";
export default class LocalServer {
private app: express.Application;
@@ -94,7 +96,7 @@ export default class LocalServer {
private configureRoutes(): void {
// Basic health check endpoint
this.app.get("/health", (req, res) => {
this.app.get("/health", (req: express.Request, res: express.Response) => {
res.status(200).json({ status: "ok" });
});
this.app.post("/ping", (req, res) => {
@@ -103,13 +105,25 @@ export default class LocalServer {
qbPath: app.getPath("userData"), //TODO: Resolve to actual QB file path.
});
});
this.app.post("/qb", handleQuickBookRequest);
// Add more routes as needed
}
public start(): void {
this.server = this.app.listen(this.PORT, () => {
log.info(`[HTTP Server] Local HTTP server running on port ${this.PORT}`);
});
try {
this.server = this.app.listen(this.PORT, (error: Error) => {
if (error) {
log.error(`[HTTP Server] Error starting server: ${error}`);
} else {
log.info(
`[HTTP Server] Local HTTP server running on port ${this.PORT}`,
);
}
});
} catch (error: unknown) {
log.error("[HTTP Server] Error starting server", errorTypeCheck(error));
}
}
public stop(): void {