Update Server.js
This commit is contained in:
parent
563cb77176
commit
6bbd46e7df
|
@ -35,7 +35,7 @@ module.exports = class Server {
|
||||||
})))
|
})))
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
.get('/api/session', Util.promisify(async req => {
|
.get('/api/session', Util.promisify(async (req) => {
|
||||||
const requiresPassword = !!process.env.PASSWORD;
|
const requiresPassword = !!process.env.PASSWORD;
|
||||||
const authenticated = requiresPassword
|
const authenticated = requiresPassword
|
||||||
? !!(req.session && req.session.authenticated)
|
? !!(req.session && req.session.authenticated)
|
||||||
|
@ -46,7 +46,7 @@ module.exports = class Server {
|
||||||
authenticated,
|
authenticated,
|
||||||
};
|
};
|
||||||
}))
|
}))
|
||||||
.post('/api/session', Util.promisify(async req => {
|
.post('/api/session', Util.promisify(async (req) => {
|
||||||
const {
|
const {
|
||||||
password,
|
password,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
@ -79,14 +79,14 @@ module.exports = class Server {
|
||||||
error: 'Not Logged In',
|
error: 'Not Logged In',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.delete('/api/session', Util.promisify(async req => {
|
.delete('/api/session', Util.promisify(async (req) => {
|
||||||
const sessionId = req.session.id;
|
const sessionId = req.session.id;
|
||||||
|
|
||||||
req.session.destroy();
|
req.session.destroy();
|
||||||
|
|
||||||
debug(`Deleted Session: ${sessionId}`);
|
debug(`Deleted Session: ${sessionId}`);
|
||||||
}))
|
}))
|
||||||
.get('/api/wireguard/client', Util.promisify(async req => {
|
.get('/api/wireguard/client', Util.promisify(async (req) => {
|
||||||
return WireGuard.getClients();
|
return WireGuard.getClients();
|
||||||
}))
|
}))
|
||||||
.get('/api/wireguard/client/:clientId/qrcode.svg', Util.promisify(async (req, res) => {
|
.get('/api/wireguard/client/:clientId/qrcode.svg', Util.promisify(async (req, res) => {
|
||||||
|
@ -108,28 +108,28 @@ module.exports = class Server {
|
||||||
res.header('Content-Type', 'text/plain');
|
res.header('Content-Type', 'text/plain');
|
||||||
res.send(config);
|
res.send(config);
|
||||||
}))
|
}))
|
||||||
.post('/api/wireguard/client', Util.promisify(async req => {
|
.post('/api/wireguard/client', Util.promisify(async (req) => {
|
||||||
const { name } = req.body;
|
const { name } = req.body;
|
||||||
return WireGuard.createClient({ name });
|
return WireGuard.createClient({ name });
|
||||||
}))
|
}))
|
||||||
.delete('/api/wireguard/client/:clientId', Util.promisify(async req => {
|
.delete('/api/wireguard/client/:clientId', Util.promisify(async (req) => {
|
||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
return WireGuard.deleteClient({ clientId });
|
return WireGuard.deleteClient({ clientId });
|
||||||
}))
|
}))
|
||||||
.post('/api/wireguard/client/:clientId/enable', Util.promisify(async req => {
|
.post('/api/wireguard/client/:clientId/enable', Util.promisify(async (req) => {
|
||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
return WireGuard.enableClient({ clientId });
|
return WireGuard.enableClient({ clientId });
|
||||||
}))
|
}))
|
||||||
.post('/api/wireguard/client/:clientId/disable', Util.promisify(async req => {
|
.post('/api/wireguard/client/:clientId/disable', Util.promisify(async (req) => {
|
||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
return WireGuard.disableClient({ clientId });
|
return WireGuard.disableClient({ clientId });
|
||||||
}))
|
}))
|
||||||
.put('/api/wireguard/client/:clientId/name', Util.promisify(async req => {
|
.put('/api/wireguard/client/:clientId/name', Util.promisify(async (req) => {
|
||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
const { name } = req.body;
|
const { name } = req.body;
|
||||||
return WireGuard.updateClientName({ clientId, name });
|
return WireGuard.updateClientName({ clientId, name });
|
||||||
}))
|
}))
|
||||||
.put('/api/wireguard/client/:clientId/address', Util.promisify(async req => {
|
.put('/api/wireguard/client/:clientId/address', Util.promisify(async (req) => {
|
||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
const { address } = req.body;
|
const { address } = req.body;
|
||||||
return WireGuard.updateClientAddress({ clientId, address });
|
return WireGuard.updateClientAddress({ clientId, address });
|
||||||
|
|
Loading…
Reference in New Issue