-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create storage monorepo (#100)
* feat: Create storage monorepo * chore: Changeset for package.json modifications * Update README.md
- Loading branch information
1 parent
7c8d9c2
commit 1ade1f0
Showing
82 changed files
with
12,045 additions
and
2,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@vercel/edge-config': patch | ||
'@vercel/kv': patch | ||
'@vercel/postgres': patch | ||
'@vercel/postgres-kysely': patch | ||
--- | ||
|
||
chore: Update package.json and licenses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { resolve } = require('node:path'); | ||
|
||
module.exports = { | ||
root: true, | ||
// This tells ESLint to load the config from the package `eslint-config-custom` | ||
extends: ['custom'], | ||
parserOptions: { | ||
project: resolve(__dirname, './packages/*/tsconfig.json'), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
name: Quality | ||
|
||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
@@ -12,69 +16,93 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected].4 | ||
uses: pnpm/[email protected].2 | ||
with: | ||
version: 7 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
node-version: '16' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
run: pnpm install | ||
|
||
- name: Run Prettier check | ||
run: pnpm run prettier-check | ||
run: pnpm prettier-check | ||
|
||
eslint: | ||
name: 'ESLint' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected].4 | ||
uses: pnpm/[email protected].2 | ||
with: | ||
version: 7 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
node-version: '16' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
run: pnpm install | ||
|
||
- name: Run ESLint check | ||
run: pnpm run eslint-check | ||
- name: Run ESLint | ||
run: pnpm run lint | ||
|
||
types: | ||
name: 'TypeScript' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected].4 | ||
uses: pnpm/[email protected].2 | ||
with: | ||
version: 7 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
node-version: '16' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
run: pnpm install | ||
|
||
- name: Run TypeScript type check | ||
run: pnpm run type-check | ||
|
||
publint: | ||
name: 'publint' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 7 | ||
|
||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run Publint | ||
run: pnpm run publint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ node_modules/ | |
|
||
# logs | ||
npm-debug.log | ||
|
||
.turbo | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
dist | ||
node_modules | ||
pnpm-lock.yaml | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,8 @@ | ||
# @vercel/edge-config | ||
# Vercel Storage | ||
|
||
 | ||
 | ||
- [`@vercel/postgres`](./packages/postgres) - Vercel Postgres database client | ||
- [`@vercel/kv`](./packages/kv) - Durable Redis-compatible Key Value store | ||
- [`@vercel/postgres-kysely`](./packages/postgres-kysely) - A `@vercel/postgres` wrapper for the [kysely ORM](https://github.com/kysely-org/kysely) | ||
- [`@vercel/edge-config`](./packages/edge-config) - Ultra-low latency data at the edge | ||
|
||
A client that lets you read Edge Config. | ||
|
||
## Examples | ||
|
||
You can use the methods below to read your Edge Config given you have its Connection String stored in an Environment Variable called `process.env.EDGE_CONFIG`. | ||
|
||
### Reading a value | ||
|
||
```js | ||
import { get } from '@vercel/edge-config'; | ||
await get('someKey'); | ||
``` | ||
|
||
Returns the value if the key exists. | ||
Returns `undefined` if the key does not exist. | ||
Throws on invalid tokens, deleted edge configs or network errors. | ||
|
||
### Checking if a key exists | ||
|
||
```js | ||
import { has } from '@vercel/edge-config'; | ||
await has('someKey'); | ||
``` | ||
|
||
Returns `true` if the key exists. | ||
Returns `false` if the key does not exist. | ||
Throws on invalid tokens, deleted edge configs or network errors. | ||
|
||
### Reading all items | ||
|
||
```js | ||
import { getAll } from '@vercel/edge-config'; | ||
await getAll(); | ||
``` | ||
|
||
Returns all Edge Config items. | ||
Throws on invalid tokens, deleted edge configs or network errors. | ||
|
||
### Reading items in batch | ||
|
||
```js | ||
import { getAll } from '@vercel/edge-config'; | ||
await getAll(['keyA', 'keyB']); | ||
``` | ||
|
||
Returns selected Edge Config items. | ||
Throws on invalid tokens, deleted edge configs or network errors. | ||
|
||
### Default behaviour | ||
|
||
By default `@vercel/edge-config` will read from the Edge Config stored in `process.env.EDGE_CONFIG`. | ||
|
||
The exported `get`, `getAll`, `has` and `digest` functions are bound to this default Edge Config Client. | ||
|
||
### Reading a value from a specific Edge Config | ||
|
||
You can use `createClient(connectionString)` to read values from Edge Configs other than the default one. | ||
|
||
```js | ||
import { createClient } from '@vercel/edge-config'; | ||
const edgeConfig = createClient(process.env.ANOTHER_EDGE_CONFIG); | ||
await edgeConfig.get('someKey'); | ||
``` | ||
|
||
The `createClient` function connects to a any Edge Config based on the provided Connection String. | ||
|
||
It returns the same `get`, `getAll`, `has` and `digest` functions as the default Edge Config Client exports. | ||
|
||
## Writing Edge Config Items | ||
|
||
Edge Config Items can be managed in two ways: | ||
|
||
- [Using the Dashboard on vercel.com](https://vercel.com/docs/concepts/edge-network/edge-config/edge-config-dashboard#manage-items-in-the-store) | ||
- [Using the Vercel API](https://vercel.com/docs/concepts/edge-network/edge-config/vercel-api#update-your-edge-config) | ||
|
||
Keep in mind that Edge Config is built for very high read volume, but for infrequent writes. | ||
|
||
## Features | ||
|
||
- Works in [Edge Runtime](https://edge-runtime.vercel.sh/), [Node.js](https://nodejs.org) and in the browser | ||
|
||
## Error Handling | ||
|
||
- An error is thrown in case of a network error | ||
- An error is thrown in case of an unexpected response | ||
|
||
## Edge Runtime Support | ||
|
||
`@vercel/edge-config` is compatible with the [Edge Runtime](https://edge-runtime.vercel.app/). It can be used inside environments like [Vercel Edge Functions](https://vercel.com/edge) as follows: | ||
|
||
```js | ||
// Next.js (pages/api/edge.js) (npm i next@canary) | ||
// Other frameworks (api/edge.js) (npm i -g vercel@canary) | ||
|
||
import { get } from '@vercel/edge-config'; | ||
|
||
export default (req) => { | ||
const value = await get("someKey") | ||
return new Response(`someKey contains value "${value})"`); | ||
}; | ||
|
||
export const config = { runtime: 'edge' }; | ||
``` | ||
|
||
## 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` | ||
To get started, see the [documentation](https://vercel.com/docs/storage) |
Oops, something went wrong.