UNPKG

promax-api-version

Version:

Contains a set of importable npm modules that interact with the RESTful APIs of CEC and other sibling companies.

36 lines (30 loc) 964 B
'use strict'; /** * * @param { String } companyName * @param { String } environment * @param { String } apiKey */ var checkArgs = function (companyName, environment, apiKey) { // check companyName validity if (!RegExp('(C|c)(E|e)(C|c)').test(companyName) && !RegExp('(A|a)(T|t)(G|g)').test(companyName) && !RegExp('(M|m)(E|e)(X|x)').test(companyName)) { console.error('companyName does not target CEC, ATG, or MEX'); return 1; } // check environment validity if (!RegExp('(S|s)(tag)?(e|(ing))?').test(environment) && !RegExp('(P|p)(rod)?(uction)?').test(environment)) { console.error('environment does not target staging or production'); return 2; } // check apiKey basics if ((!apiKey) || (apiKey.length !== 34)) { console.error('API key does not meet basic requirements'); return 3; } // return success return 0; } module.exports = checkArgs;