a year ago
Github code for Main website in public and server.js https://github.com/Lanonymus/todowebsite/tree/main
0 Replies
a year ago
You are missing a package.json and a package-lock.json
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
a year ago
yes, so revert that commit
a year ago
i think you should check out the github docs for that question
a year ago
where are your package.json and package-lock.json files in github?
a year ago
where is the package-lock.json?
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
a year ago
you can specify multiple deps in a single command
const express = require('express');
const session = require('express-session');
a year ago
you use more than just those two packages, but you got the idea
a year ago
lol i dont know, do you have fast internet
a year ago
oof 250ms under load
a year ago
faster than mine
a year ago
run it again
It may be caused of my grandpa using dowloanding some suspicious viruses online
a year ago
nope thats not another thread lol
a year ago
let me know when you have a package.json and a package-lock.json file in your repo
Okay so I added those packages: https://github.com/Lanonymus/ToDoWebsite
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 -
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
a year ago
no
a year ago
build logs please -
a year ago
please follow the instructions
a year ago
you didn't
a year ago
follow the 3 simple instructions please
a year ago
let me know when you have the build logs
a year ago
why would a YouTube search be helpful?
a year ago
then enable it
a year ago
do you have a deployment open?
a year ago
I asked for the build logs
a year ago
do another deployment then
a year ago
why does the deployment say 10 days ago
a year ago
are you deploying from the wrong GitHub repo
a year ago
those are the exact same build logs you have previously sent
a year ago
🥳
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
// 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
});
a year ago
still wrong, please do not skim read the docs page I linked
a year ago
nope, again do no skim read that docs page
a year ago
please do not skim read that
a year ago
automatically injected is the key words here
a year ago
the docs even tell you not to define it
a year ago
in the future please read documentation more carefully
a year ago
1/10