From dfbc9e183af3fbd28dc72f386b97f8df7b3de7c1 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 26 Jul 2018 13:09:54 +0000 Subject: [server/backends] Added iDoII Backend. Implemented a checkConnection method for each individual backend. Switches in backends can now have recursive elements. They are only shown if the switch is set to true. --- server/router.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server/router.js') diff --git a/server/router.js b/server/router.js index bde35a8..ab67f19 100644 --- a/server/router.js +++ b/server/router.js @@ -43,9 +43,10 @@ router.get('/backends/getCredentialsByType', auth.verifyToken, backends.getCrede router.get('/backends/getBackendInfoById', auth.verifyToken, backends.getBackendInfoById) router.get('/backends/getBackendList', auth.verifyToken, backends.getBackendList) router.get('/backends/getBackendTypes', backends.getBackendTypes) -router.get('/backends/checkConnection', auth.verifyToken, backends.checkConnection) +router.get('/backends/checkConnection', auth.verifyToken, backends.checkConnectionById) router.post('/backends/saveBackend', auth.verifyToken, backends.saveBackend) router.post('/backends/deleteBackends', auth.verifyToken, backends.deleteBackends) +router.post('/backends/checkConnection', auth.verifyToken, backends.checkConnection) // Load ipxe scipts API var ipxeloader = require(path.join(__dirname, 'api', 'ipxe-loader')) -- cgit v1.2.3-55-g7522 From f6cadb25e42e6568098f2962fa9b302cfbf074c5 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Sun, 29 Jul 2018 23:31:08 +0000 Subject: [server/router] changed api routing from query keyword to url parameter for group and client api (todo: the rest) --- server/api/clients.js | 18 ++++++-------- server/api/groups.js | 62 +++++++++++++++++++++++----------------------- server/models/client.js | 2 +- server/models/group.js | 2 +- server/router.js | 18 +++++++++++--- webapp/src/store/groups.js | 8 +++--- 6 files changed, 59 insertions(+), 51 deletions(-) (limited to 'server/router.js') diff --git a/server/api/clients.js b/server/api/clients.js index aeb4673..37e207b 100644 --- a/server/api/clients.js +++ b/server/api/clients.js @@ -3,18 +3,16 @@ var path = require('path') var db = require(path.join(__appdir, 'lib', 'sequelize')) module.exports = { - get: function (req, res) { - switch (req.query.action) { - case 'getInfo': - db.client.findOne({ where: { id: req.query.id }}).then(client => { - res.send(client) - }) - break - default: - res.end() + get: { + + getInfo: function (req, res) { + db.client.findOne({ where: { id: req.query.id } }).then(client => { + res.send(client) + }) } + }, - post: function (req, res) { + post: { } } diff --git a/server/api/groups.js b/server/api/groups.js index 8158d1c..ff29799 100644 --- a/server/api/groups.js +++ b/server/api/groups.js @@ -3,40 +3,40 @@ var path = require('path') var db = require(path.join(__appdir, 'lib', 'sequelize')) module.exports = { - get: function (req, res) { - var id = req.query.id > 0 ? req.query.id : null - switch (req.query.action) { - case 'getParents': - db.group.findOne({ where: { id: req.query.id }, include: ['parents']}).then(group => { - group.getParents().then(parents => { - res.send(parents.map(x => ({ id: x.id, name: x.name }))) - }) - }) - break - case 'getSubGroups': - db.group.findAll({ where: { '$parents.id$': id }, include: ['parents'] }).then(result => { - res.send(result) - }) - break - case 'getClients': - db.client.findAll({ where: { '$groups.id$': id }, include: ['groups'] }).then(result => { - res.send(result) + get: { + + getParents: function (req, res) { + const id = req.query.id > 0 ? req.query.id : null + db.group.findOne({ where: { id: id }, include: ['parents'] }).then(group => { + group.getParents().then(parents => { + res.send(parents.map(x => ({ id: x.id, name: x.name }))) }) - break - default: - res.end() + }) + }, + + getSubGroups: function (req, res) { + const id = req.query.id > 0 ? req.query.id : null + db.group.findAll({ where: { '$parents.id$': id }, include: ['parents'] }).then(result => { + res.send(result) + }) + }, + + getClients: function (req, res) { + const id = req.query.id > 0 ? req.query.id : null + db.client.findAll({ where: { '$groups.id$': id }, include: ['groups'] }).then(result => { + res.send(result) + }) } + }, - post: function (req, res) { - var id = req.body.id > 0 ? req.body.id : null - switch (req.body.action) { - case 'update': - if (!id) res.end() - db.group.update({ name: req.body.name }, { where: { id: id } }) - res.end() - break - default: - res.end() + post: { + + update: function (req, res) { + const id = req.body.id > 0 ? req.body.id : null + if (!id) res.end() + db.group.update({ name: req.body.name }, { where: { id: id } }) + res.end() } + } } diff --git a/server/models/client.js b/server/models/client.js index ad3bc28..1086023 100644 --- a/server/models/client.js +++ b/server/models/client.js @@ -14,8 +14,8 @@ module.exports = (sequelize, DataTypes) => { }, { timestamps: false }) - var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true }) client.associate = function (models) { + var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true }) client.belongsToMany(models.group, { as: 'groups', through: GroupXClient, foreignKey: 'clientId', otherKey: 'groupId'}) } return client diff --git a/server/models/group.js b/server/models/group.js index 9151db5..223df07 100644 --- a/server/models/group.js +++ b/server/models/group.js @@ -11,8 +11,8 @@ module.exports = (sequelize, DataTypes) => { }, { timestamps: false }) - var GroupXGroup = sequelize.define('group_x_group', {}, { timestamps: false, freezeTableName: true }) group.associate = function (models) { + var GroupXGroup = sequelize.define('group_x_group', {}, { timestamps: false, freezeTableName: true }) group.belongsToMany(group, { as: 'parents', through: GroupXGroup, foreignKey: 'childId', otherKey: 'parentId'}) } return group diff --git a/server/router.js b/server/router.js index bde35a8..6c0e4cd 100644 --- a/server/router.js +++ b/server/router.js @@ -2,6 +2,16 @@ var express = require('express') var router = express.Router() var path = require('path') +function mapActions (api, method) { + return function (req, res) { + if (method in api && req.params.action in api[method]) { + api[method][req.params.action](req, res) + } else { + res.status(501).end() + } + } +} + // Authentication routes var auth = require(path.join(__dirname, 'lib', 'authentication')) router.get('/auth', auth.auth) @@ -16,13 +26,13 @@ router.get('/user/info', auth.verifyToken, user.info) // Groups API var groups = require(path.join(__dirname, 'api', 'groups')) -router.get('/groups', groups.get) -router.post('/groups', groups.post) +router.get('/groups/:action', mapActions(groups, 'get')) +router.post('/groups/:action', mapActions(groups, 'post')) // Clients API var clients = require(path.join(__dirname, 'api', 'clients')) -router.get('/clients', clients.get) -router.post('/clients', clients.post) +router.get('/clients/:action', mapActions(clients, 'get')) +router.post('/clients/:action', mapActions(clients, 'post')) // Permissions API var permissions = require(path.join(__dirname, 'api', 'permissions')) diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js index 49c567a..8ce7f6b 100644 --- a/webapp/src/store/groups.js +++ b/webapp/src/store/groups.js @@ -29,8 +29,8 @@ export default { }, actions: { loadGroupInChain (context, { id, name, tabIndex, switchTab }) { - var getSubGroups = axios.get('/api/groups?action=getSubGroups&id=' + id) - var getClients = axios.get('/api/groups?action=getClients&id=' + id) + var getSubGroups = axios.get('/api/groups/getSubGroups?id=' + id) + var getClients = axios.get('/api/groups/getClients?id=' + id) axios.all([getSubGroups, getClients]).then(axios.spread((groupRespsonse, clientResponse) => { var group = { id: id, name: name, subGroups: groupRespsonse.data, clients: clientResponse.data } context.commit('setGroupInChain', { group: group, tabIndex: tabIndex }) @@ -38,12 +38,12 @@ export default { })) }, editGroup (context, { id, name }) { - axios.get('/api/groups?action=getParents&id=' + id).then(res => { + axios.get('/api/groups/getParents?id=' + id).then(res => { context.commit('openEditGroupDialog', { id: id, name: name, parents: res.data }) }) }, saveGroup (context) { - axios.post('/api/groups?action=update&id=' + context.state.editGroup.id).then(res => { + axios.post('/api/groups/update?id=' + context.state.editGroup.id).then(res => { context.commit('closeEditGroupDialog') }) } -- cgit v1.2.3-55-g7522 From b9186711eb2dedb475b5c77053f9c2a9a864066d Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Mon, 30 Jul 2018 00:24:48 +0000 Subject: [server/router] api calls are now dynamicly routed to the corresponding api module --- server/router.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'server/router.js') diff --git a/server/router.js b/server/router.js index 9e29f93..828f8b7 100644 --- a/server/router.js +++ b/server/router.js @@ -2,16 +2,6 @@ var express = require('express') var router = express.Router() var path = require('path') -function mapActions (api, method) { - return function (req, res) { - if (method in api && req.params.action in api[method]) { - api[method][req.params.action](req, res) - } else { - res.status(501).end() - } - } -} - // Authentication routes var auth = require(path.join(__dirname, 'lib', 'authentication')) router.get('/auth', auth.auth) @@ -20,20 +10,11 @@ router.post('/signup', auth.signup) router.post('/logout', auth.logout) router.post('/changepassword', auth.changePassword) +// ############ Legacy Code: TODO(Jannik): Rework to api and get/post or delete! ############ // User API var user = require(path.join(__dirname, 'api', 'user')) router.get('/user/info', auth.verifyToken, user.info) -// Groups API -var groups = require(path.join(__dirname, 'api', 'groups')) -router.get('/groups/:action', mapActions(groups, 'get')) -router.post('/groups/:action', mapActions(groups, 'post')) - -// Clients API -var clients = require(path.join(__dirname, 'api', 'clients')) -router.get('/clients/:action', mapActions(clients, 'get')) -router.post('/clients/:action', mapActions(clients, 'post')) - // Permissions API var permissions = require(path.join(__dirname, 'api', 'permissions')) router.get('/getRolesByUserid', permissions.getRolesByUserid) @@ -61,5 +42,22 @@ router.post('/backends/checkConnection', auth.verifyToken, backends.checkConnect // Load ipxe scipts API var ipxeloader = require(path.join(__dirname, 'api', 'ipxe-loader')) router.get('/ipxe-loader/load-script', ipxeloader.loadScript) +// ############################################################################ + +// Dynamic API routes +function mapApi (method) { + return function (req, res) { + var api = require(path.join(__dirname, 'api', req.params.api)) + if (method in api && req.params.action in api[method]) { + api[method][req.params.action](req, res) + } else { + res.status(501).end() + } + } +} + +// Every API can be called with // +router.get('/:api/:action', auth.verifyToken, mapApi('get')) +router.post('/:api/:action', auth.verifyToken, mapApi('post')) module.exports = router -- cgit v1.2.3-55-g7522 From ce9a81e6361504ea68286cd9fda72391d0aaba12 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Mon, 30 Jul 2018 03:06:35 +0000 Subject: [server] Changed old modules to the new rounter restructure. --- server/api/backends.js | 48 ++++++++++++++++++++++++++++++---------------- server/api/ipxe-loader.js | 42 ---------------------------------------- server/api/ipxe.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++ server/lib/shell.js | 2 +- server/router.js | 24 +---------------------- 5 files changed, 82 insertions(+), 83 deletions(-) delete mode 100644 server/api/ipxe-loader.js create mode 100644 server/api/ipxe.js (limited to 'server/router.js') diff --git a/server/api/backends.js b/server/api/backends.js index 3b9551e..e4d3ff6 100644 --- a/server/api/backends.js +++ b/server/api/backends.js @@ -3,7 +3,8 @@ const path = require('path') const ExternalBackends = require(path.join(__appdir, 'lib', 'external-backends', 'external-backends.js')) var db = require(path.join(__appdir, 'lib', 'sequelize')) -module.exports = { +// GET requests +module.exports.get = { getCredentialsByType: function (req, res) { const backendType = req.query.type const b = new ExternalBackends() @@ -14,7 +15,7 @@ module.exports = { res.status(200).send(instance.getCredentials()) }, - getBackendInfoById: function (req, res) { + getInfoById: function (req, res) { const backendId = req.query.id db.backend.findOne({ where: { id: backendId } }).then(backend => { const b = { @@ -27,7 +28,7 @@ module.exports = { }) }, - getBackendTypes: function (req, res) { + getTypes: function (req, res) { const backends = new ExternalBackends() var files = backends.getBackends() @@ -39,7 +40,7 @@ module.exports = { res.status(200).send(files) }, - getBackendList: function (req, res) { + getList: function (req, res) { db.backend.findAll({ attributes: ['id', 'name', 'type'] }).then(function (backends) { @@ -62,10 +63,12 @@ module.exports = { res.status(200).send({ success: connection.success, msg: connection.msg }) }) }) - }, + } +} - // POST REQUESTS - saveBackend: function (req, res) { +// POST requests +module.exports.post = { + save: function (req, res) { // Save credentials in the db. const formData = req.body const credentialString = JSON.stringify(formData.backendCredentials) @@ -82,7 +85,7 @@ module.exports = { res.status(200).send('success') }, - deleteBackends: function (req, res) { + delete: function (req, res) { const backendIds = req.body.id db.backend.destroy({ where: { id: backendIds } }).then(function () { @@ -90,15 +93,26 @@ module.exports = { }) }, + // If id is set the backend connection in the db is testest. + // Else backendinfo has to be set manually, to test unsaved connections. checkConnection: function (req, res) { - const type = req.body.backendType - // const credentials = req.body.backendCredentials + const id = req.body.id - const b = new ExternalBackends() - const instance = b.getInstance(type) - instance.checkConnection().then(connection => { - res.status(200).send({ success: connection.success, msg: connection.msg }) - }) - // TODO: Set credentials + var getBackend = null + if (id) getBackend = db.backend.findOne({ where: { id: id } }) + else getBackend = new Promise(resolve => resolve(req.body)) + + getBackend.then(backend => { + var bCredentials = { + type: backend.type, + credentials: backend.credentials + } + // Creating the backend instance and calling the specific checkConnection. + const b = new ExternalBackends() + const instance = b.getInstance(bCredentials.type) + instance.checkConnection(bCredentials).then(connection => { + res.status(200).send({ success: connection.success, msg: connection.msg }) + }) + }) } -} +} \ No newline at end of file diff --git a/server/api/ipxe-loader.js b/server/api/ipxe-loader.js deleted file mode 100644 index c484578..0000000 --- a/server/api/ipxe-loader.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - loadScript: function (req, res) { - res.setHeader('content-type', 'text/plain') - res.status(200).send(`#!ipxe -dhcp - -:start -menu Please choose a webserver to load the ipxe menu: -item pxelnx PxeLinux -item exit Exit -item exit0 Exit0 -item exit1 Exit1 -item sh [Shell] -choose target && goto \${target} - -:exit -exit -:exit0 -exit 0 -:exit1 -exit 1 -:pxelnx -# set 210:string https://bas.stfu-kthx.net:8888/ -# chain \${210:string}pxelinux.0 || goto start -# chain https://bas.stfu-kthx.net:8888/pxelinux.0 -# set next-server bas-stfu-kthx.net:8888 -# set 209:string https://bas.stfu-kthx.net:8888/pxelinux.cfg -# imgload pxelinux.0 -set net0/next-server 192.52.3.91 || -set netX/next-server 192.52.3.91 || -set next-server 192.52.3.91 || - -# set 209:string pxelinux.cfg/default -# set 210:string bas.stfu-kthx.net -shell || -boot tftp://bas.stfu-kthx.net/pxelinux.0 || goto start - -:sh -shell -goto start`) - } -} diff --git a/server/api/ipxe.js b/server/api/ipxe.js new file mode 100644 index 0000000..79c0ad8 --- /dev/null +++ b/server/api/ipxe.js @@ -0,0 +1,49 @@ +/* global __appdir */ +var path = require('path') +var shell = require(path.join(__appdir, 'lib', 'shell')) + +module.exports.get = { + build: function(req, res) { + shell.buildIpxe(req, res) + }, + loadScript: function (req, res) { + res.setHeader('content-type', 'text/plain') + res.status(200).send(`#!ipxe +dhcp + +:start +menu Please choose a webserver to load the ipxe menu: +item pxelnx PxeLinux +item exit Exit +item exit0 Exit0 +item exit1 Exit1 +item sh [Shell] +choose target && goto \${target} + +:exit +exit +:exit0 +exit 0 +:exit1 +exit 1 +:pxelnx +# set 210:string https://bas.stfu-kthx.net:8888/ +# chain \${210:string}pxelinux.0 || goto start +# chain https://bas.stfu-kthx.net:8888/pxelinux.0 +# set next-server bas-stfu-kthx.net:8888 +# set 209:string https://bas.stfu-kthx.net:8888/pxelinux.cfg +# imgload pxelinux.0 +set net0/next-server 192.52.3.91 || +set netX/next-server 192.52.3.91 || +set next-server 192.52.3.91 || + +# set 209:string pxelinux.cfg/default +# set 210:string bas.stfu-kthx.net +shell || +boot tftp://bas.stfu-kthx.net/pxelinux.0 || goto start + +:sh +shell +goto start`) + } +} diff --git a/server/lib/shell.js b/server/lib/shell.js index 311af1d..e0782f1 100644 --- a/server/lib/shell.js +++ b/server/lib/shell.js @@ -4,7 +4,7 @@ var shell = require('shelljs') var ipxeGIT = 'git://git.ipxe.org/ipxe.git' module.exports = { - buildIPXE: function (req, res) { + buildIpxe: function (req, res) { if (!shell.which('git')) { return res.status(500).send({ status: 'GIT_MISSING', error_message: 'Please install git on the server.' }) } diff --git a/server/router.js b/server/router.js index 828f8b7..7d5613a 100644 --- a/server/router.js +++ b/server/router.js @@ -10,7 +10,7 @@ router.post('/signup', auth.signup) router.post('/logout', auth.logout) router.post('/changepassword', auth.changePassword) -// ############ Legacy Code: TODO(Jannik): Rework to api and get/post or delete! ############ +// ############ Legacy Code: TODO(Chris): Rework to api and get/post or delete! ############ // User API var user = require(path.join(__dirname, 'api', 'user')) router.get('/user/info', auth.verifyToken, user.info) @@ -20,28 +20,6 @@ var permissions = require(path.join(__dirname, 'api', 'permissions')) router.get('/getRolesByUserid', permissions.getRolesByUserid) router.post('/getRoleById', auth.verifyToken, permissions.getRoleById) -// Shell API -var shell = require(path.join(__dirname, 'lib', 'shell')) -router.get('/shell/buildipxe', shell.buildIPXE) - -// Nodemailer API -var nodemailer = require(path.join(__dirname, 'lib', 'nodemailer')) -router.get('/mail/send', nodemailer.sendMail) - -// External backends API -var backends = require(path.join(__dirname, 'api', 'backends')) -router.get('/backends/getCredentialsByType', auth.verifyToken, backends.getCredentialsByType) -router.get('/backends/getBackendInfoById', auth.verifyToken, backends.getBackendInfoById) -router.get('/backends/getBackendList', auth.verifyToken, backends.getBackendList) -router.get('/backends/getBackendTypes', backends.getBackendTypes) -router.get('/backends/checkConnection', auth.verifyToken, backends.checkConnectionById) -router.post('/backends/saveBackend', auth.verifyToken, backends.saveBackend) -router.post('/backends/deleteBackends', auth.verifyToken, backends.deleteBackends) -router.post('/backends/checkConnection', auth.verifyToken, backends.checkConnection) - -// Load ipxe scipts API -var ipxeloader = require(path.join(__dirname, 'api', 'ipxe-loader')) -router.get('/ipxe-loader/load-script', ipxeloader.loadScript) // ############################################################################ // Dynamic API routes -- cgit v1.2.3-55-g7522 From 331cea8ca1f2d399f87feaf12665d5461ea962d9 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 31 Jul 2018 13:42:43 +0000 Subject: [server/ipxe] Fixed the embedded ipxe script to the router restructure. --- server/api/ipxe.js | 9 +++++++-- server/ipxe/main.ipxe | 2 +- server/router.js | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'server/router.js') diff --git a/server/api/ipxe.js b/server/api/ipxe.js index a19e744..3e8dd9a 100644 --- a/server/api/ipxe.js +++ b/server/api/ipxe.js @@ -14,6 +14,7 @@ dhcp :start menu Please choose a webserver to load the ipxe menu: item pxelnx PxeLinux +item c32boot C32Boot item exit Exit item exit0 Exit0 item exit1 Exit1 @@ -36,11 +37,15 @@ exit 1 set net0/next-server 192.52.3.91 || set netX/next-server 192.52.3.91 || set next-server 192.52.3.91 || - # set 209:string pxelinux.cfg/default # set 210:string bas.stfu-kthx.net -shell || +# shell || boot tftp://bas.stfu-kthx.net/pxelinux.0 || goto start +:c32boot +set net0/next-server 192.52.3.91 || +set netX/next-server 192.52.3.91 || +set next-server 192.52.3.91 || +boot tftp://bas.stfu-kthx.net/chain.c32 || goto start :sh shell diff --git a/server/ipxe/main.ipxe b/server/ipxe/main.ipxe index fa1f492..763725a 100644 --- a/server/ipxe/main.ipxe +++ b/server/ipxe/main.ipxe @@ -15,7 +15,7 @@ choose target && goto ${target} :js set crosscert http://ca.ipxe.org/auto/ -chain https://bas.stfu-kthx.net/api/ipxe-loader/load-script +chain https://bas.stfu-kthx.net:8888/api/ipxe/loadScript || goto start :uw chain http://10.4.9.115/boot.php diff --git a/server/router.js b/server/router.js index 7d5613a..e460771 100644 --- a/server/router.js +++ b/server/router.js @@ -10,6 +10,10 @@ router.post('/signup', auth.signup) router.post('/logout', auth.logout) router.post('/changepassword', auth.changePassword) +// Public callable functions. +var ipxe = require(path.join(__dirname, 'api', 'ipxe')) +router.get('/ipxe/loadScript', ipxe.get.loadScript) + // ############ Legacy Code: TODO(Chris): Rework to api and get/post or delete! ############ // User API var user = require(path.join(__dirname, 'api', 'user')) -- cgit v1.2.3-55-g7522 From fe619505b8b3b91f940ea6dbeb8079ffe4812897 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Sat, 4 Aug 2018 04:11:39 +0000 Subject: [webapp+server] switched from hash mode routing to history mode --- server/app.js | 5 +++-- server/router.js | 4 ++++ webapp/src/router.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'server/router.js') diff --git a/server/app.js b/server/app.js index 8a18b58..6ae77e5 100644 --- a/server/app.js +++ b/server/app.js @@ -26,11 +26,12 @@ app.use(cookieParser()) // ############################################################################ // ########################### setup routes ################################## -app.use(express.static('public')) - var apiRouter = require(path.join(__dirname, 'router')) app.use('/api', apiRouter) +app.use(express.static('public')) +app.use('*', express.static('public/index.html')) + // ############################################################################ // ######################### handle http errors ############################### diff --git a/server/router.js b/server/router.js index e460771..53caca8 100644 --- a/server/router.js +++ b/server/router.js @@ -42,4 +42,8 @@ function mapApi (method) { router.get('/:api/:action', auth.verifyToken, mapApi('get')) router.post('/:api/:action', auth.verifyToken, mapApi('post')) +router.use('*', (req, res) => { + res.status(404).end() +}) + module.exports = router diff --git a/webapp/src/router.js b/webapp/src/router.js index 9b432e5..35d0d6a 100644 --- a/webapp/src/router.js +++ b/webapp/src/router.js @@ -18,6 +18,7 @@ function setChildren (routes, parent) { } var router = new Router({ + mode: 'history', routes: [ { path: '/login', -- cgit v1.2.3-55-g7522 From 7fd2c7287794440653b589c3c662e0d582d35a80 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Sat, 4 Aug 2018 04:18:48 +0000 Subject: [server] revert unnecessary change --- server/app.js | 5 ++--- server/router.js | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'server/router.js') diff --git a/server/app.js b/server/app.js index 6ae77e5..8a18b58 100644 --- a/server/app.js +++ b/server/app.js @@ -26,12 +26,11 @@ app.use(cookieParser()) // ############################################################################ // ########################### setup routes ################################## +app.use(express.static('public')) + var apiRouter = require(path.join(__dirname, 'router')) app.use('/api', apiRouter) -app.use(express.static('public')) -app.use('*', express.static('public/index.html')) - // ############################################################################ // ######################### handle http errors ############################### diff --git a/server/router.js b/server/router.js index 53caca8..e460771 100644 --- a/server/router.js +++ b/server/router.js @@ -42,8 +42,4 @@ function mapApi (method) { router.get('/:api/:action', auth.verifyToken, mapApi('get')) router.post('/:api/:action', auth.verifyToken, mapApi('post')) -router.use('*', (req, res) => { - res.status(404).end() -}) - module.exports = router -- cgit v1.2.3-55-g7522 From 5758ff03f30e03f6d077e227cc9118a8f9ff8096 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Sat, 4 Aug 2018 04:34:45 +0000 Subject: nvm --- server/app.js | 5 +++-- server/router.js | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'server/router.js') diff --git a/server/app.js b/server/app.js index 8a18b58..6ae77e5 100644 --- a/server/app.js +++ b/server/app.js @@ -26,11 +26,12 @@ app.use(cookieParser()) // ############################################################################ // ########################### setup routes ################################## -app.use(express.static('public')) - var apiRouter = require(path.join(__dirname, 'router')) app.use('/api', apiRouter) +app.use(express.static('public')) +app.use('*', express.static('public/index.html')) + // ############################################################################ // ######################### handle http errors ############################### diff --git a/server/router.js b/server/router.js index e460771..53caca8 100644 --- a/server/router.js +++ b/server/router.js @@ -42,4 +42,8 @@ function mapApi (method) { router.get('/:api/:action', auth.verifyToken, mapApi('get')) router.post('/:api/:action', auth.verifyToken, mapApi('post')) +router.use('*', (req, res) => { + res.status(404).end() +}) + module.exports = router -- cgit v1.2.3-55-g7522