diff --git a/routes/ssh.js b/routes/ssh.js index b5cd5e9..a6b85cf 100644 --- a/routes/ssh.js +++ b/routes/ssh.js @@ -6,6 +6,7 @@ let express = require("express"); let db = require("../libs/Database").instance(); let router = express.Router(); let userRouter = express.Router(); +let deployRouter = express.Router(); function combineToList(a, b) { return a + "\n" + b; @@ -15,11 +16,12 @@ function toList(array) { return array.reduce(combineToList, "").trim(); } -router.use(["/user", "/users", "/userKeys"], userRouter); +router.use(["/u", "/user", "/users", "/userKeys"], userRouter); +router.use(["/d", "/deploy", "/deployKeys"], deployRouter); -function userReq(req, res) { +function keyReq(table, req, res) { let p = req.params; - let q = db.q.from("sshUserKeys").select("publicKeyComment"); + let q = db.q.from(table).select("publicKeyComment"); if (p.user) q.filter("user", p.user); if (p.host) q.filter("host", p.host); if (p.type) q.filter("type", p.type); @@ -39,6 +41,9 @@ function userReq(req, res) { "/@" + host + "/" + type, "/" + user + "/" + type, "/" + user + "@" + host + "/" + type, -].forEach(e => userRouter.get(e, (req, res) => userReq(req, res))); +].forEach(e => { + userRouter.get(e, (req, res) => keyReq("sshUserKeys", req, res)); + deployRouter.get(e, (req, res) => keyReg("sshDeployKeys", req, res)); +}); module.exports = router; \ No newline at end of file