Added socket.io
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const router = require('express').Router();
|
||||
const conf = require('../conf');
|
||||
const middleware = require('../middleware/auth');
|
||||
|
||||
// API routes for authentication.
|
||||
router.use('/auth', require('./auth'));
|
||||
|
||||
// API routes for working with users. All endpoints need to be have valid user.
|
||||
router.use('/user', middleware.auth, require('./user'));
|
||||
|
||||
// API routes for working with hosts. All endpoints need to be have valid user.
|
||||
router.use('/host', middleware.auth, require('./host'));
|
||||
|
||||
// API routes for working with hosts. All endpoints need to be have valid user.
|
||||
router.use('/cert', middleware.auth, require('./cert'));
|
||||
|
||||
module.exports = router;
|
||||
+2
-38
@@ -1,9 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const router = require('express').Router();
|
||||
const {User} = require('../models/user');
|
||||
const {Auth, AuthToken} = require('../models/auth');
|
||||
|
||||
const { Auth } = require('../controller/auth');
|
||||
|
||||
router.post('/login', async function(req, res, next){
|
||||
try{
|
||||
@@ -11,6 +9,7 @@ router.post('/login', async function(req, res, next){
|
||||
return res.json({
|
||||
login: true,
|
||||
token: auth.token.token,
|
||||
message:`${req.body.username} logged in!`,
|
||||
});
|
||||
}catch(error){
|
||||
next(error);
|
||||
@@ -29,39 +28,4 @@ router.all('/logout', async function(req, res, next){
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/invite/:token', async function(req, res, next) {
|
||||
try{
|
||||
req.body.token = req.params.token;
|
||||
let user = await User.addByInvite(req.body);
|
||||
let token = await AuthToken.add(user);
|
||||
|
||||
return res.json({
|
||||
user: user.username,
|
||||
token: token.token
|
||||
});
|
||||
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
/*
|
||||
verify public ssh key
|
||||
*/
|
||||
// router.post('/verifykey', async function(req, res){
|
||||
// let key = req.body.key;
|
||||
|
||||
// try{
|
||||
// return res.json({
|
||||
// info: await Users.verifyKey(key)
|
||||
// });
|
||||
// }catch(error){
|
||||
// return res.status(400).json({
|
||||
// message: 'Key is not a public key file!'
|
||||
// });
|
||||
// }
|
||||
|
||||
// });
|
||||
@@ -3,7 +3,6 @@
|
||||
const router = require('express').Router();
|
||||
const {Host} = require('../models/host');
|
||||
|
||||
|
||||
const Model = Host;
|
||||
|
||||
router.get('/', async function(req, res, next){
|
||||
|
||||
+18
-2
@@ -1,13 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const express = require('express');
|
||||
const router = require('express').Router();
|
||||
const conf = require('../conf')
|
||||
const middleware = require('../middleware/auth');
|
||||
const conf = require('../conf');
|
||||
|
||||
const values ={
|
||||
title: conf.environment !== 'production' ? `<i class="fa-brands fa-dev"></i>` : ''
|
||||
}
|
||||
|
||||
// List of front end node modules to be served
|
||||
const frontEndModules = ['bootstrap', 'mustache', 'jquery', '@fortawesome',
|
||||
'moment',
|
||||
];
|
||||
|
||||
// Server front end modules
|
||||
// https://stackoverflow.com/a/55700773/3140931
|
||||
frontEndModules.forEach(dep => {
|
||||
router.use(`/static-modules/${dep}`, express.static(path.join(__dirname, `../node_modules/${dep}`)))
|
||||
});
|
||||
|
||||
// Have express server static content( images, CSS, browser JS) from the public
|
||||
// local folder.
|
||||
router.use('/static', express.static(path.join(__dirname, '../public')))
|
||||
|
||||
router.get('/', async function(req, res, next) {
|
||||
res.render('hosts', {...values});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user