homepage.js/routes/articles.js

17 lines
447 B
JavaScript
Raw Normal View History

2023-02-22 14:55:17 +01:00
const handler = require('express-async-handler');
const Helpers = require('../helpers');
const Sequelize = require('../models');
async function articles(req, res) {
const articles = await Sequelize.Article.findAll();
res.send(await Helpers.ViewLoader.load('articles/articles.pug', {
current_route: res.originalUrl,
articles
}));
}
module.exports = (router) => {
router.get('/articles', handler(articles));
}