Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnumbers0 committed Apr 16, 2024
1 parent 84b77c0 commit c67f20b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
package-lock.json
queries.sql
.env
.env
.vercel
33 changes: 13 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
import express from "express";
import bodyParser from "body-parser";
import pg from "pg";

import dotenv from 'dotenv';
dotenv.config();

const secret = process.env.SECRET
const postgresPort = process.env.PORT

const db = new pg.Client({
user: "postgres",
host: "localhost",
database: "runproject",
password: secret,
port: postgresPort,
})
import { createClient } from '@supabase/supabase-js'

db.connect();
dotenv.config();

const app = express();
const port = 3000;

app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));

const supabaseUrl = 'https://reamqvucjdwylegwdnai.supabase.co'; //supabase details
const supabaseKey = process.env.SUPABASE_KEY;

const supabase = createClient(supabaseUrl, supabaseKey);

let items = [];

app.get("/", async (req, res) => {

try {
const result = await db.query("SELECT * FROM run ");
items = result.rows;
const { data, error } = await supabase
.from('run')
.select('*');
items = data;

res.render("index.ejs", {
projectTitle: "Run Log",
runList: items,
});
} catch(err) {
console.log(err);
console.error(err);
}

});

app.listen(port, () => {
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"dependencies": {
"body-parser": "^1.20.2",
"dotenv": "^16.4.5",
"ejs": "^3.1.10",
"express": "^4.19.2",
"nodemon": "^3.1.0",
"pg": "^8.11.5"
},
"name": "running-project",
"description": "A website to track runs over time.",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"dependencies": {
"@supabase/supabase-js": "^2.42.4",
"body-parser": "^1.20.2",
"dotenv": "^16.4.5",
"ejs": "^3.1.10",
"express": "^4.19.2",
"nodemon": "^3.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"author": "smallnumbers0",
"license": "ISC"
}
1 change: 1 addition & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ html {
font-weight: bold;
font-size: 1.5rem;
font-family: "Open Sans", sans-serif;
color: rgb(132, 217, 132);
}

#date-text {
Expand Down

0 comments on commit c67f20b

Please sign in to comment.