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:
parent
899f743ed6
commit
b40ed5ce49
9 changed files with 27 additions and 22 deletions
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue