Serve both UI assets and REST API from handler

This commit is contained in:
Ken Hibino
2021-10-10 06:33:38 -07:00
parent b20cf02f3b
commit ccdd6cea01
35 changed files with 620 additions and 234 deletions

View File

@@ -5,7 +5,7 @@ import queryString from "query-string";
// the static file server.
// In developement, we assume that the API server is listening on port 8080.
const BASE_URL =
process.env.NODE_ENV === "production" ? "/api" : "http://localhost:8080/api";
process.env.NODE_ENV === "production" ? `${window.ROOT_PATH}/api` : `http://localhost:8080${window.ROOT_PATH}/api`;
export interface ListQueuesResponse {
queues: Queue[];

5
ui/src/global.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
interface Window {
// Root URL path for asynqmon app.
// ROOT_PATH should not have the tailing slash.
ROOT_PATH: string;
}

View File

@@ -1,11 +1,11 @@
export const paths = {
HOME: "/",
SETTINGS: "/settings",
SERVERS: "/servers",
SCHEDULERS: "/schedulers",
QUEUE_DETAILS: "/queues/:qname",
REDIS: "/redis",
TASK_DETAILS: "/queues/:qname/tasks/:taskId",
HOME: `${window.ROOT_PATH}/`,
SETTINGS: `${window.ROOT_PATH}/settings`,
SERVERS: `${window.ROOT_PATH}/servers`,
SCHEDULERS: `${window.ROOT_PATH}/schedulers`,
QUEUE_DETAILS: `${window.ROOT_PATH}/queues/:qname`,
REDIS: `${window.ROOT_PATH}/redis`,
TASK_DETAILS: `${window.ROOT_PATH}/queues/:qname/tasks/:taskId`,
};
/**************************************************************