-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More cleanup
- Loading branch information
Showing
6 changed files
with
86 additions
and
213 deletions.
There are no files selected for viewing
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,16 +1,20 @@ | ||
import { db } from "../../db" | ||
import { pool } from "../../db" | ||
import { NextResponse } from "next/server" | ||
|
||
export async function POST(request: Request) { | ||
const body = await request.json() | ||
const db = await pool.connect() | ||
try { | ||
const body = await request.json() | ||
|
||
await db.query( | ||
`INSERT INTO ydoc_awareness (client, room, op) | ||
await db.query( | ||
`INSERT INTO ydoc_awareness (client, room, op) | ||
VALUES ($1, $2, $3) | ||
ON CONFLICT (client, room) | ||
DO UPDATE SET op = $3`, | ||
[body.client, body.room, body.op] | ||
) | ||
|
||
return NextResponse.json({}) | ||
[body.client, body.room, body.op] | ||
) | ||
return NextResponse.json({}) | ||
} finally { | ||
db.release() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import pgPkg from "pg" | ||
const { Client } = pgPkg | ||
import { Pool } from "pg" | ||
|
||
const db = new Client({ | ||
console.log(`init pool`) | ||
const pool = new Pool({ | ||
host: `localhost`, | ||
port: 54321, | ||
password: `password`, | ||
user: `postgres`, | ||
database: `electric`, | ||
max: 1, | ||
}) | ||
|
||
db.connect() | ||
|
||
export { db } | ||
export { pool } |
Oops, something went wrong.