UNPKG

clik

Version:
30 lines (24 loc) 747 B
const { send } = require('httpie'); function setup(token, type = 'Bearer') { const headers = { Authorization: `${type} ${token}` }; return function (method, path, body) { return send(method, new URL(path, 'https://api.clik.io'), { headers, body }).then(r => r.data); }; } function list(client) { return client('GET', '/links'); } function exists(client, uid) { return client('HEAD', `/links/${uid}`).then(() => true).catch(() => false); } function update(client, uid, href) { return client('PUT', `/links/${uid}`, { href }); } function create(client, href, uid) { return client('POST', `/links`, { uid, href }); } exports.create = create; exports.exists = exists; exports.list = list; exports.setup = setup; exports.update = update;