const {{shortName}}ServiceClass = require('../services/{{shortName}}.service');
const {{shortName}}Service = new {{shortName}}ServiceClass()

class {{shortName}}Controller {

    static async get(req, res, next) {
        try {
            const {id} = req.params;
            let result = await {{shortName}}Service.get(id);
            res.json(result);
        } catch (e) {
            next(e)
        }
    }

    static async post(req, res, next) {
        try {
            const body = req.body;
            let result = await {{shortName}}Service.post(body);
            res.json(result);
        } catch (e) {
            next(e)
        }
    }

    static async put(req, res, next) {
        try {
            const {id} = req.params;
            const body = req.body;
            let result = await {{shortName}}Service.put(id, body);
            res.json(result);
        } catch (e) {
            next(e)
        }
    }

    static async del(req, res, next) {
        try {
            const {id} = req.params;
            let result = await {{shortName}}Service.del(id);
            res.json(result);
        } catch (e) {
            next(e)
        }
    }

}

module.exports = {{shortName}}Controller;
