Reorganized routes code into a separate file
This commit is contained in:
@ -1,9 +1,33 @@
|
||||
const Project = require('../models').models.Project;
|
||||
// load routes
|
||||
const topRoutes = require('./toplevel');
|
||||
const projectRoutes = require('./project');
|
||||
const hardwareRoutes = require('./hardware');
|
||||
const benchmarkRoutes = require('./benchmark');
|
||||
|
||||
module.exports = function(app) {
|
||||
|
||||
// top-level routes
|
||||
app.get('/', topRoutes.getIndex);
|
||||
|
||||
// project routes
|
||||
app.get('/project', projectRoutes.getIndex);
|
||||
app.get('/project/list', projectRoutes.getList);
|
||||
app.get('/project/add', projectRoutes.getAdd);
|
||||
app.post('/project/add', projectRoutes.postAdd);
|
||||
app.get('/project/:project_id', projectRoutes.getView);
|
||||
|
||||
// hardware routes
|
||||
app.get('/hardware', hardwareRoutes.getIndex);
|
||||
app.get('/hardware/list', hardwareRoutes.getList);
|
||||
app.get('/hardware/add', hardwareRoutes.getAdd);
|
||||
app.post('/hardware/add', hardwareRoutes.postAdd);
|
||||
app.get('/hardware/:hardware_id', hardwareRoutes.getView);
|
||||
|
||||
// benchmark routes
|
||||
app.get('/benchmark', benchmarkRoutes.getIndex);
|
||||
app.get('/benchmark/list', benchmarkRoutes.getList);
|
||||
app.get('/benchmark/add', benchmarkRoutes.getAdd);
|
||||
app.post('/benchmark/add', benchmarkRoutes.postAdd);
|
||||
app.get('/benchmark/:benchmark_id', benchmarkRoutes.getView);
|
||||
|
||||
// GET / - primary app dashboard
|
||||
exports.getIndex = async function(req, res) {
|
||||
var projects = await Project.findAll();
|
||||
res.render('index/dashboard', {
|
||||
projects: projects
|
||||
});
|
||||
};
|
||||
|
9
src/routes/toplevel.js
Normal file
9
src/routes/toplevel.js
Normal file
@ -0,0 +1,9 @@
|
||||
const Project = require('../models').models.Project;
|
||||
|
||||
// GET / - primary app dashboard
|
||||
exports.getIndex = async function(req, res) {
|
||||
var projects = await Project.findAll();
|
||||
res.render('index/dashboard', {
|
||||
projects: projects
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user