Update JavaScript examples to latest Railway (#14)

* update serverless pg example
* update nextjs example
* update prisma example
This commit is contained in:
Jake Runzer
2020-10-07 13:17:31 -06:00
committed by GitHub
parent 095a3e6de7
commit 07b4eb1e20
8 changed files with 56 additions and 2700 deletions

View File

@@ -13,7 +13,7 @@
},
"dependencies": {
"global": "^4.4.0",
"railway": "^2.0.5",
"pg": "^8.4.0",
"tslib": "^2.0.0"
}
}

View File

@@ -1,6 +1,7 @@
const pg = require("railway/pg");
const pg = require("pg");
const client = new pg.Pool();
pg.query("SELECT now()", (err, res) => {
client.query("SELECT now()", (err, res) => {
if (err) {
console.log(err);
}
@@ -8,4 +9,4 @@ pg.query("SELECT now()", (err, res) => {
console.log(res.rows);
});
pg.close();
client.close();

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@
},
"dependencies": {
"next": "9.5.0",
"railway": "^2.0.5",
"pg": "^8.4.0",
"react": "16.13.1",
"react-dom": "16.13.1"
}

View File

@@ -3,12 +3,13 @@
// Call Railway anywhere on serverside code.
// Here or getInitialProps
import pg from "railway/pg";
import { promisify } from "util";
import pg from "pg";
export default async (req, res) => {
try {
const query = await promisify(pg.query)("Select NOW()");
const client = pg.Pool();
const query = await promisify(client.query)("Select NOW()");
res.json({
data: {
time: query.rows[0].now,

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,6 @@
},
"devDependencies": {
"@prisma/cli": "^2.1.3",
"railway": "^2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.7",
"yarpm": "^0.2.1"

File diff suppressed because it is too large Load Diff