@defer.run/client
Advanced tools
Comparing version 0.0.8 to 0.0.9
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.init = void 0; | ||
const fetch_1 = require("@whatwg-node/fetch"); | ||
const constants_js_1 = require("./constants.js"); | ||
let token = process.env[constants_js_1.TOKEN_ENV_NAME]; | ||
const init = ({ apiToken }) => { | ||
token = apiToken; | ||
let apiEndpoint = `${constants_js_1.DOMAIN}${constants_js_1.PATH}`; | ||
const init = ({ apiToken, apiUrl }) => { | ||
token = apiToken || process.env[constants_js_1.TOKEN_ENV_NAME]; | ||
apiEndpoint = apiUrl || `${constants_js_1.DOMAIN}${constants_js_1.PATH}`; | ||
}; | ||
exports.init = init; | ||
function defer(fn) { | ||
@@ -26,3 +26,3 @@ const ret = (...args) => { | ||
} | ||
(0, fetch_1.fetch)(`${constants_js_1.DOMAIN}${constants_js_1.PATH}`, { | ||
(0, fetch_1.fetch)(apiEndpoint, { | ||
method: "POST", | ||
@@ -46,2 +46,2 @@ body, | ||
} | ||
exports.default = defer; | ||
exports.default = { defer, init }; |
import { fetch } from "@whatwg-node/fetch"; | ||
import { DOMAIN, PATH, TOKEN_ENV_NAME } from "./constants.js"; | ||
let token = process.env[TOKEN_ENV_NAME]; | ||
export const init = ({ apiToken }) => { | ||
token = apiToken; | ||
let apiEndpoint = `${DOMAIN}${PATH}`; | ||
const init = ({ apiToken, apiUrl }) => { | ||
token = apiToken || process.env[TOKEN_ENV_NAME]; | ||
apiEndpoint = apiUrl || `${DOMAIN}${PATH}`; | ||
}; | ||
@@ -22,3 +24,3 @@ function defer(fn) { | ||
} | ||
fetch(`${DOMAIN}${PATH}`, { | ||
fetch(apiEndpoint, { | ||
method: "POST", | ||
@@ -42,2 +44,2 @@ body, | ||
} | ||
export default defer; | ||
export default { defer, init }; |
{ | ||
"name": "@defer.run/client", | ||
"version": "0.0.7", | ||
"version": "0.0.9", | ||
"description": "cua JavaScript client", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
interface Options { | ||
apiToken: string; | ||
apiToken?: string; | ||
apiUrl?: string; | ||
} | ||
export declare const init: ({ apiToken }: Options) => void; | ||
declare function defer<F extends (...args: any | undefined) => Promise<any>>(fn: F): F; | ||
export default defer; | ||
declare const _default: { | ||
defer: typeof defer; | ||
init: ({ apiToken, apiUrl }: Options) => void; | ||
}; | ||
export default _default; |
{ | ||
"name": "@defer.run/client", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "cua JavaScript client", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -5,9 +5,12 @@ import { fetch } from "@whatwg-node/fetch"; | ||
interface Options { | ||
apiToken: string; | ||
apiToken?: string; | ||
apiUrl?: string; | ||
} | ||
let token: string | undefined = process.env[TOKEN_ENV_NAME]; | ||
let apiEndpoint = `${DOMAIN}${PATH}`; | ||
export const init = ({ apiToken }: Options) => { | ||
token = apiToken; | ||
const init = ({ apiToken, apiUrl }: Options) => { | ||
token = apiToken || process.env[TOKEN_ENV_NAME]; | ||
apiEndpoint = apiUrl || `${DOMAIN}${PATH}`; | ||
}; | ||
@@ -32,3 +35,3 @@ | ||
} | ||
fetch(`${DOMAIN}${PATH}`, { | ||
fetch(apiEndpoint, { | ||
method: "POST", | ||
@@ -52,2 +55,2 @@ body, | ||
export default defer; | ||
export default { defer, init }; |
Sorry, the diff of this file is not supported yet
14513
207
5