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

dotenv in production?

Anything wrong with using dotenv in production? i can't see anything to suggest there is, but thought I'd check given it's a security thing. Googling throws up an article outlining issues that don't really apply to me https://dev.to/gregorygaines/stop-using-env-files-now-kp0, but I've also seen an article countering that one 😄

Requests between webservers in Nginx

So I've got 2 servers up and running on my Nginx server. Both are working/routing correctly, and I've made one a subdomain of the other: api.example.com & example.com If I need to communicate between the two do I still just make a request to api.example.com? Is that request going out to the internet and then back to Nginx, or is there a way to tell Nginx just to make the request directly?...

`Cant install mongodb on mac`

I cant install Mongodb on my mac keeps failing with the error below

1st time picking up a database, require recommendations

Hello, I'm starting to learn a bit about the backend database and I been seeing RethinkDB, MongoDB, OrientDB, and many more. With so much to choose from, I want you guys to recommend me one as someone new to all of theses databases as you guys will know more about which one is better or easy to use for someone starting out like me. I would be using this with React.js so if there is one that works well with React I would prefer that. Thanks in advance 🙂...

Puppeteer (nodejs package): need help understanding page.evaluate & elementHandle.evaluate

Hello, Learning nodejs' puppeteer package for webscraping right now. Please, correct me, if I'm wrong: I believe evaluate, takes in a pageFunction, runs it against the calling object. The point of having those functions in those classes is that we can access members of that object in our callback and perform work with it (e.g. . Am I right on all of that ? ...

Classes repetitive

What's the best way to shorten/one class a multiple class/model? I have seen our line of codes repetitive a same class with just different class name but with same arguments inside. ``` ...

Artisan Problem

I'm trying to learn a little about laravel and was attempting their tutorial, but when I set up my project and ran: php artisan serve I get the following error: In PackageManifest.php line 177: The C:\Users\Ted\Documents\Web Development\PHP\laravel\chirper\bootstrap\cache directory must be present and writable. ...

More file structure, this time webpack flavoured!

Thought I'd make another thread as this is kind of a different, but very related, question I've been developing locally using webpack and vanillajs. My server is hosted on digitalocean with ubuntu. As mentioned in my last question I build locally, push to a github repo, and then pull that repo in to my server. I plan to use github actions from next week thanks to @joao6246 advice, but for the time being that's the (maybe less than ideal?) set-up I learnt from frontend masters My Server folder structure:...

File structure on my server

I've ubuntu running on a digital ocean droplet that I was planning on using to clone a github repo of mine that I use locally. In that repo I have my usual dev/build folder structure, so I can build locally, but that'll mean when I pull the repo from my server it'll have all the dev files. Just wondering if this matters, or if there's a better way to do it? Sorry if this seems simple, but this is my first time sorting my own server 🙂...

Scheduled code execution

If you need a piece of code to run at exactly x date at y time, but also another piece of code (like a reminder) some 10 or whatever minutes before that date...how would you accomplish that? Cron jobs? on your API code or a separate Cron service? Any other methods you would use? All ideas welcomed

Error when trying to create an image in Node js

```js function BW(){ let pixels=[]; for(let i=0;i<256;i++){ pixels.push(random(0,255))...

Error with pathing when using netlify

```Request from ::1: POST /.netlify/functions/api/shorten [Error: ENOENT: no such file or directory, open 'urls.json'] { errno: -2, code: 'ENOENT', syscall: 'open',...

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)); ^...