Skip to content

Commit

Permalink
feat: Create storage monorepo (#100)
Browse files Browse the repository at this point in the history
* feat: Create storage monorepo

* chore: Changeset for package.json modifications

* Update README.md
  • Loading branch information
1 parent 7c8d9c2 commit 1ade1f0
Show file tree
Hide file tree
Showing 82 changed files with 12,045 additions and 2,031 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"linked": [["@vercel/postgres", "@vercel/postgres-kysely"]],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
Expand Down
8 changes: 8 additions & 0 deletions .changeset/pretty-lamps-develop.md
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
10 changes: 10 additions & 0 deletions .eslintrc.js
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'),
},
};
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

on:
push:
branches: [main]
Expand Down Expand Up @@ -29,7 +33,7 @@ jobs:
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: pnpm install

- name: Run tests
run: pnpm test
70 changes: 49 additions & 21 deletions .github/workflows/quality.yml
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]
Expand All @@ -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
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Release

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

on:
push:
branches:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules/

# logs
npm-debug.log

.turbo
.DS_Store
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist
node_modules
pnpm-lock.yaml
pnpm-lock.yaml
120 changes: 6 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,8 @@
# @vercel/edge-config
# Vercel Storage

![CI](https://github.com/vercel/edge-config/workflows/CI/badge.svg)
![Edge Runtime Compatible](https://img.shields.io/badge/edge--runtime-%E2%9C%94%20compatible-black)
- [`@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)
Loading

0 comments on commit 1ade1f0

Please sign in to comment.