'use strict';

const express = require('express');
const controller = require('./sync.controller');

const router = express.Router();

function asyncRoute(fn) {
  return (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);
}

router.get('/status', asyncRoute(controller.status));
router.get('/events', asyncRoute(controller.events));
router.post('/events', asyncRoute(controller.enqueue));
router.post('/retry', asyncRoute(controller.retry));

module.exports = router;
