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

chore(connect)!: drop support for node 14 and 16 #573

Merged
merged 6 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion .github/workflows/connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.X]
node-version: [18.x, 20.x]
deno-version: [1.x]

steps:
Expand Down
17 changes: 0 additions & 17 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
image:
file: .gitpod.Dockerfile

github:
prebuilds:
# enable for the default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: true
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: true
# add a check to pull requests (defaults to true)
addCheck: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
addComment: true
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
addBadge: false
2,518 changes: 1,477 additions & 1,041 deletions images/nano/deno.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions images/nano/deps.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export { default as hyper } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.0.2/packages/core/mod.ts'
export { default as app } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper-app-express%40v1.0.3/packages/app-express/mod.ts'
export { default as hyper } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.3.0/packages/core/mod.ts'
export { default as app } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper-app-express%40v1.2.0/packages/app-express/mod.ts'

// adapters
export { default as sqlite } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-sqlite/v2.0.11/mod.js'
export { default as fs } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-fs/v3.0.1/mod.js'
export { default as minisearch } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-minisearch/v2.1.3/mod.js'
export { default as hooks } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-hooks/v1.0.6/mod.js'
export { default as pouchdb } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-pouchdb/v0.1.7/mod.js'
export { default as queue } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-queue/v0.1.1/mod.js'
export { default as pouchdb } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-pouchdb/v0.2.0/mod.js'
export { default as queue } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-queue/v0.3.0/mod.js'

export { join } from 'https://deno.land/std@0.188.0/path/mod.ts'
export { parse } from 'https://deno.land/std@0.188.0/flags/mod.ts'
export * as Colors from 'https://deno.land/std@0.188.0/fmt/colors.ts'
export { join } from 'https://deno.land/std@0.207.0/path/mod.ts'
export { parseArgs as parse } from 'https://deno.land/std@0.207.0/cli/mod.ts'
export * as Colors from 'https://deno.land/std@0.207.0/fmt/colors.ts'
2 changes: 1 addition & 1 deletion images/nano/main.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from 'https://deno.land/std@0.188.0/testing/asserts.ts'
import { assertEquals } from 'https://deno.land/std@0.207.0/assert/mod.ts'
import { main } from './main.js'
import { createHarness } from './test-utils.js'

Expand Down
4 changes: 4 additions & 0 deletions packages/connect/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
clean:
@rm -rf dist to-node

# yarn build will run microbundle to bundle the transpiled node code into ESM, CJS, and UMD using microbundle
# However, the TS types are not interpreted correctly by microbundle, so we have
# to copy the types from the output of deno2node into the microbundle output folder in order to get types working
# a total hack to get the types working
to-node:
@deno run --no-check --allow-read --allow-write \
https://deno.land/x/[email protected]/src/cli.ts ./tsconfig.to-node.jsonc && \
Expand Down
24 changes: 17 additions & 7 deletions packages/connect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,38 @@ const results = await hyper.data.query({ type: 'game' })

### A Note for NodeJS

For Node environments, starting with `v0.5.0`, `hyper-connect`'s Storage service api returns a
For Node environments, starting with `v0.5.0`, `hyper-connect`'s Storage service api returns a Web
[`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) instead of a
`NodeJS.ReadableStream`. If you'd like a `NodeJS.ReadableStream`, follow one of the approaches
below.

If you're using `node>=17`, you can use Node's built in `fromWeb` to get a Node stream:

```js
import { createReadStream } from 'node:fs'
import { Readable } from 'node:stream'

const res = await hyper.storage.download(name)
const readableNodeStream = Readable.fromWeb(res)
// Convert the ReadableStream to a NodeJS.ReadableStream
await hyper.storage.download('foo.png')
.then((res) => {
if (!res.ok) throw res
return Readable.fromWeb(res.object)
})

// Or convert to a ReadbleStream from a NodeJS.ReadableStream
await hyper.storage.upload('foo.png', Readable.toWeb(createReadStream('foo.png')))
```

Otherwise, you will need to use `v0.4.0` or less of `hyper-connect`. Node `18` will be in LTS soon,
and we recommend upgrading to Node `18` LTS as soon as possible, to take advantage of the new Web
Standards centric features, like global `fetch` and `WebStreams`.

> Starting with Node 17, Node has changed how it resolves `localhost`, when using global `fetch` and
> `fetch` from libraries like `undici`. This may cause requests to `localhost` not to resolve
> correctly and fail. To get around this, you can use `127.0.0.1` or `0.0.0.0`, in lieu of
> `localhost`. For more info, See [this issue](https://github.com/nodejs/node/pull/39987)
#### Node 18 and `localhost`

Starting with Node 17, Node has changed how it resolves `localhost`, when using global `fetch` and
`fetch` from libraries like `undici`. This may cause requests to `localhost` not to resolve
correctly and fail. To get around this, you can use `127.0.0.1` or `0.0.0.0`, in lieu of
`localhost`. For more info, See [this issue](https://github.com/nodejs/node/pull/39987)

### Deno

Expand Down
22 changes: 10 additions & 12 deletions packages/connect/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
"semiColons": false
},
"lint": {
"files": {
"exclude": [
"./CHANGELOG.md",
"./dist",
"./to-node",
"node_modules/",
"node/node_modules",
"node/harness/cjs/node_modules",
"node/harness/esm/node_modules",
"./yarn.lock"
]
}
"exclude": [
"./CHANGELOG.md",
"./dist",
"./to-node",
"node_modules/",
"node/node_modules",
"node/harness/cjs/node_modules",
"node/harness/esm/node_modules",
"./yarn.lock"
]
}
}
Loading