From c31172aaf1cb2c99c075a227c8547a9c8c148b56 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 13:25:15 -0300 Subject: [PATCH 1/7] refactor(templates/drizzle-tidb): Update connection method Updated the connection method for the Drizzle + TiDB template. --- templates/javascript/drizzle-tidb-sample/package.json | 4 ++-- .../javascript/drizzle-tidb-sample/src/function/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/javascript/drizzle-tidb-sample/package.json b/templates/javascript/drizzle-tidb-sample/package.json index 3c095ebd..057bd443 100644 --- a/templates/javascript/drizzle-tidb-sample/package.json +++ b/templates/javascript/drizzle-tidb-sample/package.json @@ -18,10 +18,10 @@ "author": "azion", "license": "MIT", "dependencies": { - "@tidbcloud/serverless": "^0.1.1", + "@tidbcloud/serverless": "^0.2.0", "azion": "latest", "dotenv": "^16.3.1", - "drizzle-orm": "^0.31.2", + "drizzle-orm": "^0.35.2", "itty-router": "4.0.23" } } diff --git a/templates/javascript/drizzle-tidb-sample/src/function/index.js b/templates/javascript/drizzle-tidb-sample/src/function/index.js index 6582e7c6..3f8c78ae 100644 --- a/templates/javascript/drizzle-tidb-sample/src/function/index.js +++ b/templates/javascript/drizzle-tidb-sample/src/function/index.js @@ -30,7 +30,7 @@ async function handleRequest(request, args) { username: args.username || Azion.env.get("DRIZZLE_TIDB_USERNAME"), }); - const db = drizzle(client); + const db = drizzle({ client }); // Setup TiDB Table const posts = mysqlTable('posts', { From 503dd80b8095191c2283da7959dc3d0c620bd8d0 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 13:49:05 -0300 Subject: [PATCH 2/7] refactor(templates/drizzle-turso): Update connection method Updated the connection method for the Drizzle + Turso template. --- templates/javascript/drizzle-turso-sample/package.json | 4 ++-- .../javascript/drizzle-turso-sample/src/function/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/javascript/drizzle-turso-sample/package.json b/templates/javascript/drizzle-turso-sample/package.json index edda4c11..d09fbbc4 100644 --- a/templates/javascript/drizzle-turso-sample/package.json +++ b/templates/javascript/drizzle-turso-sample/package.json @@ -18,10 +18,10 @@ "author": "azion", "license": "MIT", "dependencies": { - "@libsql/client": "^0.5.3", + "@libsql/client": "^0.14.0", "azion": "latest", "dotenv": "^16.3.1", - "drizzle-orm": "^0.31.2", + "drizzle-orm": "^0.35.2", "itty-router": "4.0.23" } } diff --git a/templates/javascript/drizzle-turso-sample/src/function/index.js b/templates/javascript/drizzle-turso-sample/src/function/index.js index 4c1e25ee..31f1086b 100644 --- a/templates/javascript/drizzle-turso-sample/src/function/index.js +++ b/templates/javascript/drizzle-turso-sample/src/function/index.js @@ -1,7 +1,7 @@ import { MainRouter } from "../lib/routers/main-router.js"; import { PageRouter } from "../lib/routers/page-router.js"; import { ApiRouter } from "../lib/routers/api-router.js"; -import { createClient } from "@libsql/client/web"; +import { createClient } from '@libsql/client'; import { drizzle } from 'drizzle-orm/libsql'; import { integer, text, sqliteTable } from "drizzle-orm/sqlite-core"; @@ -26,7 +26,7 @@ async function handleRequest(request, args) { url: args.url || Azion.env.get("DRIZZLE_TURSO_URL"), authToken: args.token || Azion.env.get("DRIZZLE_TURSO_TOKEN"), }); - const db = drizzle(client); + const db = drizzle({ client }); // Setup Turso Table const posts = sqliteTable('posts', { From 7311badcd5a80f5a4a437b66c3885158a662d3e9 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 14:05:10 -0300 Subject: [PATCH 3/7] refactor(templates/drizzle-neon): Update connection method Updated the connection method for the Drizzle + Neon template. --- templates/javascript/drizzle-neondb-sample/package.json | 4 ++-- .../javascript/drizzle-neondb-sample/src/function/index.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/templates/javascript/drizzle-neondb-sample/package.json b/templates/javascript/drizzle-neondb-sample/package.json index c5dcda2b..0d0af79e 100644 --- a/templates/javascript/drizzle-neondb-sample/package.json +++ b/templates/javascript/drizzle-neondb-sample/package.json @@ -18,10 +18,10 @@ "author": "azion", "license": "MIT", "dependencies": { - "@neondatabase/serverless": "^0.9.3", + "@neondatabase/serverless": "^0.10.1", "azion": "latest", "dotenv": "^16.3.1", - "drizzle-orm": "^0.31.2", + "drizzle-orm": "^0.35.2", "itty-router": "4.0.23" } } diff --git a/templates/javascript/drizzle-neondb-sample/src/function/index.js b/templates/javascript/drizzle-neondb-sample/src/function/index.js index 0c738b3f..37aeb702 100644 --- a/templates/javascript/drizzle-neondb-sample/src/function/index.js +++ b/templates/javascript/drizzle-neondb-sample/src/function/index.js @@ -1,7 +1,6 @@ import { MainRouter } from "../lib/routers/main-router.js"; import { PageRouter } from "../lib/routers/page-router.js"; import { ApiRouter } from "../lib/routers/api-router.js"; -import { neon } from '@neondatabase/serverless'; import { drizzle } from 'drizzle-orm/neon-http'; import { pgTable, text, serial } from "drizzle-orm/pg-core"; @@ -22,11 +21,10 @@ async function handleRequest(request, args) { }); //Setup Neon connection - const client = neon( + const db = drizzle( args.connection_url || Azion.env.get("DRIZZLE_NEON_CONNECTION_URL") ); - const db = drizzle(client); //Setup Neon table const posts = pgTable('posts', { From efb4fc56a738a95f63c421829d64a19ae0c66ca5 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 14:09:29 -0300 Subject: [PATCH 4/7] fix(templates/drizzle-neon): remove unused dependencies --- templates/javascript/drizzle-neondb-sample/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/javascript/drizzle-neondb-sample/package.json b/templates/javascript/drizzle-neondb-sample/package.json index 0d0af79e..bc74ecf1 100644 --- a/templates/javascript/drizzle-neondb-sample/package.json +++ b/templates/javascript/drizzle-neondb-sample/package.json @@ -18,7 +18,6 @@ "author": "azion", "license": "MIT", "dependencies": { - "@neondatabase/serverless": "^0.10.1", "azion": "latest", "dotenv": "^16.3.1", "drizzle-orm": "^0.35.2", From 07ddb45d4634ac5290c53ff25e6652034a7a0cb6 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 14:13:09 -0300 Subject: [PATCH 5/7] refactor(templates/drizzle-tidb): Update connection method Updated the connection method for the Drizzle + TiDB template --- .../drizzle-tidb-sample/src/function/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/templates/javascript/drizzle-tidb-sample/src/function/index.js b/templates/javascript/drizzle-tidb-sample/src/function/index.js index 3f8c78ae..5f795693 100644 --- a/templates/javascript/drizzle-tidb-sample/src/function/index.js +++ b/templates/javascript/drizzle-tidb-sample/src/function/index.js @@ -1,7 +1,6 @@ import { MainRouter } from "../lib/routers/main-router.js"; import { PageRouter } from "../lib/routers/page-router.js"; import { ApiRouter } from "../lib/routers/api-router.js"; -import { connect } from '@tidbcloud/serverless'; import { drizzle } from 'drizzle-orm/tidb-serverless'; import { mysqlTable, int, text } from 'drizzle-orm/mysql-core'; @@ -22,16 +21,16 @@ async function handleRequest(request, args) { }); // Setup TiDB connection - const client = connect({ - database: args.database || Azion.env.get("DRIZZLE_TIDB_DATABASE"), - host: args.host || Azion.env.get("DRIZZLE_TIDB_HOST"), - password: args.password || Azion.env.get("DRIZZLE_TIDB_PASSWORD"), - port: args.port || Azion.env.get("DRIZZLE_TIDB_PORT"), - username: args.username || Azion.env.get("DRIZZLE_TIDB_USERNAME"), + const db = drizzle({ + connection: { + database: args.database || Azion.env.get("DRIZZLE_TIDB_DATABASE"), + host: args.host || Azion.env.get("DRIZZLE_TIDB_HOST"), + password: args.password || Azion.env.get("DRIZZLE_TIDB_PASSWORD"), + port: args.port || Azion.env.get("DRIZZLE_TIDB_PORT"), + username: args.username || Azion.env.get("DRIZZLE_TIDB_USERNAME"), + } }); - const db = drizzle({ client }); - // Setup TiDB Table const posts = mysqlTable('posts', { id: int('id'), From 23e13d4262aac05267fd6b3c964f06c0cd87026d Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 14:14:09 -0300 Subject: [PATCH 6/7] fix(templates/drizzle-tidb): remove unused dependencies --- templates/javascript/drizzle-tidb-sample/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/javascript/drizzle-tidb-sample/package.json b/templates/javascript/drizzle-tidb-sample/package.json index 057bd443..9372fc06 100644 --- a/templates/javascript/drizzle-tidb-sample/package.json +++ b/templates/javascript/drizzle-tidb-sample/package.json @@ -18,7 +18,6 @@ "author": "azion", "license": "MIT", "dependencies": { - "@tidbcloud/serverless": "^0.2.0", "azion": "latest", "dotenv": "^16.3.1", "drizzle-orm": "^0.35.2", From 0c7c371187179f2c80068dbbf183ac002ed84e95 Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Mon, 21 Oct 2024 14:17:53 -0300 Subject: [PATCH 7/7] fix(templates/drizzle-turso): remove unused dependencies --- .../javascript/drizzle-turso-sample/package.json | 1 - .../drizzle-turso-sample/src/function/index.js | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/templates/javascript/drizzle-turso-sample/package.json b/templates/javascript/drizzle-turso-sample/package.json index d09fbbc4..429c17f2 100644 --- a/templates/javascript/drizzle-turso-sample/package.json +++ b/templates/javascript/drizzle-turso-sample/package.json @@ -18,7 +18,6 @@ "author": "azion", "license": "MIT", "dependencies": { - "@libsql/client": "^0.14.0", "azion": "latest", "dotenv": "^16.3.1", "drizzle-orm": "^0.35.2", diff --git a/templates/javascript/drizzle-turso-sample/src/function/index.js b/templates/javascript/drizzle-turso-sample/src/function/index.js index 31f1086b..b352d5ee 100644 --- a/templates/javascript/drizzle-turso-sample/src/function/index.js +++ b/templates/javascript/drizzle-turso-sample/src/function/index.js @@ -1,7 +1,6 @@ import { MainRouter } from "../lib/routers/main-router.js"; import { PageRouter } from "../lib/routers/page-router.js"; import { ApiRouter } from "../lib/routers/api-router.js"; -import { createClient } from '@libsql/client'; import { drizzle } from 'drizzle-orm/libsql'; import { integer, text, sqliteTable } from "drizzle-orm/sqlite-core"; @@ -21,12 +20,13 @@ async function handleRequest(request, args) { return new Response(`You are trying something incorrect.`, { status: 200 }); }); - //Setup Turso connection - const client = createClient({ - url: args.url || Azion.env.get("DRIZZLE_TURSO_URL"), - authToken: args.token || Azion.env.get("DRIZZLE_TURSO_TOKEN"), + // Setup Turso connection + const db = drizzle({ + connection: { + url: args.url || Azion.env.get("DRIZZLE_TURSO_URL"), + authToken: args.token || Azion.env.get("DRIZZLE_TURSO_TOKEN"), + } }); - const db = drizzle({ client }); // Setup Turso Table const posts = sqliteTable('posts', {