@@ -40,6 +40,9 @@ app.use('/api/user', middleware.auth, require('./routes/user'));
|
|||||||
// API routes for working with hosts. All endpoints need to be have valid user.
|
// API routes for working with hosts. All endpoints need to be have valid user.
|
||||||
app.use('/api/host', middleware.auth, require('./routes/host'));
|
app.use('/api/host', middleware.auth, require('./routes/host'));
|
||||||
|
|
||||||
|
// API routes for working with hosts. All endpoints need to be have valid user.
|
||||||
|
app.use('/api/cert', middleware.auth, require('./routes/cert'));
|
||||||
|
|
||||||
app.controler = {
|
app.controler = {
|
||||||
host: require('./controler/host')
|
host: require('./controler/host')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const {createClient} = require('redis');
|
||||||
|
const client = createClient({});
|
||||||
|
|
||||||
|
client.connect();
|
||||||
|
|
||||||
|
async function getCert(host){
|
||||||
|
try{
|
||||||
|
console.log('looking for', host);
|
||||||
|
return JSON.parse(await client.GET(`${host}:latest`));
|
||||||
|
}catch(error){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {getCert};
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const router = require('express').Router();
|
||||||
|
const {getCert} = require('../models/cert');
|
||||||
|
|
||||||
|
|
||||||
|
router.get('/:host', async function(req, res, next){
|
||||||
|
try{
|
||||||
|
return res.json(await getCert(req.params.host));
|
||||||
|
}catch(error){
|
||||||
|
return next(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user