common-core-api
Version:
Pre-Beta. Wrapper for common-standards-project api
24 lines • 927 B
JavaScript
/*
from http://commonstandardsproject.com
Authentication
* All requests need an api-key query parameter or an Api-Key header. Your api key can be found in the sidebar. (on-site)
* All requests need to originate from one of the allowed origins. You can update origins on the sidebar. (on-site)
*/
(function(){
'use strict';
const val = require('./val.js')
const err = require('./error.js')
const AlgoliaClient = require('./algolia.js')
const sckey=Symbol('search')
class ApiUser{
constructor(apiKey,angApp,angKey){
if(!val.apiKey(apiKey)) throw err('Invalid apiKey value');
this.key=apiKey;
if(angApp && angKey) this[sckey] = new AlgoliaClient(angApp,angKey)
}
get search(){ return this[sckey]; }
get qs(){ return {'api-key':this.key}; }
get header(){ return {'Api-Key':this.key}; }
}
module.exports=ApiUser;
})();