Socket
Socket
Sign inDemoInstall

@vercel/edge-config

Package Overview
Dependencies
Maintainers
9
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/edge-config - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0-c26fa17c-20240611172734

13

dist/index.d.ts

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

import { DeepReadonly, DeepWritable } from 'ts-essentials';
import { TracerProvider } from '@opentelemetry/api';

@@ -40,3 +39,3 @@

*/
get: <T = EdgeConfigValue>(key: string) => Promise<DeepReadonly<T> | undefined>;
get: <T = EdgeConfigValue>(key: string) => Promise<T | undefined>;
/**

@@ -50,3 +49,3 @@ * Reads multiple or all values.

*/
getAll: <T = EdgeConfigItems>(keys?: (keyof T)[]) => Promise<DeepReadonly<T>>;
getAll: <T = EdgeConfigItems>(keys?: (keyof T)[]) => Promise<T>;
/**

@@ -113,2 +112,8 @@ * Check if a given key exists in the Edge Config.

disableDevelopmentCache?: boolean;
/**
* Sets a `cache` option on the `fetch` call made by Edge Config.
*
* Unlike Next.js, this defaults to `no-store`, as you most likely want to use Edge Config dynamically.
*/
cache?: 'no-store' | 'force-cache';
}

@@ -172,4 +177,4 @@ /**

*/
declare function clone<T = EdgeConfigValue>(edgeConfigValue: T): DeepWritable<T>;
declare function clone<T = EdgeConfigValue>(edgeConfigValue: T): T;
export { type EdgeConfigClient, type EdgeConfigItems, type EdgeConfigValue, type EmbeddedEdgeConfig, clone, createClient, digest, get, getAll, has, parseConnectionString, setTracerProvider };

@@ -6,3 +6,3 @@ // src/index.ts

var name = "@vercel/edge-config";
var version = "1.1.1";
var version = "1.2.0-c26fa17c-20240611172734";

@@ -336,3 +336,3 @@ // src/utils/tracing.ts

);
function createGetInMemoryEdgeConfig(shouldUseDevelopmentCache, connection, headers) {
function createGetInMemoryEdgeConfig(shouldUseDevelopmentCache, connection, headers, fetchCache) {
let embeddedEdgeConfigPromise = null;

@@ -349,3 +349,3 @@ let latestRequest = null;

headers: new Headers(headers),
cache: "no-store"
cache: fetchCache
}

@@ -398,4 +398,4 @@ ).then(async (res) => {

function createClient2(connectionString, options = {
staleIfError: 604800
/* one week */
staleIfError: 604800,
cache: "no-store"
}) {

@@ -421,2 +421,3 @@ if (!connectionString)

headers["cache-control"] = `stale-if-error=${options.staleIfError}`;
const fetchCache = options.cache || "no-store";
const shouldUseDevelopmentCache = !options.disableDevelopmentCache && process.env.NODE_ENV === "development" && process.env.EDGE_CONFIG_DISABLE_DEVELOPMENT_SWR !== "1";

@@ -426,3 +427,4 @@ const getInMemoryEdgeConfig = createGetInMemoryEdgeConfig(

connection,
headers
headers,
fetchCache
);

@@ -435,5 +437,3 @@ const api = {

assertIsKey(key);
return Promise.resolve(
localEdgeConfig.items[key]
);
return Promise.resolve(localEdgeConfig.items[key]);
}

@@ -445,3 +445,3 @@ assertIsKey(key);

headers: new Headers(headers),
cache: "no-store"
cache: fetchCache
}

@@ -477,3 +477,3 @@ ).then(async (res) => {

headers: new Headers(headers),
cache: "no-store"
cache: fetchCache
}).then((res) => {

@@ -502,5 +502,3 @@ if (res.status === 401)

assertIsKeys(keys);
return Promise.resolve(
pick(localEdgeConfig.items, keys)
);
return Promise.resolve(pick(localEdgeConfig.items, keys));
}

@@ -518,3 +516,3 @@ if (Array.isArray(keys))

headers: new Headers(headers),
cache: "no-store"
cache: fetchCache
}

@@ -546,3 +544,3 @@ ).then(async (res) => {

headers: new Headers(headers),
cache: "no-store"
cache: fetchCache
}

@@ -549,0 +547,0 @@ ).then(async (res) => {

{
"name": "@vercel/edge-config",
"version": "1.1.1",
"version": "1.2.0-c26fa17c-20240611172734",
"description": "Ultra-low latency data at the edge",

@@ -31,3 +31,2 @@ "homepage": "https://vercel.com",

"dependencies": {
"ts-essentials": "9.4.1",
"@vercel/edge-config-fs": "0.1.0"

@@ -34,0 +33,0 @@ },

@@ -135,12 +135,33 @@ # @vercel/edge-config

## Caught a Bug?
## Fetch cache
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Link the package to the global module directory: `npm link`
3. Within the module you want to test your local development instance of `@vercel/edge-config`, just link it to the dependencies: `npm link @vercel/edge-config`. Instead of the default one from npm, Node.js will now use your clone of `@vercel/edge-config`!
By default the Edge Config SDK will fetch with `no-store`, which triggers dynamic mode in Next.js ([docs](https://nextjs.org/docs/app/api-reference/functions/fetch#optionscache)).
As always, you can run the tests using: `npm test`
To use Edge Config with static pages, pass the `force-cache` option:
## A note for Vite users
```js
import { createClient } from '@vercel/edge-config';
const edgeConfigClient = createClient(process.env.EDGE_CONFIG, {
cache: 'force-cache',
});
// then use the client as usual
edgeConfigClient.get('someKey');
```
**Note** This opts out of dynamic behavior, so the page might display stale values.
## Notes
### Do not mutate return values
Cloning objects in JavaScript can be slow. That's why the Edge Config SDK uses an optimization which can lead to multiple calls reading the same key all receiving a reference to the same value.
For this reason the value read from Edge Config should never be mutated, otherwise they could affect other parts of the code base reading the same key, or a later request reading the same key.
If you need to modify, see the `clone` function described [here](#do-not-mutate-return-values).
### Usage with Vite
`@vercel/edge-config` reads database credentials from the environment variables on `process.env`. In general, `process.env` is automatically populated from your `.env` file during development, which is created when you run `vc env pull`. However, Vite does not expose the `.env` variables on `process.env.`

@@ -184,1 +205,9 @@

```
## Caught a Bug?
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Link the package to the global module directory: `npm link`
3. Within the module you want to test your local development instance of `@vercel/edge-config`, just link it to the dependencies: `npm link @vercel/edge-config`. Instead of the default one from npm, Node.js will now use your clone of `@vercel/edge-config`!
As always, you can run the tests using: `npm test`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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