Kevin Powell - Community

KPC

Kevin Powell - Community

A friendly place for developers to meet other devs, ask questions, get help, and just have a good time πŸ™‚.

Join

front-end

resources

back-end

ui-ux

os-and-tools

How to keep track when session expires in express session

Hello guys, sorry to disturb you all; can someone explain how can I do in order to keep track when a session expires , for e,g after 5sec without refreshing the web-page ```JS // Access the session as req.session app.get('/', (req,res) => {...

Creating multiple landing pages with subdomains

I have to create landing pages on multiple subdomains e.g. shop.thedomain.com and academy.thedomain.com The pages are already built on thedomain.com Wordpress install. Is there a way to assign these subdomain URLs to these pages without creating brand new Wordpress installs in the subdomain directory and without using redirect; eg instead of redirecting the subdomain shop.thedomain.com to thedomain.com/shop the url bar should show the address as shop.thedomain.com and load the page content that exists at thedomain.com/shop Same with academy.thedomain.com . There has to be a way to do this without duplicating the Wordpress install files and database for one landing page labeled and accessible from the subdomain address...

sending data with uri (but doesn't affect the page its trying to reach)

Okay so, see image Every group would be using a uid, which should be accesable when copying the link, so that you can send it to someone and they can go to the correct page but, how do I do this? I'm new to php and I've tried looking online but I can't find the right answer. Doing it like this just gave me the 404 cant find page as its probably looking for group.php?gid=id1instead of just group.php ...
No description

Content-type multipart/form-data vs application/json when submitting a form

Hello guys, sorry to disturb you all; consider the following code: ```JS document.querySelector('#login').addEventListener('submit', (event) => { event.preventDefault(); // Prevent default form submission...

How to handle middleware, routes and routers in express

Hello guys, sorry to disturb you all; I have some doubts concerning the following terminologies and how they are used in express js: middleware , routes and routers. From what I have understood, middleware is just the middleman sitting in between a request and a respond which has the abilities to modify our request and respond object. Routes are simply the endpoint of our urls, like http/localhost:3030/abc/endpoint. Routers are the things that modularize our script by handling specific routes; like routers create dedicated "rooms" to handle specific routes. I'm What I'm confused about is the use of app.use() and when creating a new instance of : router = express.Router(), what does the express.Router() does? Because in our main script, this will be used as argument in the app.use, like app.use(router). What is happening here? How is app.use behaving as a middleware.... I understand the terminologies but I'm having some difficulties to visualise how they work in real time....

What happens when we submit a form in HTML if action attribute is empty or contains a url

Hello guys, sorry to disturb you all; I have built a small server using node and express js. Now I have built a small login form. What I want to do is send the form to the server; their I will need to perform some validation etc. But how do I send the form to the server ? Also, say my form web page is on localhost:3030 and my server on localhost:8080, how do I do communicate please

Express server not loading my stylesheet

Hello guys, sorry to disturb you all; I try to build a small server using express; my html file is being delivered but the stylesheet related to it isn't... I don't understand why, I'm having the following error in the browser: Refused to apply style from 'http://localhost:8080/styles/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. Here is my code:...
No description

API vs SSR (Server Side rendering)

Hello guys, sorry to disturb you all; I just came across the term SSR. I had a look at what it means and from what I've understood, the term SSR means that everything is "pre-made" in the backend. For example, a server serves an a web page where the HTML is already rendered along with the CSS and JS(Like SSR serves a template). Behind the scenes, SSR does use APIs to fetch data but the idea is every initial loading is done by the server (every time a web page is reloaded we should still g...

Serving static files in express

Hello everyone, sorry to disturb you. I have a question regarding app.get(express.static()). Let's say we have a folder named public, and the path to this folder is passed as an argument. We noticed that if we have a stylesheet in this folder, the link to it in the HTML file doesn't need to be changed. When the server is running, the CSS is still parsed correctly. However, if we try to open the HTML file directly using the local server VS Code extension, it doesn't work. Could anyone explain why this happens please....

What is the purpose of a middleware in express

Hello guys, from what I have read, in Express.js, middleware is a function that intercepts incoming requests and gives access to the request and response objects. What is it purpose/importance? How does it relate to route handlers please...

Password Generator

Hi guys, I created this mini project to learn a little more PHP, since I only worked with Laravel a little, I felt that there was a lack of more syntax and more programming logic so I decided to create a mini project to learn exactly that, I would like you to analyze the project and if you could tell me what's best, especially in terms of code cleanliness, good practices and security, please read the README file to understand, Thank you! https://github.com/andresantos2460/generator-with-php-vanilla...
No description

Creating an IPFS UnixFS File System By Hand

I am contemplating a collaborative file system based on IPFS. Users will publish the root of a directory tree & a service worker will copy that tree into a Neo4j instance running in Docker with a model of a versioned repository in it. The frontend, then, will talk to Neo4j (which is a graph database) to allow more complex views of the data than a simple tree view. I'm particularly interested in incorporating ordered lists where users rank content. Say I could get 50 people's opinions of the top 20 funniest memes ever, & generate a composite list from those....

Demystifying event loop and blocking code in nodejs

Hello guys, sorry to disturb you all; I'm currently learning nodejs and I came across the terms "event loop" and "blocking code". Can someone just confirm whether my understanding is correct or if there are things that can be added: From what I have understand, the event loop monitors whatever process happen in our node environment such as reading from a file or writing to a file. The event loop offload works on a specific process if that process is caught "waiting" so that other tasks can be perform by the time the other task finish waiting....

How to prepend a specific word in my server url in node

Hello guys, sorry to disturb you all; I have created a simple server using node js. The url of my server is always something like that: localhost:xxxx/index.html I have some questions first:...

How does HTTP headers/HTTP request and respond work

Hello guys, sorry to disturb you all; I'm trying to build a small server using nodejs but first I need to understand how http and http headers work; can someone explain please. All I understand that our headers contain a request header and response header but it's unclear

Trying to build a web server using nodejs

Hello guys, sorry to disturb you all; I'm currently learning how to build a web server locally using nodejs. However, I have some doubts; I don't understand that part on the filePath, what are we trying to do here? Why are we both about only html files? What's happening here please ```JS const extension = path.extname(req.url); let contentType; ...

help... cookie not sent on https

I'm trying to implement the auth using passport js and it's working over localhost but when I turn on samesite=none and secure=true in my cookie settings over my production build the cookies are not beint sent (not even the set-cookie header) but it's beint sent if i only have the samesite none and not the secure true but chrome requires secure.. I have been frustrated over this for few days and I cannot find the cause any help is much appreciated https://github.com/yogeshdnumb/express-template https://github.com/yogeshdnumb/shadcn-template...

REST API and RESTful API are the same thing?

if not, what’s the difference? Are they both idempotent? both send stateless requests? or those are not the differences?

Learning back-end development with: MongoDB, Express, Node, postman and AJAX

Hello guys, sorry to disturb you all; I need to learn back-end development with the following technlogies: MongoDB, Express, Node, postman, learn about APIs and AJAX; can someone recommend me any resource please
Next