Skip to content

Commit eb3d244

Browse files
authored
Minor updates to the examples folder (#47)
- Updated dependencies - Updated NextJS example slightly (no need to explicitly tell client to use fetch)
1 parent 31e27b2 commit eb3d244

File tree

10 files changed

+27
-39
lines changed

10 files changed

+27
-39
lines changed

examples/browser/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"vite": "^5.2.0"
1414
},
1515
"dependencies": {
16-
"@datastax/astra-db-ts": "^1.2.0",
16+
"@datastax/astra-db-ts": "^1.2.1",
1717
"events": "^3.3.0"
1818
}
1919
}

examples/cloudflare-workers/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cloudflare-workers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"wrangler": "^3.55.0"
1313
},
1414
"dependencies": {
15-
"@datastax/astra-db-ts": "^1.2.1-1",
15+
"@datastax/astra-db-ts": "^1.2.1",
1616
"events": "^3.3.0"
1717
}
1818
}

examples/http2-when-minified/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/http2-when-minified/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@datastax/astra-db-ts": "^1.2.1-1",
12+
"@datastax/astra-db-ts": "^1.2.1",
1313
"fetch-h2": "^3.0.0",
1414
"next": "14.2.3",
1515
"react": "^18",

examples/nextjs/README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22

33
## Overview
44

5-
`astra-db-ts` works nearly natively with Next.js, depending on the runtime used:
6-
- `edge`: `astra-db-ts` will work like normal here.
7-
- `nodejs`: the `DataAPIClient` may just need a hint to use `fetch` instead of the default http client under the hood, as such:
8-
```ts
9-
const client = new DataAPIClient('*TOKEN*', {
10-
httpOptions: { client: 'fetch' },
11-
});
12-
```
13-
14-
See `examples/http2-when-minified` for more information about using HTTP/2 with Next.js.
5+
`astra-db-ts` works natively with Next.js. Just some minor special action is necessary if you need to use
6+
HTTP/2. See `examples/http2-when-minified` for more information about using HTTP/2 with Next.js.
157

168
This is a simple example of how it can be used to interact with an Astra database; it'll simply
179
list out all the collections in a given database.

examples/nextjs/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@datastax/astra-db-ts": "^1.2.1-1",
12+
"@datastax/astra-db-ts": "^1.2.1",
1313
"next": "14.2.3",
1414
"react": "^18",
1515
"react-dom": "^18"

examples/nextjs/src/app/route.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { DataAPIClient } from '@datastax/astra-db-ts';
22

3-
// Creates the client with the `httpOptions` set to use the `fetch` client as Next.js's minification
4-
// conflicts with the importing of our default http client (see http2-when-minified for more info)
5-
// See `examples/http2-when-minified` for more information on how to use HTTP/2 with Next.js
6-
const client = new DataAPIClient(process.env.ASTRA_DB_TOKEN!, {
7-
httpOptions: { client: 'fetch' },
8-
});
3+
// Creates the client. Because the code is minified (when ran), astra-db-ts will default to using
4+
// `fetch` as the HTTP client. If you need HTTP/2, please see `examples/http2-when-minified` for more
5+
// information on how to use HTTP/2 with Next.js
6+
const client = new DataAPIClient(process.env.ASTRA_DB_TOKEN!);
97
const db = client.db(process.env.ASTRA_DB_ENDPOINT!);
108

11-
// If `runtime` is set to `edge`, you could get away without needing to specify the specific
12-
// client, as `astra-db-ts` would be able to infer that it should use `fetch` for you.
13-
// e.g. `const client = new DataAPIClient(process.env.ASTRA_DB_TOKEN!);`
9+
// You may use the edge runtime as normal as well. HTTP/2 is not supported here, at all.
1410
// export const runtime = 'edge';
1511

1612
// Simple example which (attempts to) list all the collections in the database

0 commit comments

Comments
 (0)