-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove compose.yaml * Migrate front-end to Turso's SQLite * Migrate collab server to Turso * Remove MySQL Extension
- Loading branch information
1 parent
f2e6a88
commit 38cebf0
Showing
16 changed files
with
515 additions
and
207 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,6 @@ yarn-error.log* | |
# Misc | ||
.DS_Store | ||
*.pem | ||
|
||
# SQLite | ||
local.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# The following is a sample a .env file, to get started create a copy and name | ||
# it ".env". | ||
|
||
NODE_ENV=development | ||
|
||
# Must match NEXTAUTH_SECRET on front-end as it is used to sign and validate JWTs | ||
AUTH_SECRET=secret | ||
|
||
TURSO_DATABASE_URL=file:../../local.db | ||
|
||
# Production | ||
|
||
# NODE_ENV=production | ||
# TURSO_AUTH_TOKEN= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { DatabaseConfiguration } from "@hocuspocus/extension-database"; | ||
import { createClient } from "@libsql/client"; | ||
import { env } from "./env.js"; | ||
|
||
const client = createClient({ | ||
url: env.TURSO_DATABASE_URL, | ||
authToken: env.TURSO_AUTH_TOKEN, | ||
}); | ||
|
||
const tursoConfiguration: DatabaseConfiguration = { | ||
async fetch({ documentName }) { | ||
const res = await client.execute({ | ||
sql: `SELECT name, data | ||
FROM document | ||
WHERE name = ? | ||
`, | ||
args: [documentName], | ||
}); | ||
|
||
const data = res.rows[0]?.data; | ||
if (data instanceof ArrayBuffer) { | ||
return new Uint8Array(data); | ||
} | ||
|
||
return null; | ||
}, | ||
|
||
async store({ documentName, state: documentData }) { | ||
const now = new Date().getTime(); | ||
await client.execute({ | ||
sql: `UPDATE document | ||
SET data = ?, | ||
modifiedOn = ? | ||
WHERE name = ? | ||
`, | ||
args: [documentName, now, documentData], | ||
}); | ||
}, | ||
}; | ||
|
||
export default tursoConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
NEXT_PUBLIC_COLLAB_SERVER_URL=ws://localhost:1234 | ||
|
||
# Local development database | ||
# This should match the same one configured for the collaboration server | ||
DATABASE_URL=mysql://root:pass@localhost/jotter | ||
|
||
TURSO_DATABASE_URL=file:../../local.db | ||
|
||
NEXTAUTH_URL=http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import mysql from "mysql2/promise"; | ||
import env from "@/config/env-server"; | ||
import { drizzle } from "drizzle-orm/mysql2"; | ||
import * as schema from "@/schema"; | ||
import { createClient } from "@libsql/client"; | ||
import { drizzle } from "drizzle-orm/libsql"; | ||
|
||
const connection = await mysql.createConnection(env.DATABASE_URL); | ||
const connection = await createClient({ | ||
url: env.TURSO_DATABASE_URL, | ||
authToken: env.TURSO_AUTH_TOKEN, | ||
}); | ||
|
||
const db = drizzle(connection, { mode: "planetscale", schema }); | ||
const db = drizzle(connection, { schema }); | ||
|
||
export default db; |
Oops, something went wrong.