const express = require('express');
const router = express.Router();
const authorize = require('../../../../middlewares/authorize-sapps');
const ApiKeyService = require('./apikey.service');

router.post('/create', authorize(), create);
router.get('/', authorize(), getAll);

module.exports = router;

function create(req, res, next) {
    ApiKeyService.create(req.body)
        .then(result => res.json(result))
        .catch(next);
}

function getAll(req, res, next) {
    ApiKeyService.getAll(req.query)
        .then(result => res.json(result))
        .catch(next);
}
