Skip to content

Commit

Permalink
Merge pull request #88 from thedanchez/ci-workflow
Browse files Browse the repository at this point in the history
build: refines github workflow, adds linting
  • Loading branch information
jchris authored Feb 6, 2024
2 parents 110cdb3 + 63fbd1f commit c1b93e5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 81 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jchris
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI
on:
- push
- pull_request

jobs:
quality-checks:
name: Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20.10.0

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.15.0
run_install: false

- name: Install Dependencies
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Lint Check
run: pnpm lint:check

- name: Format Check
run: pnpm format:check

- name: Run Tests
run: pnpm test
43 changes: 0 additions & 43 deletions .github/workflows/test.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"standard.enable": false
}
"editor.codeActionsOnSave": {
"source.fixAll": "always"
},
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange"
}
66 changes: 30 additions & 36 deletions packages/react/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# <img src="https://fireproof.storage/static/img/flame.svg" alt="Fireproof logo" width="25"> [Fireproof](https://fireproof.storage) – live database for the web

<p align="right">
Expand All @@ -10,7 +8,7 @@

Simplify your application state with a live database. Automatically update your UI based on local or remote changes, and optionally integrate with any cloud for replication and sharing.

Fireproof is an embedded JavaScript document database designed to streamline app development. Data resides locally, with optional encrypted cloud storage and real-time sync and collaboration. Features like live queries, database branches and snapshots, and file attachments make Fireproof ideal for browser-based apps big or small.
Fireproof is an embedded JavaScript document database designed to streamline app development. Data resides locally, with optional encrypted cloud storage and real-time sync and collaboration. Features like live queries, database branches and snapshots, and file attachments make Fireproof ideal for browser-based apps big or small.

Fireproof works in the browser, server, edge function, and any other JavaScript environment, with [connectors for popular backend services like AWS, Netlify, and PartyKit.]()

Expand All @@ -31,7 +29,7 @@ npm install @fireproof/core
The default build is optimized for browsers, to load the node build add `/node`:

```js
import { fireproof } from '@fireproof/core/node'
import { fireproof } from "@fireproof/core/node";
```

Add the database to any web page via HTML script tag (global is `Fireproof`):
Expand All @@ -41,8 +39,8 @@ Add the database to any web page via HTML script tag (global is `Fireproof`):
```

Go ahead and write features, then [connect to any cloud backend](https://www.npmjs.com/package/@fireproof/connect) later.
### JavaScript Example

### JavaScript Example

```js
import { fireproof } from 'use-fireproof'
Expand All @@ -60,7 +58,7 @@ const result = await db.query("age", { range: [40, 52] })

Jump to the docs site [for JavaScript API basics.](https://use-fireproof.com/docs/database-api/basics) You can [find a real-world JavaScript app here.](https://github.com/mlc-ai/web-stable-diffusion/pull/52) Fireproof has been tested in many JavaScript environments. Read more about [bundler support](https://use-fireproof.com/docs/bundling).

### React Example
### React Example

Fireproof has React hooks so you can avoid boilerplate and write expressive code. Instead of dealing with React contexts and reducers, simple hooks make your JSON documents feel like `setState()` objects.

Expand All @@ -74,7 +72,7 @@ function App() {
Read the [step-by-step React tutorial](https://use-fireproof.com/docs/react-tutorial) to get started, or [check out this code sandbox example](https://codesandbox.io/s/fireproof-react-antd-twelve-nk63z6?file=/src/App.tsx) to see how easy it is to build a basic app.
## Why choose Fireproof
## Why choose Fireproof
Fireproof has a unique take on distributed data integrity, rooted in immutable data and cryptographically verifiable protocols. This allows you to add live data to any app without complex configuration or installation (it's just an npm module) and if you decide to connect to the cloud you can easily choose storage providers or connect to your own S3 bucket. End-to-end encryption allows you to manage keys separately from data, defining custom security policies, so you can get started writing app features today, and connect to any environment when you are ready. This infrastructure independence makes Fireproof great for brownfield and greenfield projects alike.
Expand All @@ -84,11 +82,11 @@ Fireproof has a unique take on distributed data integrity, rooted in immutable d
The core features of the database are available on any platform in a compact JavaScript package and a foundational cloud storage service.
* **JSON Documents** - Encrypted changes are persisted locally and to any connected storage. Store any JSON object using a familiar document database API.
* **File Attachments** - Share social media or manage uploads within Fireproof's [file attachment API](https://use-fireproof.com/docs/database-api/documents#put-with-files). Attachments are stored locally and in the cloud, and can be encrypted or public.
* **Live Query** - Sort and filter any database with CouchDB-style `map` functions. The `useFireproof` React hook integrates so cleanly your code doesn't even have to import `useState` or `useEffect`, instead, [`useLiveQuery`](https://use-fireproof.com/docs/react-hooks/use-live-query) makes dynamic renders easy.
* **Realtime Updates** - [Subscribe to query changes in your application](https://use-fireproof.com/docs/database-api/database#subscribing-to-changes), so your UI updates automatically. This makes vanilla JS apps super easy to build -- the `useFireproof` React hook handles this so you won't need `db.subscribe()` there.
* **Cryptographic Proofs** - Fireproof's Merkle clocks and hash trees are immutable and self-validating, making all query results into offline-capable data slices. Fireproof makes cryptographic proofs available for all of its operations, accelerating replication and making trustless index sharing possible. This makes it a great choice for building custom document approval workflows or other situations where provenance is important.
- **JSON Documents** - Encrypted changes are persisted locally and to any connected storage. Store any JSON object using a familiar document database API.
- **File Attachments** - Share social media or manage uploads within Fireproof's [file attachment API](https://use-fireproof.com/docs/database-api/documents#put-with-files). Attachments are stored locally and in the cloud, and can be encrypted or public.
- **Live Query** - Sort and filter any database with CouchDB-style `map` functions. The `useFireproof` React hook integrates so cleanly your code doesn't even have to import `useState` or `useEffect`, instead, [`useLiveQuery`](https://use-fireproof.com/docs/react-hooks/use-live-query) makes dynamic renders easy.
- **Realtime Updates** - [Subscribe to query changes in your application](https://use-fireproof.com/docs/database-api/database#subscribing-to-changes), so your UI updates automatically. This makes vanilla JS apps super easy to build -- the `useFireproof` React hook handles this so you won't need `db.subscribe()` there.
- **Cryptographic Proofs** - Fireproof's Merkle clocks and hash trees are immutable and self-validating, making all query results into offline-capable data slices. Fireproof makes cryptographic proofs available for all of its operations, accelerating replication and making trustless index sharing possible. This makes it a great choice for building custom document approval workflows or other situations where provenance is important.
Learn more about the [architecture](https://use-fireproof.com/docs/architecture) behind Fireproof.
Expand All @@ -100,7 +98,7 @@ With Fireproof, you **build first** and connect it to your cloud of choice when
### AI Copilot Quick Start
Because Fireproof is designed to let you get started in the browser and connect to the cloud when you're ready, it's ideal for AI-assisted app development. If you are using GPT, Claude, or Bard, you can [easily enable the AI to write React apps using Fireproof](https://hackernoon.com/get-chatgpt-to-focus-on-coding-on-the-right-apis-with-gptdoc-strings).
Because Fireproof is designed to let you get started in the browser and connect to the cloud when you're ready, it's ideal for AI-assisted app development. If you are using GPT, Claude, or Bard, you can [easily enable the AI to write React apps using Fireproof](https://hackernoon.com/get-chatgpt-to-focus-on-coding-on-the-right-apis-with-gptdoc-strings).
Working with an AI assistant is a great way to get started on projects or try out new frameworks. Paste this line of code into your prompt, along with a detailed description of the app to build, and your app will be running without ever requiring a cloud.
Expand All @@ -115,18 +113,18 @@ For example prompts and inspiration [check out the illustrated version of this t
Import from the package like this:
```js
import { fireproof } from 'use-fireproof'
import { fireproof } from "use-fireproof";
```
and create a database:
```js
const database = fireproof('my-app-name')
const database = fireproof("my-app-name");
```
### JSON Documents
A simple put, get and delete interface for keeping track of all your JSON documents. Once your data is in Fireproof you can access it from any app or website.
A simple put, get and delete interface for keeping track of all your JSON documents. Once your data is in Fireproof you can access it from any app or website.
```js
const { id } = await database.put({
Expand All @@ -135,7 +133,7 @@ const { id } = await database.put({
age: 47
});

const doc = await database.get('three-thousand')
const doc = await database.get('three-thousand')
// {
// _id : 'three-thousand'
// name : 'André',
Expand All @@ -145,26 +143,25 @@ const doc = await database.get('three-thousand')
Fireproof tracks all versions so undo is easy to write, and cryptographically verifiable snapshots of the database are as easy as web links.
### Flexible Query
```js
const { rows } = await database.query("age", { range: [40, 52] })
const { rows } = await database.query("age", { range: [40, 52] });
```
Fireproof provides a live query interface that allows you to subscribe to changes in your data. This means that your UI will automatically update whenever there is a change to your data. See the [useFireproof React hooks documentation](https://github.com/fireproof-storage/fireproof/blob/main/packages/react/README.md) for the easiest way to use this feature.
You can specify your function as a string and Fireproof will interpret it as indexing that field on all documents. You can also pass a function for more control:
```js
const { rows } = await database.query(function (doc, map) {
map(doc.age, doc.name)
}, { range: [40, 52] })
const { rows } = await database.query(
function (doc, map) {
map(doc.age, doc.name);
},
{ range: [40, 52] }
);
```
The same mechanism that powers the built-in indexes can all be used to connect secondary [vector indexers](https://github.com/tantaraio/voy) or fulltext indexes to Fireproof. [Follow this tutorial to connect a secondary index](https://fireproof.storage/documentation/external-indexers/).
### Realtime Updates
Expand All @@ -182,25 +179,23 @@ const unsubscribe = database.subscribe(changes) => {
Return the `unsubscribe` function from `useEffect` and React will handle it for you. (In the code below, we use the arrow function's implicit return to connect the unsubscribe function to the `useEffect` hook. This prevents extra subscriptions from building up on each render.)
```js
useEffect(() => database.subscribe((changes) =>
changes.forEach(change => console.log(change))), [])
useEffect(() => database.subscribe((changes) => changes.forEach((change) => console.log(change))), []);
```
The React [useLiveQuery](https://use-fireproof.com/docs/react-hooks/use-live-query) hook automatically refreshes query results for you, but under the hood, it's just calling `index.query()` and calling `setState()` when the results change. You can use the same technique to build your live query UIs with any framework.
### Cryptographic Proofs
Fireproof's Merkle clocks and hash trees are immutable and self-validating, and all query results are offline-capable data slices. Fireproof makes cryptographic proofs available for all of its operations, accelerating replication and making trustless index sharing possible. If you are making a "DocuSign for _____", [proofs make Fireproof the ideal verifiable document database](https://fireproof.storage/posts/from-mlops-to-point-of-sale:-merkle-proofs-and-data-locality/) for smart contracts and other applications where unique, verifiable, and trustworthy data is required. [Proof chains provide performance benefits as well](https://purrfect-tracker-45c.notion.site/Data-Routing-23c37b269b4c4c3dacb60d0077113bcb), by allowing recipients to skip costly I/O operations and instead cryptographically verify that changes contain all of the required context.
Fireproof's Merkle clocks and hash trees are immutable and self-validating, and all query results are offline-capable data slices. Fireproof makes cryptographic proofs available for all of its operations, accelerating replication and making trustless index sharing possible. If you are making a "DocuSign for **\_**", [proofs make Fireproof the ideal verifiable document database](https://fireproof.storage/posts/from-mlops-to-point-of-sale:-merkle-proofs-and-data-locality/) for smart contracts and other applications where unique, verifiable, and trustworthy data is required. [Proof chains provide performance benefits as well](https://purrfect-tracker-45c.notion.site/Data-Routing-23c37b269b4c4c3dacb60d0077113bcb), by allowing recipients to skip costly I/O operations and instead cryptographically verify that changes contain all of the required context.
### Cloud Storage
When you are ready to save your data to the cloud for sharing or backup:
```js
import { connect } from 'use-fireproof'
import { connect } from "use-fireproof";

const connection = await connect.web3(db, '[email protected]')
const connection = await connect.web3(db, "[email protected]");
```
You can tie any app to your app developer storage account, or allow users to create personal storage accounts (at no cost to you).
Expand All @@ -211,10 +206,9 @@ Currently, the web3 driver only stores database data, not metadata, but that sti
The six-month roadmap for Fireproof includes these features to make it a complete offering for application data.
### Automatic Replication
Documents changes are persisted to [Filecoin](https://filecoin.io) via [web3.storage](https://web3.storage), and made available over IPFS and on a global content delivery network. All you need to do to sync state is send a link to the latest database head, and Fireproof will take care of the rest.
Documents changes are persisted to [Filecoin](https://filecoin.io) via [web3.storage](https://web3.storage), and made available over IPFS and on a global content delivery network. All you need to do to sync state is send a link to the latest database head, and Fireproof will take care of the rest.
### Peer-to-peer Sync
Expand Down

0 comments on commit c1b93e5

Please sign in to comment.