Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nano)!: use In-Memory MongoDB in lieu of PouchDB to power Data Services #613

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
image:
file: .gitpod.Dockerfile

tasks:
- name: Setup Git Hooks
init: deno task prepare
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

deno task staged
7 changes: 7 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"**/*.{md,json,js,ts}": ["deno fmt"],
"**/README.md": [
"deno run -A --no-lock npm:markdown-toc-gen@1 insert",
"deno fmt"
]
}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
<a href="https://docs.hyper.io/whats-new">What's New</a>
</p>

<!-- toc -->

- [Introduction](#introduction)
- [Status](#status)
- [Running Locally](#running-locally)
- [Documentation](#documentation)
- [Contributions](#contributions)
- [Developer Setup](#developer-setup)
- [Thank you](#thank-you)

<!-- tocstop -->

## Introduction

👋 Hey 👋
Expand Down Expand Up @@ -63,7 +75,7 @@ Alternatively, if you're using `node`, you can run `npx hyper-nano`

This `nano` version of hyper implements the following ports and adapters:

- `data` (powered by [PouchDB](https://github.com/hyper63/hyper-adapter-pouchdb))
- `data` (powered by [In-Memory MongoDB](https://github.com/hyper63/hyper-adapter-mongodb))
- `cache` (powered by [Sqlite](https://github.com/hyper63/hyper-adapter-sqlite))
- `storage` (powered by your local [file system](https://github.com/hyper63/hyper-adapter-fs))
- `search` (powered by [Sqlite and Minisearch](https://github.com/hyper63/hyper-adapter-minisearch))
Expand Down
4 changes: 4 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"tasks": {
"prepare": "deno run -A --no-lock npm:husky@^8 install",
"staged": "deno run -A --no-lock npm:lint-staged@^15"
},
"fmt": {
"include": ["./"],
"exclude": ["./**/CHANGELOG.md"],
Expand Down
8 changes: 4 additions & 4 deletions images/nano/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ clean:

compile-linux:
@deno compile --target=x86_64-unknown-linux-gnu \
--allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--allow-run --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-unknown-linux-gnu-$(VER) mod.js

compile-apple:
@deno compile --target=x86_64-apple-darwin \
--allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--allow-run --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-apple-darwin-$(VER) mod.js

compile-arch-apple:
@deno compile --target=aarch64-apple-darwin \
--allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--allow-run --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-aarch64-apple-darwin-$(VER) mod.js

compile-windows:
@deno compile --target=x86_64-pc-windows-msvc \
--allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--allow-run --allow-sys --allow-env --allow-read --allow-write=__hyper__,/tmp/hyper --allow-net \
--unstable --no-check=remote \
--output ./build/hyper-x86_64-pc-windows-msvc-$(VER) mod.js
20 changes: 8 additions & 12 deletions images/nano/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ logic. `hyper-nano` is an embodiment of this approach.
[`adapters`](https://docs.hyper.io/oss/building-your-own-adapter) for all of the hyper service
offerings:

- data (powered by [PouchDB](https://github.com/hyper63/hyper-adapter-pouchdb))
- data (powered by [In-Memory MongoDB](https://github.com/hyper63/hyper-adapter-mongodb))
- cache (powered by [Sqlite](https://github.com/hyper63/hyper-adapter-sqlite))
- storage (powered by your local [file system](https://github.com/hyper63/hyper-adapter-fs))
- search (powered by [Sqlite and Minisearch](https://github.com/hyper63/hyper-adapter-minisearch))
Expand Down Expand Up @@ -78,7 +78,7 @@ npx hyper-nano --domain=foobar --experimental --data --cache ...
Alternatively, if you use `Deno` you may run `hyper nano` directly from the source:

```sh
deno run --allow-env --allow-read --allow-write=__hyper__ --allow-net --unstable --no-check=remote https://raw.githubusercontent.com/hyper63/hyper/main/images/nano/mod.js
deno run --allow-run --allow-env --allow-read --allow-write=__hyper__ --allow-net --unstable --no-check=remote https://raw.githubusercontent.com/hyper63/hyper/main/images/nano/mod.js
```

If you'd like to programmatically start `hyper nano`, you can import `main.js` and run `main`:
Expand All @@ -101,23 +101,23 @@ then consume your hyper instance
using `HTTP`.

To consume using [`hyper-connect`](https://github.com/hyper63/hyper/tree/main/packages/connect) pass
`http://localhost:[port]/[domain]` to `hyper-connect` as your
`http://127.0.0.1:[port]/[domain]` to `hyper-connect` as your
[`connection string`](https://docs.hyper.io/app-keys#nq-connection-string)

Consume with [`hyper-connect`](https://github.com/hyper63/hyper/tree/main/packages/connect):

```js
import { connect } from 'hyper-connect'

const hyper = connect('http://localhost:6363/test')
const hyper = connect('http://127.0.0.1:6363/test')

await hyper.data.list()
```

Or consume via HTTP

```sh
curl http://localhost:6363/data/test
curl http://127.0.0.1:6363/data/test
```

> Starting with Node 17, Node has changed how it resolves `localhost`, when using global `fetch` and
Expand Down Expand Up @@ -205,25 +205,21 @@ await main({
### cache

```
./scripts/cache.sh
deno task cache
```

### test

```
./scripts/test.sh
deno task test
```

### compile

```
./scripts/compile.sh
make clean compile-{target}
```

### actions

Github actions deploy hyper to https://hyperland.s3.amazonaws.com/hyper

## LICENSE

Apache 2.0
Loading