check-apikey.js 352 Bytes
const config = require('../../config');

module.exports = async (req, res, next) => {
    const { apikey } = req.params;

    if (!config.apikey) {
        next();
    } else if (config.apikey === apikey) {
        next();
    } else {
        res.status(403).json({
            error: true,
            message: 'Invalid apikey',
        });
    }
};