Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@youri-kane/heroku-client

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@youri-kane/heroku-client - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

dist/logger/index.d.ts

2

dist/client.d.ts
import { HerokuClient, HerokuClientParams } from './types';
export declare const createClient: ({ baseURL, metricsURL, token, cache, }: HerokuClientParams) => HerokuClient;
export declare const createClient: ({ baseURL, metricsURL, token, cache, debug, }: HerokuClientParams) => HerokuClient;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,3 +31,3 @@ exports.createClient = void 0;

const getRateLimit_1 = require("./requests/miscellaneous/getRateLimit");
const createClient = ({ baseURL = constants_1.defaultBaseURL, metricsURL = constants_1.defaultMetricsURL, token, cache, }) => {
const createClient = ({ baseURL = constants_1.defaultBaseURL, metricsURL = constants_1.defaultMetricsURL, token, cache, debug, }) => {
if (!baseURL) {

@@ -19,2 +42,8 @@ throw new errors_1.HerokuClientError('Missing Heroku baseURL');

}
let logger;
if (debug) {
Promise.resolve().then(() => __importStar(require('./logger'))).then(({ logger: definedLogger }) => {
logger = definedLogger;
});
}
const state = {

@@ -24,4 +53,7 @@ rateLimit: 0,

const handleResponse = (request, response) => {
const remaining = Number(response.headers['RateLimit-Remaining'] || 0);
const remaining = Number(response.headers['ratelimit-remaining'] || 0);
if (!Number.isNaN(remaining)) {
if (logger) {
logger.debug(`Rate Limit Remaining: ${remaining}`);
}
state.rateLimit = remaining;

@@ -48,2 +80,3 @@ }

metricsURL,
getLogger: () => logger,
})({});

@@ -62,2 +95,3 @@ if (result.hasFailed) {

requests: (0, requests_1.buildRequests)({
getLogger: () => logger,
baseURL,

@@ -64,0 +98,0 @@ token,

@@ -28,3 +28,3 @@ "use strict";

function createRequest(config) {
return async ({ useCache = true, timeout, ...req }) => {
return async ({ useCache = false, timeout, ...req }) => {
const method = config?.method ?? 'GET';

@@ -40,5 +40,5 @@ const query = req?.query || config.defaultQuery

};
if (useCache && config.onRequest) {
if (config.onRequest) {
const res = config.onRequest(computedParams);
if (res) {
if (res && useCache) {
return handleResponse({ ...req, config }, res);

@@ -61,3 +61,3 @@ }

});
if (useCache && config.onResponse) {
if (config.onResponse) {
config.onResponse(computedParams, response);

@@ -64,0 +64,0 @@ }

@@ -6,3 +6,3 @@ import * as apps from './apps';

import { RequestConfig } from './types';
export declare const buildRequests: ({ baseURL, metricsURL, token, onResponse, onRequest, }: RequestConfig) => {
export declare const buildRequests: ({ baseURL, metricsURL, token, getLogger, onResponse, onRequest, }: RequestConfig) => {
getDynoLoad: (params: import("./types").RequestParams & {

@@ -9,0 +9,0 @@ params: {

@@ -41,15 +41,28 @@ "use strict";

};
const buildRequests = ({ baseURL, metricsURL, token, onResponse, onRequest, }) => {
const buildRequests = ({ baseURL, metricsURL, token, getLogger, onResponse, onRequest, }) => {
return Object.keys(requests).reduce((builtRequests, requestId) => {
const reqId = requestId;
const request = requests[reqId];
const fn = request({
getLogger,
baseURL,
metricsURL,
token,
onResponse,
onRequest,
});
return {
...builtRequests,
[reqId]: request({
baseURL,
metricsURL,
token,
onResponse,
onRequest,
}),
[reqId]: async (...args) => {
const start = Date.now();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const res = await fn(...args);
const end = Date.now();
const logger = getLogger();
if (logger) {
logger.debug(`${reqId} took ${end - start}ms`);
}
return res;
},
};

@@ -56,0 +69,0 @@ }, {});

import { AxiosResponse } from 'axios';
import { TypedEmitter } from 'tiny-typed-emitter';
import { Logger } from 'winston';
export declare type HTTPVerb =

@@ -77,2 +78,3 @@ /**

onResponse?: (request: FullRequestParams, response: AxiosResponse) => void;
getLogger: () => Logger | undefined;
};

@@ -79,0 +81,0 @@ export declare type PollRequest<R extends PollRequestParams = PollRequestParams, T extends PollAbleResponse = PollAbleResponse> = (config: {

@@ -8,2 +8,3 @@ import { ResponseCacheResult } from './cache';

cache?: ResponseCacheResult;
debug?: boolean;
};

@@ -10,0 +11,0 @@ export declare type HerokuClient = {

{
"name": "@youri-kane/heroku-client",
"version": "0.1.8",
"version": "0.1.9",
"description": "heroku developer api client with typescript support",

@@ -54,4 +54,5 @@ "main": "dist/index.js",

"query-string": "^7.0.1",
"tiny-typed-emitter": "^2.1.0"
"tiny-typed-emitter": "^2.1.0",
"winston": "^3.6.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc