tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
re-add db stuff to appview
awarm.space
6 months ago
6c04c63a
fa8f7cb2
+11
-2
1 changed file
expand all
collapse all
unified
split
appview
index.ts
+11
-2
appview/index.ts
···
20
20
import { createIdentity } from "actions/createIdentity";
21
21
import { drizzle } from "drizzle-orm/node-postgres";
22
22
import { inngest } from "app/api/inngest/client";
23
23
+
import { Pool } from "pg";
23
24
24
25
const cursorFile = process.env.CURSOR_FILE || "/cursor/cursor";
25
26
···
30
31
const QUOTE_PARAM = "/l-quote/";
31
32
async function main() {
32
33
let startCursor;
34
34
+
const pool = new Pool({
35
35
+
connectionString: process.env.DB_URL,
36
36
+
});
33
37
try {
34
38
let file = (await readFile(cursorFile)).toString();
35
39
console.log("START CURSOR: " + file);
···
90
94
});
91
95
92
96
if (error && error.code === "23503") {
93
93
-
let db = drizzle(process.env.DB_URL!);
97
97
+
let c = await pool.connect();
98
98
+
let db = drizzle(c);
94
99
await createIdentity(db, { atp_did: evt.did });
100
100
+
c.release();
95
101
await supabase.from("publications").upsert({
96
102
uri: evt.uri.toString(),
97
103
identity_did: evt.did,
···
138
144
record: record.value as Json,
139
145
});
140
146
if (error && error.code === "23503") {
147
147
+
let c = await pool.connect();
148
148
+
let db = drizzle(c);
141
149
await createIdentity(db, { atp_did: evt.did });
150
150
+
c.release();
142
151
await supabase.from("publication_subscriptions").upsert({
143
152
uri: evt.uri.toString(),
144
153
identity: evt.did,
···
260
269
firehose.start();
261
270
const cleanup = async () => {
262
271
console.log("shutting down firehose...");
263
263
-
client.release();
272
272
+
pool.end();
264
273
await firehose.destroy();
265
274
await runner.destroy();
266
275
process.exit();