Tag: coffeescript

nodejs护照总是失败的URL

我正在使用护照,允许通过我的网站上的Facebooklogin。 一切似乎工作得很好,但Facebook的网站callback总是去到failureRedirect,即使我从Facebook有回来的所有数据有效的令牌。 任何想法为什么发生这种情况? express = require "express" passport = require 'passport' FBStrategy = require('passport-facebook').Strategy Properties = require "./config.json" FB_APP_ID = REMOVED FB_APP_SECRET = REMOVED passport.serializeUser = (user, done) -> done null, user passport.deserializeUser = (obj, done) -> done null, obj fb = new FBStrategy clientID: FB_APP_ID clientSecret: FB_APP_SECRET callbackURL: "http://localhost/auth/facebook/callback" (accessToken, refreshToken, profile, done) -> […]

如何在Locomotivejs中设置coffescript?

我应该怎么做在Locomotivejs中设置coffeescript。 这似乎很容易,但我无法弄清楚。 我在“all.js”中设置了选项,没有运气。 我想我差不多还是很远才能把事情做好。 🙁 this.set("options",{coffee:true}); 任何帮助表示赞赏。

与Coffeescript一起使用should.js

我想在我在Coffeescript中编写的Node.js项目中使用should.js和mocha。 在纯Javascript中,should.js中的expression式就像 (function(){ throw new Error('fail'); }).should.throw(); 现在我想在Coffeescript中编写相同的expression式。 就像是 object.function().should.throw 但是,编译 object["function"]().should["throw"]; 我的Coffescript代码中的错误在哪里?

Node.js类的问题,或者我做错了什么?

这个代码 class Foo bar: [] test = new Foo() test.bar.push('b') test2 = new Foo() console.log test2.bar 将产生输出['b'] 。 怎么可能呢? 编辑: 这就是CoffeScript生成的内容: // Generated by CoffeeScript 1.4.0 var Test, test, test2; Test = (function() { function Test() {} Test.prototype.a = []; return Test; })(); test = new Test(); test.a.push('b'); test2 = new Test(); console.log(test2.a); 因此,下面写的是完全正确的。 感谢你们。

简单的Q承诺节点的例子

我试图把我的头围绕Q库/承诺一般,所以我可以在我的节点应用程序中实现它,但我很难find一些简洁和具体,足以快速入门。 有人可以帮助我把这个代码翻译成一个使用Q的承诺库的asycronous模式吗? // # For those new to coffeescript // # '(params) ->' === 'function (params) {}' in coffeescript // # '@' === 'this' in coffeescript // # NPM Q = require 'q' // # Database class module.exports = class Database constructor: () -> // # mongoose @mongoose = require('mongoose') // # Make database connection […]

Coffeescript + node.js:意外标记>(函数箭头)

当我尝试运行以下coffeescript代码时: request = require('request') request('http://google.com', (error, response, body) -> if not error and response.statusCode is 200 console.log(body) ) 我得到以下错误: request('http://google.com', (error, response, body) -> ^ SyntaxError: Unexpected token > at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:901:3 但是当我在coffeescript.org的编译器上运行它时,它会吐出正确的javascript。 任何想法发生了什么?

节点:child_process.exec()进程在父进程死亡后继续

我试图创build一个本地API服务用于testing目的,这涉及到在我的构build系统中运行make命令。 代码如下所示: (注意:这是咖啡的脚本) request = require "request" child_process = require "child_process" tsc = require "training_service_connector" campaign = "happytest" strategy = campaign port_number = 54340 service_conf_filename = tsc.writeServiceConfig(strategy, port_number) exec_callback = (error, stdout, stderr) -> console.log ('stdout:\n' + stdout + '\nstderr:\n' + stderr + "\nerror:\n" + error) child_process.exec ("CONFIG=#{service_conf_filename} make run_bidder_service_runner", exec_callback) # some other stuff […]

只是不能让Passport.js工作

编辑:对不起现在这么久了,在编译的JS里join了! 我也加了Kevsbuild议。 我正在开发一个MEAN栈应用程序(MongoDB,ExpressJS,Angular,NodeJS),并且花了很多时间,特别是在咖啡脚本中。 我的问题是,我不能让passport.js工作,每次返回{success:false}。 当我在我的LocalStrategy函数中做一个console.log时,它似乎从来没有被调用过。 任何想法为什么? 一些片段 server.coffee(主文件) … Account = mongoose.model 'account' passport.use 'local-login', new LocalStrategy (_username, password, done) -> Account.findOne {username:_username}, (error, user) -> if error done error if not user done null, false, {message:'Incorrect username.'} done null,user passport.serializeUser (user, done) -> console.log 'serialize user' if user done null, user passport.deserializeUser (id, done) […]

节点中的R.js和Coffeescript

新的节点。 有人可以帮我理解如何在nodejs应用程序中使用coffeescript来configurationr.js吗? 详细阐述一下,我有点失落了。 在哪里包括r.js在项目中。 一个简单的用例,需要用r.js来定义。 在源代码中包含cs-require的位置 哪些部分可以用npm install来安装我之前问过这个问题,但好像我问了10个问题,所以我试图更简洁。 我希望有人能指点我一个例子git,因为我很难find任何。 谢谢

如何在远程服务器上从远程服务器获取JSON?

我正在寻找一种方法来复制jQuery方法getJSON,但服务器端。 我使用的服务器是一个用coffeescript编写的express框架的node.js服务器。 我有客户端的代码是: # To get the client IP $.getJSON("http://jsonip.com?callback=?", (data) -> # To get more information about that IP $.getJSON("http://freegeoip.net/json/" + data.ip, (fulldata) -> console.log fulldata)) fulldatavariables给我关于客户IP的信息。 我必须避免使用JavaScript客户端,所以我尝试做同样的服务器端,我得到的客户端IP: (req, res) -> # To get the client IP req.ip 但之后,我不知道如何从freegeoip.net服务器获取json中的完整数据。 帮助,任何人?