node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Browserify support?

Open airandfingers opened this issue 11 years ago • 5 comments

I'm trying to browserify sails-rest, which depends on restify, and my current issue stems from one of restify's dependencies, spdy:

Error: module "./spdy/protocol/generic.node" not found from "node_modules/sails-rest/node_modules/restify/node_modules/spdy/lib/spdy.js"
at notFound (node_modules/moonboots-express/node_modules/moonboots/node_modules/browserify/index.js:812:15)

As far as I can tell, spdy is only used by restify's server component (not its client), while sails-rest only uses restify's client.

As such, I figure the best way to proceed is to split off restify's client functionality into a standalone restify-client package, and use a custom version of sails-rest that uses restify-client instead of restify.

Is there any way around this labor-intensive approach? Is anyone already using restify on the browser?

airandfingers avatar Mar 03 '15 06:03 airandfingers

for that you should supertest

gergelyke avatar Mar 03 '15 18:03 gergelyke

Just to follow up, I tried removing createServer and the code that calls it, but even the client code can't be Browserified - the client relies on the mime module, which makes a dynamic fs.readFileSync call, which Browserify can't handle, even with the brfs transform.

Thanks for the suggestion. I'll find another way to do what I want to do.

airandfingers avatar Mar 04 '15 07:03 airandfingers

@gergelyke I also met this issue. What do you mean we should supertest~? Does it mean that we should another library?

StevenRoan avatar Jul 21 '15 06:07 StevenRoan

@StevenRoan yes, he meant we should use another library. sails-rest - even restify-client - is designed to run on the server only.

I wound up using https://github.com/visionmedia/superagent, which is the HTTP agent part of the supertest library he mentioned.

airandfingers avatar Jul 21 '15 07:07 airandfingers

@airandfingers get it. Thanks for response

StevenRoan avatar Jul 31 '15 07:07 StevenRoan