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

Another (hopefully simple) passport question (passport.authenticate())

I'm following a great passport guide by a guy called zach gollwitzer - would really recommend: https://www.youtube.com/watch?v=F-sFp_AvHc8 He talks about using the ``` passport.authenticate('local', {failureRedirect: '/login-failure', successRedirect: 'login-success'})...

Deserializing a user with passportjs (promise chaining vs async await?)

I'm following a tutorial on passport and am looking at a deserializeUser function: ``` passport.deserializeUser((userId, done) => { User.findById(userId)...

Proxyquire with a nested dependency

So I've got a test file and 2 modules. moduleA has a dependency, moduleB ```// moduleA.js...

How to make SQL Table Column data UNIQUE

I created this Clubs table in my SQL database but I want to make name row unique such that two rows will not have the same name. ``CREATE TABLE clubs ( id integer PRIMARY KEY AUTO_INCREMENT, name` VARCHAR(45) NOT NULL,...

Why does accessing the session object make Express-Session work?

My sessions suddenly stopped being saved, and cookies stopped being set. All routes were working, and Postman was also not receiving cookies (so I ruled out cors). I discovered that accessing the session object immediately after the middleware fixed the issue. So this code was all that was needed: ```app.use((req, res, next) => {...

Testing express-validator?

Just wondering how to test my route validation? I remember being told before that you shouldn't test an external library, but surely I should test my implementation of it? For example: ```...

DevDependency vs Dependency, npm.

Not a big deal at all, just curious, but I come across this all the time: Packages that I feel should be dev dependencies but aren't. The latest is Mocha, but like I said it feels pretty frequent. Does it not really matter that much? I don't really know enough to comment, so maybe I'm just way off base πŸ™‚...

Sharp and Canvas error on Node

I have a project I'm trynna run for the first time, the codebase is an API backend written with express, so I tried running npm install script on it but some errors showed up about sharp and canvas which I really did install the two packages separately but when I tried running the project this error below keeps coming up. ```node:internal/modules/cjs/loader:1203 return process.dlopen(module, path.toNamespacedPath(filename)); ^...

Retrieve and display the sku

I need this H3 to display the sku of our products in Magento 1.9 <h3 class="product-name<?php echo ($_options = $this->getOptionList())? " has-options": ""; ?>"><?php echo $this->escapeHtml($this->getProductName()) ?>&nbsp;<span>SKU: <?php echo $this->escapeHtml($this->getSku());?></span></h3> And so far, it will not display the sku....

Error message for no reason

I am just getting started with backend development with flask and it is showing an error message

more than one row returned

Can anyone explain me why this query results in an error more than 1 row returned by a subquery used as an expression select a.*, (select b.x from b where a.id = b.a_id) from a especially since the problem is resolved once i change it to this select a.*, case when (select true from b where a.id = b.a_id and b.x = true) = true then true else false end...

Catching specific exception

Hi All, I want to catch the specific exception and throw if any other exceptions occur, this is in c#, in general, how do we handle it? any resource link will help too. Thanks

How does `extends` work?

I have a CommandLoader class extended over DynamicLoader. But any property defined on the DynamicLoader class uses it's this. So the load method fails? this is confusing....

.save() is not working. Link is supposed to be added in the website url but dose not appear

I am trying to make a blog page with express, mongoose, node js. I have added the database but when using the .save() function it dosent generate a id needed in the website url

Can strips pre-built checkout only be used surrounded by a form attribute?

I’m having trouble integrating stripe using firebase. My code seems correct but every time I click β€œcheckout” nothing occurs even though I set it to redirect to stripe checkout. Is there a way to use it without having the form attribute around the button?...

Is it a good practice to put functions inside of class objects?

I am currently making a class called MainRESTHandler and it's going to have many functions, so I wanted to categorise the many functions in various objects. For example ```ts export class MainRESTHandler { constructor() {...

How to stop container and delete images in github actions script before docker builds?

I have this script in my github actions ```js - name: Build docker image run: |-...

Symphony Mailer with twig

This is the class I use to send mails, it works except for the template. When I open mailtrap I get the mails but only the TEXT parts not the html templates. Any ideas on why that happens?

How do I display a single entry from an array from MYSQL

This works ... ``` $result = mysqli_query($conn, "SELECT * from $table"); $pix = array(); while ($row = $result->fetch_assoc()) {...

SyntaxError Octal escape sequences are not allowed in strict mode.

I have a path to a file system, but when I use ts-node, it throws an error. How should I rewrite this so that I can get the file to work? Relevant Potion of code: ```ts const DATAPATH = "C:\path\to\repo\advent-of-code\2022\01\data.txt";...