javascriptier exports

This commit is contained in:
Daniel Lugo 2020-06-24 07:13:05 -04:00
parent fb9b71781e
commit c438d3293f
3 changed files with 9 additions and 5 deletions

View file

@ -6,6 +6,8 @@ const Common = require('shock-common')
const Key = require('../key') const Key = require('../key')
const Utils = require('../utils') const Utils = require('../utils')
const Wall = require('./wall')
/** /**
* @param {string} pub * @param {string} pub
* @returns {Promise<string>} * @returns {Promise<string>}
@ -89,4 +91,6 @@ const getMyUser = async () => {
module.exports.getMyUser = getMyUser module.exports.getMyUser = getMyUser
module.exports.Follows = require('./follows') module.exports.Follows = require('./follows')
module.exports.Wall = require('./wall')
module.exports.getWallPage = Wall.getWallPage
module.exports.getWallTotalPages = Wall.getWallTotalPages

View file

@ -8,7 +8,7 @@ const Key = require('../key')
/** /**
* @returns {Promise<number>} * @returns {Promise<number>}
*/ */
const getTotalPages = () => const getWallTotalPages = () =>
/** @type {Promise<number>} */ (Utils.tryAndWait( /** @type {Promise<number>} */ (Utils.tryAndWait(
(_, user) => (_, user) =>
user user
@ -24,7 +24,7 @@ const getTotalPages = () =>
* @returns {Promise<Common.SchemaTypes.WallPage>} * @returns {Promise<Common.SchemaTypes.WallPage>}
*/ */
const getWallPage = async page => { const getWallPage = async page => {
const totalPages = await getTotalPages() const totalPages = await getWallTotalPages()
const empty = { const empty = {
count: 0, count: 0,
posts: {} posts: {}
@ -55,6 +55,6 @@ const getWallPage = async page => {
} }
module.exports = { module.exports = {
getTotalPages, getWallTotalPages,
getWallPage getWallPage
} }

View file

@ -1845,7 +1845,7 @@ module.exports = async (
try { try {
const { page } = req.query; const { page } = req.query;
return res.status(200).json(await GunGetters.Wall.getWallPage(page)) return res.status(200).json(await GunGetters.getWallPage(page))
} catch (err) { } catch (err) {
return res.status(500).json({ return res.status(500).json({
errorMessage: err.message errorMessage: err.message