Faker
Faker
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
How to load content in a single page web app
Oh okay I see... consider a website where we can upload... we don t know.in advance how many images there are, definitely here we should inject the html right ?
3 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
ty !!
12 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
yep, by the way, max-width was the correct property to use here? to restrict the background color from taking whole width of viewport ?
12 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
yep this is what I did, but didn't understand, why the padding of ul was causing some issues here?
12 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
it works now, thanks !!!
12 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
ah lmao, true
12 replies
KPCKevin Powell - Community
Created by Faker on 11/20/2024 in #front-end
width of anchor tag of a vertical navigation bar not being set properly
also, I tried to add a hover effect, it seems like the anchor tag isn't taking the full width, why please
12 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
yep I see, what is the last point, for the automatic clask, didn't know it exist
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
I use the first method where we have invalid request... seems easier for now
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
by the way, I was able to do the session management session !!
import express from 'express';
import session from 'express-session';
import path from 'path';
import { fileURLToPath } from 'url';

const app = express();
const port = 8080;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let viewCount = 0;


// Use the session middleware
const sessionOptions = {
secret: 'super secret secret',
cookie: {maxAge: 8000} // 5sec
// resave: false, // don't save session for each request if unmodified
// saveUninitialized: false // don't create session until something is stored - interacting with session
}
app.use(session(sessionOptions));

// Access the session as req.session
app.get('/', (req,res) => {
console.log(req.session);
if (req.session.viewCount) {
req.session.viewCount++;
viewCount++;
}
else {
req.session.viewCount = 1;
viewCount = 1;
}
console.log(`${req.session.id}`);
res.sendFile(path.join(__dirname, '../public/HTML/index.html'));
});

app.get('/data', (req,res) => {
if (!req.session.viewCount) {
return res.status(440).json({
"errorMsg": "Server timed out"
});
}
res.json({
"name":"John Doe",
"age": 40
})
})


app.listen(port, () => {
console.log(`Server started on port: ${port}`);
})
import express from 'express';
import session from 'express-session';
import path from 'path';
import { fileURLToPath } from 'url';

const app = express();
const port = 8080;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let viewCount = 0;


// Use the session middleware
const sessionOptions = {
secret: 'super secret secret',
cookie: {maxAge: 8000} // 5sec
// resave: false, // don't save session for each request if unmodified
// saveUninitialized: false // don't create session until something is stored - interacting with session
}
app.use(session(sessionOptions));

// Access the session as req.session
app.get('/', (req,res) => {
console.log(req.session);
if (req.session.viewCount) {
req.session.viewCount++;
viewCount++;
}
else {
req.session.viewCount = 1;
viewCount = 1;
}
console.log(`${req.session.id}`);
res.sendFile(path.join(__dirname, '../public/HTML/index.html'));
});

app.get('/data', (req,res) => {
if (!req.session.viewCount) {
return res.status(440).json({
"errorMsg": "Server timed out"
});
}
res.json({
"name":"John Doe",
"age": 40
})
})


app.listen(port, () => {
console.log(`Server started on port: ${port}`);
})
I don't know if it is efficient but it worked and I understand how things work :c
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
yep I see, so I can just ignore the "keep-alive" thing ?
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
There is something known as "keep-alive" , I think it is some kind of attribute in headers, do that have anything to play with what you mentioned please
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
Yep I see, I will try it out and revert back, thanks !
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
I set the maxAge of cookie to 5000ms, it's for testing
22 replies
KPCKevin Powell - Community
Created by Faker on 11/19/2024 in #back-end
How to keep track when session expires in express session
The session expires after 5sec but I want to be redirected to kind of a "time-out" page because the user don't know that the session has expired
22 replies
KPCKevin Powell - Community
Created by Faker on 11/17/2024 in #back-end
Content-type multipart/form-data vs application/json when submitting a form
yep I see, thanks !!
61 replies
KPCKevin Powell - Community
Created by Faker on 11/17/2024 in #back-end
Content-type multipart/form-data vs application/json when submitting a form
but the thing is, I set up a small server for form submission... intially, I was getting an error because the server expect application/json while it was receiving multipart/form-data. Then, I needed to use a library called "multer" I forgot what it did but then it works
61 replies
KPCKevin Powell - Community
Created by Faker on 11/17/2024 in #back-end
Content-type multipart/form-data vs application/json when submitting a form
yep it can't
61 replies
KPCKevin Powell - Community
Created by Faker on 11/17/2024 in #back-end
Content-type multipart/form-data vs application/json when submitting a form
because it isn't something what it understands
61 replies
KPCKevin Powell - Community
Created by Faker on 11/17/2024 in #back-end
Content-type multipart/form-data vs application/json when submitting a form
hmm nothing, returns an error
61 replies