Skip to content

Commit

Permalink
feat: use libsql stateless as default (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal authored Apr 19, 2024
1 parent 1bd7009 commit bc95a87
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
20 changes: 17 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"dotenv": "^16.4.5",
"drizzle-orm": "^0.30.1",
"eslint-plugin-jest": "^27.6.3",
"libsql-stateless-easy": "^1.5.8",
"lucia": "^3.1.1",
"lucide-react": "^0.309.0",
"magic-bytes.js": "^1.10.0",
Expand Down
23 changes: 18 additions & 5 deletions studio/src/drivers/turso-driver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
InStatement,
ResultSet,
} from "@libsql/client/web";
import { createClient as createClientStateless } from "libsql-stateless-easy";
import {
SqliteLikeBaseDriver,
DatabaseHeader,
Expand Down Expand Up @@ -64,11 +65,23 @@ export default class TursoDriver extends SqliteLikeBaseDriver {
this.authToken = authToken;
this.bigInt = bigInt;

this.client = createClient({
url: this.endpoint,
authToken: this.authToken,
intMode: bigInt ? "bigint" : "number",
});
if (
url.startsWith("libsql://") ||
url.startsWith("http://") ||
url.startsWith("https://")
) {
this.client = createClientStateless({
url: this.endpoint.replace(/^libsql:\/\//, "https://"),
authToken: this.authToken,
intMode: bigInt ? "bigint" : "number",
});
} else {
this.client = createClient({
url: this.endpoint,
authToken: this.authToken,
intMode: bigInt ? "bigint" : "number",
});
}
}

supportBigInt(): boolean {
Expand Down

0 comments on commit bc95a87

Please sign in to comment.