3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 13:55:03 +00:00

feat: add api prefix option

This commit is contained in:
Dragory 2024-04-06 11:54:31 +00:00
parent 899f743ed6
commit b40ed5ce49
No known key found for this signature in database
9 changed files with 27 additions and 22 deletions

View file

@ -10,6 +10,8 @@ import { initGuildsAPI } from "./guilds/index";
import { clientError, error, notFound } from "./responses";
import { startBackgroundTasks } from "./tasks";
const apiPathPrefix = env.HOST_MODE === "lightweight" ? env.LIGHTWEIGHT_API_PATH_PREFIX || "" : "/api";
const app = express();
app.use(
@ -24,16 +26,20 @@ app.use(
);
app.use(multer().none());
const rootRouter = express.Router();
initAuth(app);
initGuildsAPI(app);
initArchives(app);
initDocs(app);
// Default route
app.get("/", (req, res) => {
rootRouter.get("/", (req, res) => {
res.json({ status: "cookies", with: "milk" });
});
app.use(apiPathPrefix, rootRouter);
// Error response
// eslint-disable-next-line @typescript-eslint/no-unused-vars
app.use((err, req, res, next) => {