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

AnonymousTRIAL

a year ago

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

0 Replies

AnonymousTRIAL

a year ago

413a7dad-c2ce-4187-8822-4c592f0b177c


a year ago

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


AnonymousTRIAL

a year ago

Alright


AnonymousTRIAL

a year ago

I dowloanded them


AnonymousTRIAL

a year ago

what do I put now in this box

1233863842170278000


AnonymousTRIAL

a year ago

1233864041932394500


a year 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?


a year ago

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


AnonymousTRIAL

a year ago

Dont I have to keep them as a secret variables?


a year ago

yes, so revert that commit


AnonymousTRIAL

a year ago

OH


AnonymousTRIAL

a year ago

I thought I hide them


AnonymousTRIAL

a year ago

and also they are wrong ones lol


AnonymousTRIAL

a year ago

where Do I revert

1233864876297031700


a year ago

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


AnonymousTRIAL

a year ago

oh well


a year ago

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


AnonymousTRIAL

a year ago

Alright


AnonymousTRIAL

a year ago

Changed Credentials and added packages-json


AnonymousTRIAL

a year ago

how does it look now


a year ago

where is the package-lock.json?


AnonymousTRIAL

a year ago

um


AnonymousTRIAL

a year ago

Well


AnonymousTRIAL

a year ago

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


a year ago

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


AnonymousTRIAL

a year ago

I would have to dowloand every dependancy separately?


a year ago

you can specify multiple deps in a single command


AnonymousTRIAL

a year ago

you mean npm install x y z etc?


AnonymousTRIAL

a year ago

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


AnonymousTRIAL

a year ago

in this case express and the second one


a year ago

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


AnonymousTRIAL

a year ago

alright


AnonymousTRIAL

a year ago

Is it supposed to be taking this long?

1233868174341050400


a year ago

lol i dont know, do you have fast internet


AnonymousTRIAL

a year ago

1233868378469568500


AnonymousTRIAL

a year ago

a decent I'd say


a year ago

oof 250ms under load


AnonymousTRIAL

a year ago

1233868561961844700


AnonymousTRIAL

a year ago

yeah well …


AnonymousTRIAL

a year ago

It not bad right


AnonymousTRIAL

a year ago

?..


a year ago

faster than mine


AnonymousTRIAL

a year ago

bro I think it paused

1233868816023294000


AnonymousTRIAL

a year ago

it ain't movin


a year ago

run it again


AnonymousTRIAL

a year ago

alr lets see


AnonymousTRIAL

a year ago

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


AnonymousTRIAL

a year ago

but that's another thread


a year ago

nope thats not another thread lol


AnonymousTRIAL

a year ago

1233869365317992400


AnonymousTRIAL

a year ago

Bro I think my dog is eating the router cables


AnonymousTRIAL

a year ago

or at least having them arleady straved


a year ago

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


AnonymousTRIAL

a year ago

aLr


AnonymousTRIAL

a year ago

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


AnonymousTRIAL

a year ago

should be good now


AnonymousTRIAL

a year ago

what do you think


AnonymousTRIAL

a year ago

1237468780318163000


a year ago

let me take a look


a year 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 -


AnonymousTRIAL

a year 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

AnonymousTRIAL

a year ago

It cannot find module express


AnonymousTRIAL

a year ago

do I have to put node_modules in the github?


AnonymousTRIAL

a year ago

@Brody


a year ago

no


AnonymousTRIAL

a year ago

why railway cant find module express then


a year ago

build logs please -


AnonymousTRIAL

a year ago

1237476644029993000


AnonymousTRIAL

a year ago

it doesnt do anything


a year ago

please follow the instructions


AnonymousTRIAL

a year ago

1237477268499075300


AnonymousTRIAL

a year ago

I did


a year ago

you didn't


AnonymousTRIAL

a year ago

???


AnonymousTRIAL

a year ago

what am I supposed to do


a year ago

follow the 3 simple instructions please


a year ago

let me know when you have the build logs


AnonymousTRIAL

a year ago

what are the

1237478036115558400


AnonymousTRIAL

a year ago

bro I am doing this first time


AnonymousTRIAL

a year ago

Like what even is bookmarklet


AnonymousTRIAL

a year ago

sounds like a book mouse


AnonymousTRIAL

a year ago

from 2013 facebook


AnonymousTRIAL

a year ago

💀


AnonymousTRIAL

a year ago

1237479403882287400


AnonymousTRIAL

a year ago

NaHHH


AnonymousTRIAL

a year ago

tHAT's wild


a year ago

why would a YouTube search be helpful?


AnonymousTRIAL

a year ago

1237480982815445000


AnonymousTRIAL

a year ago

I dont have the marklet bar


AnonymousTRIAL

a year ago

💀


a year ago

then enable it


AnonymousTRIAL

a year ago

???


AnonymousTRIAL

a year ago

1237481378627719200


AnonymousTRIAL

a year ago

Okay I did add it and run it


AnonymousTRIAL

a year ago

but it says this


a year ago

do you have a deployment open?


AnonymousTRIAL

a year ago


AnonymousTRIAL

a year ago

okay I did open it


AnonymousTRIAL

a year ago

here are the logs


a year ago

I asked for the build logs


AnonymousTRIAL

a year ago

they are empty


a year ago

do another deployment then


AnonymousTRIAL

a year ago


AnonymousTRIAL

a year ago

here they are


a year ago

why does the deployment say 10 days ago


a year ago

are you deploying from the wrong GitHub repo


AnonymousTRIAL

a year ago

1237483535082852400


AnonymousTRIAL

a year ago

well


AnonymousTRIAL

a year ago

Oh wait


AnonymousTRIAL

a year ago

I think I know hwy


AnonymousTRIAL

a year ago

why


AnonymousTRIAL

a year ago

am stupid xdd


AnonymousTRIAL

a year ago

I didin't connect github



AnonymousTRIAL

a year ago


AnonymousTRIAL

a year ago

Now it should be fine


a year ago

those are the exact same build logs you have previously sent


AnonymousTRIAL

a year ago

no


AnonymousTRIAL

a year ago

It has 6 more lines


AnonymousTRIAL

a year ago

it a bit diffrent


AnonymousTRIAL

a year ago

Now I get success


AnonymousTRIAL

a year ago

1237487859641090000


a year ago

🥳


AnonymousTRIAL

a year ago

I mean


AnonymousTRIAL

a year ago

kinnda succes


AnonymousTRIAL

a year ago

xdd


AnonymousTRIAL

a year ago

1237488532516372500


a year ago

^


AnonymousTRIAL

a year 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?


a year ago

yes you did, please read the docs page I linked


AnonymousTRIAL

a year ago

aLright


AnonymousTRIAL

a year ago

I think I fixed it


AnonymousTRIAL

a year 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
});

AnonymousTRIAL

a year ago

how does it look now


a year ago

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


AnonymousTRIAL

a year ago

bruuuu


AnonymousTRIAL

a year ago

1237496132494430500


AnonymousTRIAL

a year ago

You meant this , Didin't you?


a year ago

nope, again do no skim read that docs page


AnonymousTRIAL

a year ago

1237496884248056000


AnonymousTRIAL

a year ago

I dont have a PORT variable defined automaticly


AnonymousTRIAL

a year ago

1237497037327700200


a year ago

please do not skim read that


AnonymousTRIAL

a year ago

???


a year ago

automatically injected is the key words here


AnonymousTRIAL

a year ago

oh so you mean


AnonymousTRIAL

a year ago

That I dont have to define it


AnonymousTRIAL

a year ago

and I can just say PORT


AnonymousTRIAL

a year ago

in the code


a year ago

the docs even tell you not to define it


a year ago

in the future please read documentation more carefully



AnonymousTRIAL

a year ago

okay I think


AnonymousTRIAL

a year ago

I corrected all those goofy errors


AnonymousTRIAL

a year ago

lets see if it works


AnonymousTRIAL

a year ago

Oh MA gAT


AnonymousTRIAL

a year ago

IT WORKING


AnonymousTRIAL

a year ago

yOOOOOOOOooooooooooooooooooooooooooooOOOOOOOOOOO



AnonymousTRIAL

a year ago

No Freaking way



AnonymousTRIAL

a year ago

@Brody can u test it out ?


AnonymousTRIAL

a year ago

and give it Rate ⭐ ??


a year ago

1/10


AnonymousTRIAL

a year ago

that's better then 0



How do I connect Webste &lt;-&gt; Server &lt;-&gt; Database❓ - Railway Help Station