22 lines
665 B
JavaScript
22 lines
665 B
JavaScript
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const PostsDBApi = require('../db/api/posts');
|
|
const AccountTiersDBApi = require('../db/api/account_tiers');
|
|
const wrapAsync = require('../helpers').wrapAsync;
|
|
|
|
router.get('/data', wrapAsync(async (req, res) => {
|
|
// Fetch latest posts for guest users
|
|
const posts = await PostsDBApi.findAll({ limit: 6, page: 0 }, { currentUser: null });
|
|
|
|
// Fetch account tiers
|
|
const tiers = await AccountTiersDBApi.findAll({ limit: 10, page: 0 }, { currentUser: null });
|
|
|
|
res.status(200).send({
|
|
posts: posts.rows,
|
|
tiers: tiers.rows
|
|
});
|
|
}));
|
|
|
|
module.exports = router;
|