text: import PostService from '../services/post.service';
  
  /**
   * Get all posts
   * @param req
   * @param res
   * @returns void
   */
  export function getPosts(req, res) {
    PostService.getPosts((err, posts) => {
      if (err) {
        res.status(500).send(err);
      }
      res.json({ posts });
    });
  }
  
  /**
   * Save a post
   * @param req
   * @param res
   * @returns void
   */
  export function addPost(req, res) {
    if (!req.body.post.name || !req.body.post.title || !req.body.post.content) {
      res.status(403).end();
    }
    PostService.addPost(req.body.post, (err, saved) => {
      if (err) {
        res.status(500).send(err);
      }
      res.json({ post: saved });
    });
  }
  
  /**
   * Get a single post
   * @param req
   * @param res
   * @returns void
   */
  export function getPost(req, res) {
    PostService.getPost({ cuid: req.params.cuid }, (err, post) => {
      if (err) {
        res.status(500).send(err);
      }
      res.json({ post });
    });
  }
  
  /**
   * Delete a post
   * @param req
   * @param res
   * @returns void
   */
  export function deletePost(req, res) {
    PostService.deletePost({ cuid: req.params.cuid }, (err, post) => {
      if (err) {
        res.status(500).send(err);
      }
  
      post.remove(() => {
        res.status(200).end();
      });
    });
  }
  