identities
parent
650a69606b
commit
b5bb38a1fa
|
|
@ -1,9 +1,17 @@
|
|||
const express = require('express');
|
||||
const { Router } = express;
|
||||
const router = new Router()
|
||||
const identity = require('../src/identity.js')
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
res.json({
|
||||
identities: await identity.get.all()
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/:guid', (req, res) => {
|
||||
console.log(req);
|
||||
console.log(req.param.guid);
|
||||
res.json({});
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
|
|
@ -2,19 +2,14 @@ const express = require('express');
|
|||
const { Router } = express;
|
||||
const api = new Router()
|
||||
|
||||
api.use('/identity', )
|
||||
|
||||
api.get('/', (req, res) => {
|
||||
res.json({
|
||||
up: true,
|
||||
time: new Date().getTime(),
|
||||
identities: [
|
||||
{
|
||||
name: 'example'
|
||||
}
|
||||
]
|
||||
identity: '/identity'
|
||||
})
|
||||
})
|
||||
|
||||
api.use('/identity', require('./identity.js'))
|
||||
|
||||
module.exports = api;
|
||||
|
|
@ -34,7 +34,8 @@ async function getAllIdentities() {
|
|||
identities.find({}, (err, docs) => {
|
||||
const names = docs.reduce((acc, obj) => {
|
||||
if(obj._id in acc) return acc;
|
||||
else acc[obj._id] = obj.name;
|
||||
acc[obj._id] = obj.name;
|
||||
return acc;
|
||||
}, {});
|
||||
res(names);
|
||||
})
|
||||
|
|
@ -46,4 +47,10 @@ module.exports = {
|
|||
get: Object.assign(getIdentity, {
|
||||
all: getAllIdentities
|
||||
})
|
||||
};
|
||||
|
||||
(async function() {
|
||||
if(Object.keys(await getAllIdentities()).length === 0) {
|
||||
createIdentity('Default');
|
||||
}
|
||||
})();
|
||||
Loading…
Reference in New Issue