restify


restify 2.6.1 how to disable body parser for specific request

巧了我就是萌 提交于 2020-01-01 03:25:30
问题 I am pretty new to node.js services and I am facing a problem with multipart/form-data content type. I need a way to disable body parser functionality for specific request. I am using restify 2.6.1. Below are some snippet of the configuration. My setup is: App.js : server.use(restify.authorizationParser()); server.use(restify.dateParser()); server.use(restify.queryParser()); server.use(restify.jsonp()); server.use(restify.bodyParser()); server.use(restifyValidator); server.use(restify

restify regular expression on named parameter

て烟熏妆下的殇ゞ 提交于 2019-12-25 14:21:57
问题 I am using the restify 2.8.4. Understood that named parameter with regular expression is not supported in Mixing regex and :params in route #247 Instead of cobble both logics into one block. server.get ('/user/:id', function (req, res, next) { var id = req.params.id; // check with isNaN() // if string do this // if number do that } I prefer below code structure: //hit this route when named param is a number server.get (/user\/:id(\\d+)/, function (req, res, next) { var id = req.params.id; //

restify: why serving working directory is not possible?

我怕爱的太早我们不能终老 提交于 2019-12-25 02:39:22
问题 I have a restify server with node.js I use to make some development and tests and to do so, I use serveStatic. I wonder why I cannot use the following configuration without getting 403 errors: server.get(/.*/, restify.serveStatic({ directory: '.', default: "index.html" })); Although if I make a link to my current dir: ln -s . serverDir This will work: server.get(/.*/, restify.serveStatic({ directory: './serverDir', default: "index.html" })); What is the reason for this ? Security ? Bug ?

Calling 'next()' from promises in a middleware causes 'next shouldn't be called more than once'

末鹿安然 提交于 2019-12-24 08:47:25
问题 Recently I changed my code from Express to Restify. I'm honestly not sure if it used to happen before, but I guess it did. Basically in my middleware I call a promisified method and when it resolves I call next and do other stuff in the next middleware. When it is rejected I also want to call next with no errors in some cases. Otherwise it must call the error middleware passing err to next . somePromise() .then(()=>{ next(); }) .catch((err)=>{ if(err.someatt) next(); else next(err) }); It

Error: invalid_request Missing required parameter: scope (Restify & Passportjs w/ Google OAuth2)

廉价感情. 提交于 2019-12-24 00:46:08
问题 So, I've run into a problem with my Node.js app, using Restify and Passportjs (Google OAuth2 strategy). When I use passport.authenticate() , it gives me the following error: 400. That’s an error. Error: invalid_request Missing required parameter: scope I found another question about the same thing from a couple of years ago (invalid_request with missing: scope using Google Passportjs on Google Oauth2). The author said he finally fixed it himself but didn't post the fix. Has anyone else run

Node.js + restify cant upload file

六眼飞鱼酱① 提交于 2019-12-23 20:15:50
问题 Im having problems uploading files to a node.js application using restify. This is my upload code https://gist.github.com/maumercado/7ab5cbbfd27c6b825044 Apparently the events are not being triggered, but I dont really know the reason, also the files are being created, but once I see the size info it says 0 bytes. also this is the server.js file https://gist.github.com/maumercado/ecf948b4b8fc7d39e69e Im using a post request in order to upload the file and node 0.10.7. What can be wrong with

How to upload file using restify

我怕爱的太早我们不能终老 提交于 2019-12-23 12:45:45
问题 I'm trying to upload image file to Rest server(Confluence to be more specific) using Restify module but getting Assertion error. I'm not sure if I'm using right approach for file upload to REST server. Could anyone point me to the right direction? This is my attempt - var restify = require('restify'); var header = {'Authorization': 'Basic xxxxx', 'content-type': 'multipart/form-data'}; var client = restify.createJsonClient({ url: 'http://www.testsite.com', version: '*', headers: header });

Testing Restify Route Handler that contains Promise Code Block, using SinonJs and Mocha

我的未来我决定 提交于 2019-12-23 00:48:08
问题 I have a restify action code block below: function retriveAll(req, res, next) { db.user .find({where: {id: 1}) .then(function(user){ res.send(user); }) .catch(function(details){ res.send(details.message); }) .finally(function(){ next(); }); } I want to test this action specifically validating that res.send() was called within this code block . And later on validating the res.send() returned data. I'm using SinonJs and Mocha for testing framework. Here's a sample test code block for the method

How to avoid the data of request stream loss after doing some authentication on node.js?

谁说胖子不能爱 提交于 2019-12-22 09:15:08
问题 How do request streams works with node.js (express or restify) ? When a client who tries to upload an audio, mpeg or other binary file to the server, the request should be a Readable Stream on the server. that we could pipe into another stream using request.pipe() to for example get the file from the request, and then upload the file to amazon s3 using knox. When I'm using an asynchronous authentication method part of the streamed data is being lost and the length doesn't match with the

Node.js EventEmitter error

戏子无情 提交于 2019-12-20 05:39:15
问题 I have an error when trying to inherit EvenEmitter /* Consumer.js */ var EventEmitter = require('events').EventEmitter; var util = require('util'); var Consumer = function() {}; Consumer.prototype = { // ... functions ... findById: function(id) { this.emit('done', this); } }; util.inherits(Consumer, EventEmitter); module.exports = Consumer; /* index.js */ var consumer = new Consumer(); consumer.on('done', function(result) { console.log(result); }).findById("50ac3d1281abba5454000001"); /*

工具导航Map