is-valid-apikey.js 406 Bytes
module.exports = (apikey, apikeys) => {
    if (!apikey) return false;
    if (typeof apikey !== 'string') return false;
    if (!apikeys || !Array.isArray(apikeys)) return false;

    const matchedApikey = apikeys.find((item) => !item.disabled
        && (
            (typeof item === 'string' && item === apikey)
            || (item.value === apikey)
        ));

    return matchedApikey || false;
};