IBM Cloud with Cloud Foundry: node-gzip does not compress a buffer - node.js

I'm trying to compress a buffer, and it works fine on my local machine, but when I upload the service to Cloud Foundry on IBM Cloud, it doesn't work (no errors in logs). Sample code is here:
const {gzip} = require('node-gzip')
gzip(buf)
.then((compressed) => {
logger.debug('buffer has been compressed')
})
Here is package.json:
"dependencies": {
"bluemix-autoscaling-agent": "1.0.14",
"cfenv": "1.1.0",
"cors": "2.8.5",
"express": "4.16.4",
"lodash": "4.17.11",
"node-gzip": "1.1.2",
"object-path": "0.11.4",
"path": "0.12.7"
}
Cloud Foundry service LOG_LEVEL=debug so I can see logs output for other part of my code.
Do you know any other alternative to node-gzip to compress/decompress a buffer? ZLIB is too old - last updated 7 years ago. We don't want to use it as a matter of code integrity and security.

Related

How can upload images on filerobot with strapi V4?

I would like to download the images downloaded on strapi on fileRobot (Scaleflex). To do this, I completed the installation process (https://market.strapi.io/providers/provider-upload-filerobot#install-now-section).
However, nothing has changed and all my images are still saved on the /upload/ directory and i never see the filerobot API request on the network tab of my browser.
This is my dependencies versions :
"dependencies": {
"#strapi/plugin-i18n": "4.5.6",
"#strapi/plugin-users-permissions": "4.5.6",
"#strapi/strapi": "4.5.6",
"jks-js": "^1.1.0",
"mysql": "^2.18.1",
"provider-upload-filerobot": "^1.0.8"
}
I suppose that my plugins.js file is not used when i start strapi.
Is there an incompatibility ? Can you help me ?
Thanks

Files don't compress when run nodejs app in IBM cloud foundry

So I have simple express app. When it run locally, I can see js, css files got gzip compressed but when I deploy to cloud foundry, those files not compressed. The files size still the same.
Anyone know the reason, how to fix it or solutions for this issue ?
const express = require('express');
const compression = require('compression');
const app = express();
app.use(compression());
app.use(express.static('./public'));
Package.json
{
"name": "conversation-simple",
"description": "A simple Node.js based web app which shows how to use the Conversation API to recognize user intents.",
"version": "0.1.1",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"#google/chatbase": "^1.1.2",
"body-parser": "^1.18.2",
"botbuilder": "^3.15.0",
"cloudant": "^1.10.0-NOTICE",
"compression": "^1.7.3",
"cors": "^2.8.4",
"dotenv": "^2.0.0",
"express": "^4.16.1",
"gulp-rename": "^1.4.0",
"moment": "^2.22.2",
"nano": "^6.4.4",
"request": "^2.87.0",
"slick-carousel": "^1.8.1",
"underscore": "^1.9.0",
"universal-analytics": "^0.4.16",
"watson-developer-cloud": "^3.5.3",
"xml-js": "^1.6.3"
},
"engines": {
"node": "8.15.x"
}
}
Update:
Look like there is location problem. When it's deployed to Sydney, the compression doesn't work but Dallas is ok. IBM support have confirmed the issue in my ticket and currently investigate.
I have the same issue, I feel like I've tried absolutely everything so far:
Static Gzipping (serving .gz files)
Brotli (no dice)
Dynamic compression (like you)
Redirect to static .gz files
It works locally as it should but once deployed - farting noise nothing.
I have a feeling it happens in the proxy and needs to be enabled somewhere, where is not documented though
Commenting here to follow this, also I've contacted their support, if I get any answers I will put them here :)
This issue was fixed by IBM.
"After investigation, we found an issue that strips the header and decompresses the response in the Cloud Foundry Platform AU-SYD region."

Hosting my node.js project on Live server

I am new to node.js, I have created a project using create-react-app with react, react-redux and react-router.
Now, I want to upload my project to a live server so, I was wondering if I am required to upload the node_modules folder to the server or is it all incorporated in the build folder somehow?
I have searched for answers but only got results related to "Pros and cons of including node modules in your git repository"
No you don't need to upload node_modules into the server.
If you are using a web service like HEROKU to deploy or AWS I recommend you use it so.
so the bottom line is that you don't need to upload the node_modules file. just commit the repo to a git hub and you can link it to your Heroku account so that the site will be live.
so what happens here is that when you not include the node_module file, you have seen that package.json file right ?
You can see all the dependencies that you have used to work on your project like this
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.4",
"generate-password": "^1.4.1",
"js-base64": "^2.4.9",
"jsonwebtoken": "^8.4.0",
"mongojs": "^2.6.0",
"mongoose": "^5.3.12",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0"
}
so that means using that package.json file the server will add and install all the dependencies that need to run the application. And of course this will run on a node environment only. So you will need to select it in the web service you are using. In Heroku you can deploy your app to a node environment. You it's easy you just need to go there and read their documentation on how to do it.you can try digital ocen too they also provide such facilities
heroku here amazon node app deploy here digital ocean docs
here

Using a specific Node.js version in Gandi Simple Hosting

basically, I am Using Gandi Simple Hosting for a Node.js application. I would like to use a specific Node.js version. I'm ready that all I had to do was making a ".nvmrc" file and putting the required version number in it.
Now my .nvmrc file looks like this.
6.11.0
And my package.json file is like this.
{
"name": "name-of-my-app",
"version": "0.3.0",
"dependencies": {
"express": "3.x",
"socket.io": "1.x",
"mysql": "2.x",
"ejs": "2.x",
"emailjs": "1.x",
"svg-captcha": "1.x",
"sitemap": "1.x",
"discord.js": "11.x"
},
"scripts": {
"start": "node server.js"
}
}
When I restart my server, the console says the following.
/srv/data/web/vhosts/default /srv/data/web/vhosts/default
N/A: version "N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
Despite looking at the Gandi documentation, I can't find out what is wrong.
Thanks you in advance for your help! :-)
Noël.
I got an answer from the Gandi Technical Assistance.
I was told to deploy my code using Git. I made it work by following these inscructions: https://wiki.gandi.net/en/simple/git.

live reload not working for live-server# 0.9.2

For my web application I am using "live-server": "^0.9.2", here's the package json file,
{
"name": "demoapp",
"version": "1.0.0",
"description": "This project contains the samples of the book",
"scripts": {
"live": "live-server",
"start": "npm run live"
},
"dependencies": {
"angular": "^1.5.0",
"angular-messages": "^1.5.0",
"angular-route": "^1.5.0",
"bootstrap": "^3.3.6",
"jquery": "^2.2.0"
},
"devDependencies": {
"live-server": "^0.9.2"
}
}
When I am executing command "npm start", live server starts and web page starts # http://127.0.0.1:8080/
Now, whenever I am changing content for html/css, change detection is not happening and browser content is also not refreshed.
What could be the reason for it? how to resolve it. Thanks!!!
According to the github readme doc, the extension works best if it can find html files which are served by default on the web browser. It may detect changes in the local files that you edit, but rendering them to the browser depends on whether you are editing an html file or not. There has to be a hack for it to work, just not found one yet

Resources