How do I connect Webste <-> Server <-> Database❓
Anonymous
TRIALOP

2 years ago

Github code for Main website in public and server.js https://github.com/Lanonymus/todowebsite/tree/main

0 Replies

Anonymous
TRIALOP

2 years ago

413a7dad-c2ce-4187-8822-4c592f0b177c


brody
EMPLOYEE

2 years ago

You are missing a package.json and a package-lock.json


Anonymous
TRIALOP

2 years ago

Alright


Anonymous
TRIALOP

2 years ago

I dowloanded them


Anonymous
TRIALOP

2 years ago

what do I put now in this box

1233863842170278000


Anonymous
TRIALOP

2 years ago

1233864041932394500


brody
EMPLOYEE

2 years ago

your last github commit has you hardcoding the database credentials, please revert that commit.
where are your package.json and package-lock.json files in github?


brody
EMPLOYEE

2 years ago

nothing, it does not need to be filled if you correctly setup your project


Anonymous
TRIALOP

2 years ago

Dont I have to keep them as a secret variables?


brody
EMPLOYEE

2 years ago

yes, so revert that commit


Anonymous
TRIALOP

2 years ago

OH


Anonymous
TRIALOP

2 years ago

I thought I hide them


Anonymous
TRIALOP

2 years ago

and also they are wrong ones lol


Anonymous
TRIALOP

2 years ago

where Do I revert

1233864876297031700


brody
EMPLOYEE

2 years ago

i think you should check out the github docs for that question


Anonymous
TRIALOP

2 years ago

oh well


brody
EMPLOYEE

2 years ago

where are your package.json and package-lock.json files in github?


Anonymous
TRIALOP

2 years ago

Alright


Anonymous
TRIALOP

2 years ago

Changed Credentials and added packages-json


Anonymous
TRIALOP

2 years ago

how does it look now


brody
EMPLOYEE

2 years ago

where is the package-lock.json?


Anonymous
TRIALOP

2 years ago

um


Anonymous
TRIALOP

2 years ago

Well


Anonymous
TRIALOP

2 years ago

I need to add it by using this command right in terminal ? : npm install express


brody
EMPLOYEE

2 years ago

you would need to do that for all the deps your code uses


Anonymous
TRIALOP

2 years ago

I would have to dowloand every dependancy separately?


brody
EMPLOYEE

2 years ago

you can specify multiple deps in a single command


Anonymous
TRIALOP

2 years ago

you mean npm install x y z etc?


Anonymous
TRIALOP

2 years ago

const express = require('express');
const session = require('express-session');


Anonymous
TRIALOP

2 years ago

in this case express and the second one


brody
EMPLOYEE

2 years ago

you use more than just those two packages, but you got the idea


Anonymous
TRIALOP

2 years ago

alright


Anonymous
TRIALOP

2 years ago

Is it supposed to be taking this long?

1233868174341050400


brody
EMPLOYEE

2 years ago

lol i dont know, do you have fast internet


Anonymous
TRIALOP

2 years ago

1233868378469568500


Anonymous
TRIALOP

2 years ago

a decent I'd say


brody
EMPLOYEE

2 years ago

oof 250ms under load


Anonymous
TRIALOP

2 years ago

1233868561961844700


Anonymous
TRIALOP

2 years ago

yeah well …


Anonymous
TRIALOP

2 years ago

It not bad right


Anonymous
TRIALOP

2 years ago

?..


brody
EMPLOYEE

2 years ago

faster than mine


Anonymous
TRIALOP

2 years ago

bro I think it paused

1233868816023294000


Anonymous
TRIALOP

2 years ago

it ain't movin


brody
EMPLOYEE

2 years ago

run it again


Anonymous
TRIALOP

2 years ago

alr lets see


Anonymous
TRIALOP

2 years ago

It may be caused of my grandpa using dowloanding some suspicious viruses online


Anonymous
TRIALOP

2 years ago

but that's another thread


brody
EMPLOYEE

2 years ago

nope thats not another thread lol


Anonymous
TRIALOP

2 years ago

1233869365317992400


Anonymous
TRIALOP

2 years ago

Bro I think my dog is eating the router cables


Anonymous
TRIALOP

2 years ago

or at least having them arleady straved


brody
EMPLOYEE

2 years ago

let me know when you have a package.json and a package-lock.json file in your repo


Anonymous
TRIALOP

2 years ago

aLr


Anonymous
TRIALOP

2 years ago

Okay so I added those packages: https://github.com/Lanonymus/ToDoWebsite


Anonymous
TRIALOP

2 years ago

should be good now


Anonymous
TRIALOP

2 years ago

what do you think


Anonymous
TRIALOP

2 years ago

1237468780318163000


brody
EMPLOYEE

2 years ago

let me take a look


brody
EMPLOYEE

2 years ago

those two files look good, you will now need to make a slight change to line 10 of server.js, for that change, please read this docs page -


Anonymous
TRIALOP

2 years ago

node:internal/modules/cjs/loader:1080

throw err;

^

Error: Cannot find module 'express'

Require stack:

- /app/server.js

at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)

at Module._load (node:internal/modules/cjs/loader:922:27)

at Module.require (node:internal/modules/cjs/loader:1143:19)

at require (node:internal/modules/cjs/helpers:119:18)

at Object. (/app/server.js:2:17)

at Module._compile (node:internal/modules/cjs/loader:1256:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

at Module.load (node:internal/modules/cjs/loader:1119:32)

at Module._load (node:internal/modules/cjs/loader:960:12)

at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12) {

code: 'MODULE_NOT_FOUND',

requireStack: [ '/app/server.js' ]

}

Node.js v18.18.2

Anonymous
TRIALOP

2 years ago

It cannot find module express


Anonymous
TRIALOP

2 years ago

do I have to put node_modules in the github?


Anonymous
TRIALOP

2 years ago

@Brody


brody
EMPLOYEE

2 years ago

no


Anonymous
TRIALOP

2 years ago

why railway cant find module express then


brody
EMPLOYEE

2 years ago

build logs please -


Anonymous
TRIALOP

2 years ago

1237476644029993000


Anonymous
TRIALOP

2 years ago

it doesnt do anything


brody
EMPLOYEE

2 years ago

please follow the instructions


Anonymous
TRIALOP

2 years ago

1237477268499075300


Anonymous
TRIALOP

2 years ago

I did


brody
EMPLOYEE

2 years ago

you didn't


Anonymous
TRIALOP

2 years ago

???


Anonymous
TRIALOP

2 years ago

what am I supposed to do


brody
EMPLOYEE

2 years ago

follow the 3 simple instructions please


brody
EMPLOYEE

2 years ago

let me know when you have the build logs


Anonymous
TRIALOP

2 years ago

what are the

1237478036115558400


Anonymous
TRIALOP

2 years ago

bro I am doing this first time


Anonymous
TRIALOP

2 years ago

Like what even is bookmarklet


Anonymous
TRIALOP

2 years ago

sounds like a book mouse


Anonymous
TRIALOP

2 years ago

from 2013 facebook


Anonymous
TRIALOP

2 years ago

💀


Anonymous
TRIALOP

2 years ago

1237479403882287400


Anonymous
TRIALOP

2 years ago

NaHHH


Anonymous
TRIALOP

2 years ago

tHAT's wild


brody
EMPLOYEE

2 years ago

why would a YouTube search be helpful?


Anonymous
TRIALOP

2 years ago

1237480982815445000


Anonymous
TRIALOP

2 years ago

I dont have the marklet bar


Anonymous
TRIALOP

2 years ago

💀


brody
EMPLOYEE

2 years ago

then enable it


Anonymous
TRIALOP

2 years ago

???


Anonymous
TRIALOP

2 years ago

1237481378627719200


Anonymous
TRIALOP

2 years ago

Okay I did add it and run it


Anonymous
TRIALOP

2 years ago

but it says this


brody
EMPLOYEE

2 years ago

do you have a deployment open?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

okay I did open it


Anonymous
TRIALOP

2 years ago

here are the logs


brody
EMPLOYEE

2 years ago

I asked for the build logs


Anonymous
TRIALOP

2 years ago

they are empty


brody
EMPLOYEE

2 years ago

do another deployment then


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

here they are


brody
EMPLOYEE

2 years ago

why does the deployment say 10 days ago


brody
EMPLOYEE

2 years ago

are you deploying from the wrong GitHub repo


Anonymous
TRIALOP

2 years ago

1237483535082852400


Anonymous
TRIALOP

2 years ago

well


Anonymous
TRIALOP

2 years ago

Oh wait


Anonymous
TRIALOP

2 years ago

I think I know hwy


Anonymous
TRIALOP

2 years ago

why


Anonymous
TRIALOP

2 years ago

am stupid xdd


Anonymous
TRIALOP

2 years ago

I didin't connect github



Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

Now it should be fine


brody
EMPLOYEE

2 years ago

those are the exact same build logs you have previously sent


Anonymous
TRIALOP

2 years ago

no


Anonymous
TRIALOP

2 years ago

It has 6 more lines


Anonymous
TRIALOP

2 years ago

it a bit diffrent


Anonymous
TRIALOP

2 years ago

Now I get success


Anonymous
TRIALOP

2 years ago

1237487859641090000


brody
EMPLOYEE

2 years ago

🥳


Anonymous
TRIALOP

2 years ago

I mean


Anonymous
TRIALOP

2 years ago

kinnda succes


Anonymous
TRIALOP

2 years ago

xdd


Anonymous
TRIALOP

2 years ago

1237488532516372500


brody
EMPLOYEE

2 years ago

^


Anonymous
TRIALOP

2 years ago

app.use(express.static('public'));
app.use(express.json({limit: '1mb'}));
app.listen("0.0.0.0", () => console.log('Server Live at PORT 0.0.0.0'));
// Ustawienie domyślnego silnika szablonów
app.set('view engine', 'ejs');

I am doing something wrong?


brody
EMPLOYEE

2 years ago

yes you did, please read the docs page I linked


Anonymous
TRIALOP

2 years ago

aLright


Anonymous
TRIALOP

2 years ago

I think I fixed it


Anonymous
TRIALOP

2 years ago

// Importuj moduły i ustaw serwer
const express = require('express');
const session = require('express-session');
const app = express();

app.use(express.static('public'));
app.use(express.json({limit: '1mb'}));

const port = process.env.PGPORT || 3000;

// Listen on `port` and 0.0.0.0
app.listen(port, "0.0.0.0", function () {
  => console.log('Server Live at PORT 0.0.0.0'))
});


// Ustawienie domyślnego silnika szablonów
app.set('view engine', 'ejs');


// Użyj sesji
app.use(session({
    secret: 'secret-key',
    resave: false,
    saveUninitialized: false,
    cookie: { maxAge: 1000 * 60 * 60 * 24 } // Sesja będzie ważna przez 1 dzień (zmień według potrzeb)
}));



// Teraz możesz użyć `res.locals.userId` w swoich routach, aby sprawdzić, czy użytkownik jest zalogowany.

// Przykład zabezpieczenia routy przed dostępem niezalogowanego użytkownika


// Przechowuj użytkowników w pamięci dla uproszczenia
const { Pool } = require('pg');
const pool = new Pool({
    user: POSTGRES_USER,
    host: PGHOST,
    database: POSTGRES_DB,
    password: PGPASSWORD,
    port: PGPORT
});

Anonymous
TRIALOP

2 years ago

how does it look now


brody
EMPLOYEE

2 years ago

still wrong, please do not skim read the docs page I linked


Anonymous
TRIALOP

2 years ago

bruuuu


Anonymous
TRIALOP

2 years ago

1237496132494430500


Anonymous
TRIALOP

2 years ago

You meant this , Didin't you?


brody
EMPLOYEE

2 years ago

nope, again do no skim read that docs page


Anonymous
TRIALOP

2 years ago

1237496884248056000


Anonymous
TRIALOP

2 years ago

I dont have a PORT variable defined automaticly


Anonymous
TRIALOP

2 years ago

1237497037327700200


brody
EMPLOYEE

2 years ago

please do not skim read that


Anonymous
TRIALOP

2 years ago

???


brody
EMPLOYEE

2 years ago

automatically injected is the key words here


Anonymous
TRIALOP

2 years ago

oh so you mean


Anonymous
TRIALOP

2 years ago

That I dont have to define it


Anonymous
TRIALOP

2 years ago

and I can just say PORT


Anonymous
TRIALOP

2 years ago

in the code


brody
EMPLOYEE

2 years ago

the docs even tell you not to define it


brody
EMPLOYEE

2 years ago

in the future please read documentation more carefully



Anonymous
TRIALOP

2 years ago

okay I think


Anonymous
TRIALOP

2 years ago

I corrected all those goofy errors


Anonymous
TRIALOP

2 years ago

lets see if it works


Anonymous
TRIALOP

2 years ago

Oh MA gAT


Anonymous
TRIALOP

2 years ago

IT WORKING


Anonymous
TRIALOP

2 years ago

yOOOOOOOOooooooooooooooooooooooooooooOOOOOOOOOOO



Anonymous
TRIALOP

2 years ago

No Freaking way



Anonymous
TRIALOP

2 years ago

@Brody can u test it out ?


Anonymous
TRIALOP

2 years ago

and give it Rate ⭐ ??


brody
EMPLOYEE

2 years ago

1/10


Anonymous
TRIALOP

2 years ago

that's better then 0



Loading...