UNPKG

ghost

Version:

The professional publishing platform

27 lines (21 loc) 622 B
const debug = require('ghost-ignition').debug('api:v3:utils:serializers:output:posts'); const mapper = require('./utils/mapper'); module.exports = { all(models, apiConfig, frame) { debug('all'); // CASE: e.g. destroy returns null if (!models) { return; } if (models.meta) { frame.response = { posts: models.data.map(model => mapper.mapPost(model, frame)), meta: models.meta }; return; } frame.response = { posts: [mapper.mapPost(models, frame)] }; } };