37 lines
728 B
JavaScript
37 lines
728 B
JavaScript
const db = require('../models');
|
|
const Item = db.items;
|
|
const License = db.licenses;
|
|
|
|
// GET - /
|
|
exports.getIndex = async function(req, res) {
|
|
// check if there's a limit set
|
|
if (isset(req.body['limit'])) {
|
|
const limit = req.body.limit;
|
|
} else {
|
|
const limit = 10;
|
|
}
|
|
|
|
// fetch inventory items from database
|
|
const items = await Item.findAll({
|
|
limit: limit,
|
|
order: [
|
|
['updatedAt', 'DESC'],
|
|
],
|
|
});
|
|
|
|
// fetch licenses from database
|
|
const licenses = await License.findAll({
|
|
limit: limit,
|
|
order: [
|
|
['updatedAt', 'DESC'],
|
|
],
|
|
});
|
|
|
|
// req.flash('info', 'This is a test flash message.');
|
|
|
|
res.render('index.twig', {
|
|
inventory: items,
|
|
licenses: licenses,
|
|
});
|
|
};
|