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

@flatfile/listener

Package Overview
Dependencies
Maintainers
26
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flatfile/listener - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

6

CHANGELOG.md
# @flatfile/listener
## 0.3.0
### Minor Changes
- 2a30e13: Add cross-env library for accessing environment variables
## 0.2.0

@@ -4,0 +10,0 @@

92

dist/index.js

@@ -44,2 +44,88 @@ "use strict";

// ../cross-env-config/dist/index.mjs
var CrossEnvConfig = class {
/**
* Get a config value from either the environment or any registry overrides
* @param prop
*/
static get(prop) {
return this.safeEnvLookup(prop);
}
/**
* Set a value explicitly
*
* @param key
* @param value
*/
static set(key, value) {
return this._overrides.set(key, value);
}
/**
* Alias a key to another key if helpful. This is useful if you have different naming
* constructs for different environments.
*
* @param from
* @param to
*/
static alias(from, to) {
return this._aliases.set(from, to);
}
/**
* Helpful if you've decided to store settings in another object and want to
* make that available here. For example in client-side implementations you may reserve
* a window.FLATFILE_CONFIG object to store settings.
*
* @param obj
*/
static attachConfigRegistry(obj) {
this._registry = obj;
}
/**
* Use this to provide an override getter for config values. This is useful
* if you need to dynamically look up values. Overrides will still take precedence.
*
* @param cb
*/
static attachConfigFactory(cb) {
this._factory = cb;
}
static reset() {
this._overrides = /* @__PURE__ */ new Map();
this._registry = void 0;
this._factory = void 0;
}
/**
* Internal function for traversing the possible environment sources for a value
*
* @param prop
* @private
*/
static safeEnvLookup(prop) {
let values = [];
if (this._overrides.get(prop)) {
values.push(this._overrides.get(prop));
}
if (typeof this._registry === "object") {
values.push(this._registry[prop]);
}
if (typeof this._factory === "function") {
values.push(this._factory(prop));
}
if (typeof process === "object" && typeof process.env === "object") {
values.push(process.env[prop]);
}
const foundValue = values.find((v) => v !== void 0);
if (foundValue !== void 0) {
return foundValue;
}
const alias = this._aliases.get(prop);
if (alias) {
return this.safeEnvLookup(alias);
}
return void 0;
}
};
CrossEnvConfig._overrides = /* @__PURE__ */ new Map();
CrossEnvConfig._aliases = /* @__PURE__ */ new Map();
// src/events/authenticated.client.ts

@@ -49,4 +135,5 @@ var import_axios = __toESM(require("axios"));

constructor(accessToken, apiUrl) {
const FLATFILE_API_URL = process.env.AGENT_INTERNAL_URL || "http://localhost:3000";
this._accessToken = accessToken || process.env.FLATFILE_BEARER_TOKEN || "...";
const FLATFILE_API_URL = CrossEnvConfig.get("AGENT_INTERNAL_URL") || "http://localhost:3000";
const bearerToken = CrossEnvConfig.get("FLATFILE_BEARER_TOKEN");
this._accessToken = accessToken || bearerToken || "...";
this._apiUrl = apiUrl || FLATFILE_API_URL;

@@ -60,3 +147,2 @@ }

const fetchUrl = this._apiUrl + "/" + url;
console.log({ fetchUrl });
return import_axios.default.get(fetchUrl, { headers }).then((resp) => resp.data.data).catch((err) => {

@@ -63,0 +149,0 @@ });

3

package.json
{
"name": "@flatfile/listener",
"version": "0.2.0",
"version": "0.3.0",
"description": "A PubSub Listener for configuring and using Flatfile",

@@ -20,2 +20,3 @@ "main": "dist/index.js",

"@flatfile/ts-config-platform-sdk": "*",
"@flatfile/cross-env-config": "*",
"@types/flat": "^5.0.2",

@@ -22,0 +23,0 @@ "@types/jest": "^29.5.1",

@@ -0,1 +1,2 @@

import { CrossEnvConfig } from '@flatfile/cross-env-config'
import axios from 'axios'

@@ -9,6 +10,6 @@

const FLATFILE_API_URL =
process.env.AGENT_INTERNAL_URL || 'http://localhost:3000'
CrossEnvConfig.get('AGENT_INTERNAL_URL') || 'http://localhost:3000'
const bearerToken = CrossEnvConfig.get('FLATFILE_BEARER_TOKEN')
this._accessToken =
accessToken || process.env.FLATFILE_BEARER_TOKEN || '...'
this._accessToken = accessToken || bearerToken || '...'

@@ -24,6 +25,8 @@ this._apiUrl = apiUrl || FLATFILE_API_URL

const fetchUrl = this._apiUrl + '/' + url
console.log({ fetchUrl })
return axios.get(fetchUrl, { headers }).then((resp: any) => resp.data.data).catch((err: any) => {})
return axios
.get(fetchUrl, { headers })
.then((resp: any) => resp.data.data)
.catch((err: any) => {})
}
/**

@@ -30,0 +33,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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