functionscope / Node-Excel-Export

A simple node.js module for exporting data set to Excel xlsx file.
492 stars 271 forks source link

Major conflict with Sails.js Blueprints #24

Open dannycampa opened 9 years ago

dannycampa commented 9 years ago

I'm currenlty using your module with my app that uses SailsJS 0.10.2. SailsJS uses something called Blueprints to auto-generate a RESTful API for the models that are created.

When using the Excel Export in conjucntion with SailsJS, it caused REST operations to not read any of the parameters I was sending.

I'm pretty new to nodeJS so correct me if I'm wrong, but at quick glance i noticed you have several variables set outside of your exports. Wouldn't this cause the variables to be global and most likely cause them to conflict with anything sharing those var names?

functionscope commented 9 years ago

In node.js variables local to the module will be private, as the module is wrapped in a function. See node.js api manual http://nodejs.org/api/modules.html

Do you have an example showing the conflict?

On Mon, Dec 1, 2014 at 1:26 PM, dannycampa notifications@github.com wrote:

I'm currenlty using your module with my app that uses SailsJS 0.10.2. SailsJS uses something called Blueprints to auto-generate a RESTful API for the models that are created.

When using the Excel Export in conjucntion with SailsJS, it caused REST operations to not read any of the parameters I was sending.

I'm pretty new to nodeJS so correct me if I'm wrong, but at quick glance i noticed you have several variables set outside of your exports. Wouldn't this cause the variables to be global and most likely cause them to conflict with anything sharing those var names?

— Reply to this email directly or view it on GitHub https://github.com/functionscope/Node-Excel-Export/issues/24.

dannycampa commented 9 years ago

I didn't take any screenshots, but basically in blueprints, if i create a model called users, the blueprints api will auto generate create, find, destroy and update endpoints. So then I can enter the following url:

http://localhost/users/create?email=user@domain.com&firstname=danny&lastname=campa

It will then return me a json response of the created record with createdDate, modifiedDate, ID, and the parameters I sent.

When I required your module though in a seperate controller, it broke this functionality. My validation wasn't working from the Waterline API. When i disable the validation, it was just creating empty records.

Once I removed my require line from the seperate controller, it started accepting the parameters again.

Here is the use of your module in one of my controllers:

http://pastebin.com/LPC0AuXh

Commenting line 8, resolved the issue with the REST functionality. I didn't have any errors in my console or anything. Exports worked just fine, but it broke the REST api.

functionscope commented 9 years ago

I can't tell anything wrong. I guess you have properly npm install the package and your package.json file correctly lists the dependencies.

You might want to use node-inspector to debug into it.

On Tue, Dec 2, 2014 at 12:52 PM, dannycampa notifications@github.com wrote:

I didn't take any screenshots, but basically in blueprints, if i create a model called users, the blueprints api will auto generate create, find, destroy and update endpoints. So then I can enter the following url:

http://localhost/users/create?email=user@domain.com &firstname=danny&lastname=campa

It will then return me a json response of the created record with createdDate, modifiedDate, ID, and the parameters I sent.

When I required your module though in a seperate controller, it broke this functionality. My validation wasn't working from the Waterline API. When i disable the validation, it was just creating empty records.

Once I removed my require line from the seperate controller, it started accepting the parameters again.

Here is the use of your module in one of my controllers:

http://pastebin.com/LPC0AuXh

Commenting line 8, resolved the issue with the REST functionality. I didn't have any errors in my console or anything. Exports worked just fine, but it broke the REST api.

— Reply to this email directly or view it on GitHub https://github.com/functionscope/Node-Excel-Export/issues/24#issuecomment-65273177 .

johanlajili commented 9 years ago

Same problem here. Deal breaker for me.

dannycampa commented 9 years ago

I ended up building a second app as a standalone exporter. When I build the production version though I'm going to have to try and figure out what's going on. Someone forked this version though, so I might look at that when I get to that point, to see if it has the same issue.

johanlajili commented 9 years ago

I think I'm going to look at other solutions. It's a shame cause I already have the export working with excel-export.

hardikbarot commented 9 years ago

So what is solution?

mwielbut commented 9 years ago

Seems to be caused by the collections.js dependency. This library blindly makes major additions to core classes via prototype, including Array which is likely creating a conflict. Using excel-export-fast doesn't rely on this dependency.

gillescochez commented 9 years ago

Collection mayhem was added in the last commit, taking the file in its previous state did the job for me, no collection problems in there.

Shame can't have it as a dependency any more but at least it works with sails.js.

Attempted excel-export-fast and that has more dependencies and well I couldn't even manage to install it so copy/pasting the previous index.js and adding node-zip as dependency was a quick win. Both projects seems barely supported or cared for so probably safer in the long run to not depend on them.

tjwebb commented 9 years ago

This library blindly makes major additions to core classes via prototype

Mootools also does this, and has caused problems with sails.js. But in general, adding junk onto global prototypes will break just about anything and is a terrible idea.

dudestein commented 9 years ago

Same problem here. After running anything with excel-export, the blueprints just go completely crazy...

functionscope commented 9 years ago

Likely collection.js is the source of problems. Try using previous version of excel-export 0.3.11 which does not depend on collection.js.

On Thu, Apr 30, 2015 at 5:56 PM, Paulo Silva notifications@github.com wrote:

Same problem here. After running anything with excel-export, the blueprints just go completely crazy...

— Reply to this email directly or view it on GitHub https://github.com/functionscope/Node-Excel-Export/issues/24#issuecomment-97982603 .

jmav commented 9 years ago

Same problem here with sails.js.

tjwebb commented 9 years ago

Yea I think we determined already that this excel module (or one of its dependencies) hacks the prototype of some of the built-in Javascript objects, such as Array. We (sails.js) rely on the standard objects to do what they're supposed to do. If some other module screws this up, there's not a lot that can be done aside from filing an issue on that other project and telling the developer they're an idiot.

dudestein commented 9 years ago

a good fix is:

REMOVE this module from your project.

use node-xlsx instead.

Messing with the prototype of Javascript objects is way out of line!

tjwebb commented 9 years ago

Messing with the prototype of Javascript objects is way out of line! use node-xlsx instead.

There you have it folks. The solution.

This module doesn't seem to be very actively maintained, anyway

netrevisanto commented 9 years ago

@functionscope Your Solution works very well with sails 0.9.8 Thanks very much!