45 lines
879 B
JavaScript
45 lines
879 B
JavaScript
var express = require('express');
|
|
var router = express.Router();
|
|
var mdataController = require('../controllers/mdataController.js');
|
|
|
|
function requiresLogin(req, res, next){
|
|
if(req.session && req.session.userId){
|
|
return next();
|
|
} else{
|
|
return res.redirect('/mdata');
|
|
}
|
|
}
|
|
|
|
/*
|
|
* GET
|
|
*/
|
|
router.get('/', mdataController.list);
|
|
router.get('/publish', requiresLogin, mdataController.publish);
|
|
router.get('/my', requiresLogin, mdataController.listmy);
|
|
router.get('/delete/:id', requiresLogin, mdataController.remove);
|
|
router.get('/update/:id/:ans', requiresLogin, mdataController.update);
|
|
|
|
|
|
|
|
/*
|
|
* GET
|
|
*/
|
|
router.get('/:id', mdataController.show);
|
|
|
|
/*
|
|
* POST
|
|
*/
|
|
router.post('/', mdataController.create);
|
|
|
|
/*
|
|
* PUT
|
|
*/
|
|
router.put('/:id', mdataController.update);
|
|
|
|
/*
|
|
* DELETE
|
|
*/
|
|
router.delete('/:id', mdataController.remove);
|
|
|
|
module.exports = router;
|