Skip to content

Instantly share code, notes, and snippets.

@iworkforthem
Created December 1, 2020 07:53
Show Gist options
  • Save iworkforthem/199efeb51454c763b307817dea7cc9cf to your computer and use it in GitHub Desktop.
Save iworkforthem/199efeb51454c763b307817dea7cc9cf to your computer and use it in GitHub Desktop.
expressjs connect to Materialize
const express = require("express");
const app = express();
const port = 3000;
const { Client } = require("pg");
const client = new Client({
host: "127.0.0.1",
port: 6875,
database: "materialize",
});
client.connect();
client.query("SHOW DATABASES", (err, res) => {
if (err) {
console.log(err.stack);
} else {
console.log(res.rows);
}
});
app.get("/", (req, res) => {
res.send("Hello World!");
});
app.listen(port, () => {
console.log(`express-materialize app listening at http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment