You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
841 B

import EventEmitter from 'events';
import Agent from './agent';
export default class Now extends EventEmitter {
constructor (url, token, { forceNew = false, debug = false }) {
super();
this._token = token;
this._debug = debug;
this._forceNew = forceNew;
this._agent = new Agent(url, { debug });
this._onRetry = this._onRetry.bind(this);
}
ls (url) {
console.log('list', url);
}
rm (url, aliases) {
console.log('rm', url, aliases);
}
set (url, aliases) {
console.log('set', url, aliases);
}
_onRetry (err) {
if (this._debug) {
console.log(`> [debug] Retrying: ${err.stack}`);
}
}
async _fetch (_url, opts = {}) {
opts.headers = opts.headers || {};
opts.headers.authorization = `Bearer ${this._token}`;
return await this._agent.fetch(_url, opts);
}
}