-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uWebsockets.js] Upgrade to v20.31.0 (#8332)
* [uWebsockets.js] Upgrade to v20.31.0 * [uWebsockets.js] Upgrade to v20.31.0 * [uWebsockets.js] Refactor(server.js): escape unsafe html using regex * [uWebsockets.js] Refactor(postgres.js): change database driver from pg to postgres.js * [uWebsockets.js] Refactor(postgres.js): fix warn invalid date header * [uwebsockets.js] Update README.md * [uWebsockets.js] Refactor(server.js): improve fortunes * [uWebsockets.js] Refactor(server.js): update fortunes * [uWebsockets.js] Upgrade to v20.31.0 * [uWebsockets.js] Refactor server.js, utils.js, and postgres.js
- Loading branch information
Showing
6 changed files
with
65 additions
and
345 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
285 changes: 12 additions & 273 deletions
285
frameworks/JavaScript/uwebsockets.js/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
21 changes: 6 additions & 15 deletions
21
frameworks/JavaScript/uwebsockets.js/src/database/postgres.js
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,24 +1,15 @@ | ||
import Pool from "pg-pool"; | ||
import postgres from "postgres"; | ||
|
||
const pool = new Pool({ | ||
const sql = postgres({ | ||
host: "tfb-database", | ||
user: "benchmarkdbuser", | ||
password: "benchmarkdbpass", | ||
database: "hello_world", | ||
max: 1 | ||
}); | ||
|
||
await pool.connect(); | ||
export const fortunes = async () => await sql`SELECT id, message FROM fortune`; | ||
|
||
const query = (text, values) => | ||
pool.query(text, values || []).then((r) => r.rows); | ||
export const find = async (id) => await sql`SELECT id, randomNumber FROM world WHERE id = ${id}`.then((arr) => arr[0]); | ||
|
||
export const fortunes = () => query("SELECT * FROM fortune"); | ||
|
||
export const find = (id) => | ||
query("SELECT * FROM world WHERE id = $1", [id]).then((arr) => arr[0]); | ||
|
||
export const update = (obj) => | ||
query("UPDATE world SET randomNumber = $1 WHERE id = $2", [ | ||
obj.randomNumber, | ||
obj.id, | ||
]); | ||
export const update = async (obj) => await sql`UPDATE world SET randomNumber = ${obj.randomNumber} WHERE id = ${obj.id}`; |
Oops, something went wrong.