You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
718 B
25 lines
718 B
import PromiseRouter from "express-promise-router"; |
|
|
|
import ApiError from "@common/ApiError"; |
|
import { ErrorCode } from "@common/ErrorCode"; |
|
import { ServerState } from "@server/state"; |
|
|
|
import { devices } from "./devices"; |
|
import { mosquitto } from "./mosquitto"; |
|
import { token } from "./token"; |
|
import { users } from "./users"; |
|
|
|
export default function createApi(state: ServerState) { |
|
const router = PromiseRouter(); |
|
|
|
router.use("/devices", devices(state)); |
|
router.use("/users", users(state)); |
|
router.use("/mosquitto", mosquitto(state)); |
|
router.use("/token", token(state)); |
|
|
|
router.use("*", (req, res) => { |
|
throw new ApiError("API endpoint not found", ErrorCode.NotFound); |
|
}); |
|
|
|
return router; |
|
}
|
|
|