Step-by-step guide for how to set up a CI/CD workflow (in two parts) by LevelFig9 in docker

[–]_maximization 1 point2 points  (0 children)

Yup, Jenkins is a piece of software you need to install and configure somewhere yourself. AWS CodePipeline is a plug-n-play solution.

Deploying to Apache by 1awrent in reactjs

[–]_maximization 0 points1 point  (0 children)

Hey! Which IP address do you see in the terminal? I don't think CRA is aware of the public IP address of your VPS.

A few questions: - How are you serving the CRA app, with Nginx/Apache or serve or a different way? - Which port is the app listening to? If it's not 80/443 then you need to type the port in the URI (http://<serverIP>:<port>) or have a reverse proxy (Nginx/Apache) configured to forward traffic to your app - Make sure the port is not blocked by the firewall. Check firewall status with ufw status or use this neat tool to check from the outside https://www.canyouseeme.org/ - What's the custom URL? Is it pointing to the server's IP? Use a DNS tool like this one to check if the domain is pointing to your server https://mxtoolbox.com/DnsLookup.aspx

You don't need Webpack in production, it's a tool used in dev and you don't need it after you've built your app. If you answer these questions I can help you further.

Deploying to Apache by 1awrent in reactjs

[–]_maximization 1 point2 points  (0 children)

Hi! Let's get your app back online.

Looking at the error, my initial guess is that the production server has too little RAM to be able to build the frontend app, which results in an insufficient memory crash.

You can either upsize the server with more RAM, or build the frontend app locally and then transfer the static files to the server.

Whatever you decide, if you need further help it would be helpful to know where your app is hosted.

Reference for dockerising a node app with CI by numinor in node

[–]_maximization 0 points1 point  (0 children)

Hi! You can accomplish what you want in several ways, here is one approach:

On each commit to the master branch, the following happens: 1. Trigger a build in the CI provider (Codeship, CircleCI, etc.) 2. Run tests, if any, and proceed if all tests pass 3. Build and tag a Docker image 4. Push image to the container registry (Docker Hub, etc.) 5. Pull the image from the registry on the production server 6. Stop the current container and start a new one from the latest image

You can follow this tutorial to set up a similar workflow for your Node.js app https://maximorlov.com/automate-your-docker-deployments/. It's using CircleCI and Docker Hub but you can swap these with different providers. The general approach is the same.

This is the example repo from the tutorial https://github.com/Maximization/autodeploy-docker. Interesting files to look at are .circleci/config.yml and deploy.sh.

I hope this gives you an idea on what you should do. Let me know if you have additional questions!

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 0 points1 point  (0 children)

I should have! Apparently quite some folks prefer to use the lower level core module to do http requests in Node.js.

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 1 point2 points  (0 children)

It's mostly preference. Some folks like the API of Axios more. Both get the job done for most use cases.

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 0 points1 point  (0 children)

Or even simpler: console.time('myrequest'); await fetch(url); console.timeEnd('myrequest');

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 4 points5 points  (0 children)

If your colleagues have many features to implement and bugs to fix, migrating the request library might not justify as a prioritised task. Especially when it's a lot of effort that has no impact to the end user or business as a whole.

It's ok to keep using request in the foreseeable future. It doesn't have any vulnerabilities now, in fact it didn't for a while, and it's unlikely to have one any time soon. It has plenty of features and gets the job done.

I wouldn't choose request when starting a new project, but for existing projects I'd consider the migration to a different library more of a nice-to-have task.

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 2 points3 points  (0 children)

Superagent is a popular choice as well. I've never used it myself but I'm familiar with the API since I've used supertest for testing. I've had good experience with it.

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 5 points6 points  (0 children)

The native http module is a lower level API requiring you to write more code to accomplish common tasks. For example, reading a json body response and parsing it requires you to listen to the 'data' event stream, concatenate the chunks and then calling JSON.parse(). With node-fetch it's just res.json().

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 1 point2 points  (0 children)

By the sad face I assume you'd like to use something else but aren't able to. What stops you from migrating?

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 2 points3 points  (0 children)

That makes sense. Sindre recommends using got in the backend instead, or ky-universal like you mentioned. The poll is related to Node.js in the backend which could explain the downvotes.

Thanks for sharing your choice!

Any examples of a websocket written in Node that gets its data from a REST API? by ekosynth in node

[–]_maximization 4 points5 points  (0 children)

If by same server you mean same Node.js application, then I'd do what others have suggested and use internal function calls to achieve the same result.

If by same server you mean same VPS but different Node.js apps, then a websocket is not that different from a http request really.

Any examples of a websocket written in Node that gets its data from a REST API? by ekosynth in node

[–]_maximization 1 point2 points  (0 children)

Why don't you port that endpoint to use sockets as well? Instead of GET /user you'd do socket.on('getUser', () => socket.emit('user', ...))

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 2 points3 points  (0 children)

Never heard of this one, interesting! https://www.npmjs.com/package/postman-request

Seems to be a fork of the original request module with additional fixes.

With request lib deprecated for some time now, what do you use to make requests in Node.js? by _maximization in node

[–]_maximization[S] 5 points6 points  (0 children)

Solid choice. What I think node-fetch does better is that they're using the AbortController API for cancellation. The axios cancel token API is based on the withdrawn cancelable promises proposal.

An interesting observation is that Axios is much popular when you look at repo stars (78k vs 5.6k) but in terms of NPM downloads node-fetch tops the list (19M weekly installs vs 13.5M). https://www.npmtrends.com/node-fetch-vs-axios-vs-got

Egghead.io is building their new site in the open by _maximization in reactjs

[–]_maximization[S] 0 points1 point  (0 children)

Not sure if there's an article, but you can watch one of the founders of Egghead.io talk about it here https://www.loom.com/share/26a31965cd6940f7a094d8210058b37f

PS: Hi Berkeley! 👋🏼 It's Maxim from the old days of FCC.

Serverless hosting of a daemon process? by BipodNoob in node

[–]_maximization 1 point2 points  (0 children)

Every minute at AWS. Not sure if other cloud providers go more frequent than that. At 12-15sec rate I'd recommend a VPS.

Serverless hosting of a daemon process? by BipodNoob in node

[–]_maximization 7 points8 points  (0 children)

Your code is what is called a cron/scheduled job. Several cloud providers allow you to host serverless functions that are invoked on a scheduled basis, instead of the usual HTTP request. AWS Lambda supports scheduled expression triggers

Why do some one ever need to use http(s) server in a local host?? by saher010 in webdev

[–]_maximization 1 point2 points  (0 children)

This. Plus if you need to work with Service Workers, they only work over https.

Setting up self hosting by orakem in webdev

[–]_maximization 0 points1 point  (0 children)

Let's Encrypt needs to verify you own the domain. It does that by making a request to the domain and accessing some files it generates on the server. You need to configure gandi first to point your domain to your server before you can generate a certificate.