restify

nodejs https callback not updating global variable [duplicate]

こ雲淡風輕ζ 提交于 2019-12-11 23:24:49
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) Closed 5 years ago . I'm setting up a quick proxy server in nodejs to proxy a API request for an Angular application. The proxy endpoint is a service I do not control and does not support CORS or JSONP. For testing, I setup a dummy http server in the code example below, but in reality this is a remote domain. I'm pretty sure my problem is due to asynchronous processing of nodejs, but

Problems using node-restify-oauth2-mongodb

自古美人都是妖i 提交于 2019-12-11 20:47:55
问题 I would like to use Restify/Nodejs + Oauth2 + Mongodb to register and authenticate users... I found a great git hub repo here: https://github.com/rgallagher27/node-restify-oauth2-mongodb I have both Redis and Mongo installed and I get the node up and running with the code and I can register users. However, I have some problems with validating a user. There was one step in the instructions that I am not sure I am completing correctly ... ////////////////////// **Insert a Client Key into the

Elastic - Sorting value with priority

本小妞迷上赌 提交于 2019-12-11 15:43:55
问题 So, i have 1 field, we can call it timeInt. the type value is integer. The value is counted from 0. And i want to sort it with priority condition. 0 / 1 will be placed on the top then the bigger value is placed after value 0 / 1. Ex: 0 1 100 99 98 etc... I don't know how can i achieve that, i already search on google, and still stucked, i just try query sort like this: sort:[{timeInt:{'order':'asc'}}] but it just ascending sort let newQuery = { index: `${config.get('/indexElastic').needAction

Elastic - Desc sort is not working anymore when doing boost query + must query

て烟熏妆下的殇ゞ 提交于 2019-12-11 15:20:46
问题 So, i'm doing sort with priority that already solved on my previous post: Elastic - Sorting value with priority But i found the new problem, when i want to filter data with specified field, the query sort of timeInt doesn't work anymore I've tried this query, but the query sort of timeInt doesn't work. Here is my query: { query: { bool: { must: { match: { 'flag_type': "contract" } }, should: [ { match: { timeInt: { query: 0, boost: 3 } } }, { match: { timeInt: { query: 1, boost: 2 } } } ] } }

Using a testing database with Restify

╄→尐↘猪︶ㄣ 提交于 2019-12-11 11:05:25
问题 I created a simple Restify server, and started testing its functionality through Mocha using its own JSONclient. When Unit Testing functionality, it's possible to set an ENV var indicating a testing setup, and connect to the according mongodb database. However, when using the JSONClient you, obviously, test the 'running' API server, which is already connected. Is there any way to end-to-end test API functionality through the client by swithing database-connections as to not overwrite the

What is wrong with this HTTP-Get Basic authentication code?

眉间皱痕 提交于 2019-12-11 03:57:19
问题 I am using node.js restify as backend to run a REST API server and angularjs as front-end to call the HTTP GET. The REST server uses HTTP Basic Authentication. The username is foo and password is bar . I have tested that the backend code works by using a restify client. Here is the working client code; var client = restify.createJsonClient({ url: 'http://127.0.0.1' }); client.basicAuth('foo', 'bar'); client.get('/alert?list=alertList', function(err, req, res, obj) { console.log(obj); }); I

Download a file from REST API with Restangular request

别来无恙 提交于 2019-12-11 03:32:15
问题 I've got a simple node.js + Restify backend with standard CORS settings and this endpoint: var file = '1,5,8,11,12,13,176,567,9483'; server.get('/download', function(req, res, next) { res.set({"Content-Disposition": "attachment; filename='numbers.csv'"}); res.setHeader("Content-type", "text/csv"); res.send(file); return next(); }, function(err) { res.send(err); }); What it's suppose to do is to is to create CSV file and return it. It works great when I simply type in the endpoint address to

Restify on Cloudfoundry 'invalid ELF header'

十年热恋 提交于 2019-12-11 03:19:49
问题 I'm deploying a node.js app to Cloudfoundry, the only module dependency is restify. I've tried pushing it with my local node_modules directory and also using npm shrinkwrap and 'ignoreModules' in cloudfoundry.json but always end up with this in the stdout.log: { stack: [Getter/Setter], arguments: undefined, type: undefined, message: '/var/vcap/data/dea/apps/myapp-0-6f9cf62f9bbe58f5d2eb13a94acb5d3a/app/node_modules/restify/node_modules/dtrace-provider/build/Release/DTraceProviderBindings.node:

Returning values from Promise(Bluebird) in Node.js

∥☆過路亽.° 提交于 2019-12-11 03:08:51
问题 I am learning Node.js and was looking at the Promise module. I am very new at this so please bare with bad code conventions and stuff. I am trying to build a REST Client API using restify. I have attached my Client Code below: Here is my Client: // local functions function loadResult(err, req, res, obj) { //console.log(err, req, res, obj); var result = { 'err': err, 'text': obj }; console.log(result); return result; } function getClient() { if (client) { return client; } else { client =

Last callback not being called using async

余生颓废 提交于 2019-12-11 02:36:51
问题 I cannot seem to get the last callback (commented as "optional callback") called to send the result back to the browser. Any pointers as to what I am doing wrong? I am using the following modules: async, restify and postgresql for node.js console.log('Start'); var async = require('async'); var restify = require('restify'); var server = restify.createServer(); server.use(restify.bodyParser()); server.get('/user/creationdate/:username', function(req, res, next) { var userName = req.params