Tag: coffeescript

使用护照的Node.js用户authentication

(具有序列化function的更新代码 – 仍然redirect到/ failedRedirect) 我正试图使用​​护照包进行简单的用户名/密码authentication,但是失败。 在下面的例子中,我试图通过基本上总是返回一个有效的身份validation来validation身份validation是否正常(不pipe通过什么),但是由于某种原因它失败了,护照redirect到失败的login链接。 如果有人能帮我弄清楚如何让这个例子简单地authentication任何东西,我应该能够从那里pipe理。 在coffeescript中的代码是: express = require "express" passport = require "passport" LocalStrategy = require("passport-local").Strategy passport.use(new LocalStrategy( (username, password, done) -> console.log "LocalStrategy invoked" done(null, {id: 1, name: "Marius"}) )) passport.serializeUser (user, done) -> done null, user passport.deserializeUser (obj, done) -> done null, obj app = express.createServer() app.configure -> app.use express.bodyParser() […]

如何configurationGrunt的目录recursionSass编译任务

我是一个新手,学习如何configuration咖啡,玉器和sass编译任务。 我可以成功地为咖啡和玉目录configuration编译任务,但我不能sass。 我的项目的结构是波纹pipe . ├── Gruntfile.coffee ├── node_modules ├── package.json ├── sass │ └── index.sass └── www 和我的package.json是 { "name": "grunt-sass-test", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-sass": "~0.5.0" } } 当Gruntfile.coffee在下面时, $ grunt sass编译index.css成功: module.exports = (grunt) -> grunt.initConfig pkg: grunt.file.readJSON('package.json') sass: compile: files:[ "www/index.css": "sass/index.sass" ] 但是如下所示, >>没有find源文件“index.sass”。 显示错误 sass: compile: cwd: 'sass' […]

使用CoffeeScript中的Node.js需求和类来解决循环依赖关系

我想知道是否有一种方法可以在使用CoffeeScript类和super时候习惯性地避免Node.js require循环依赖的问题。 鉴于以下简化的CoffeeScript文件: 一杯咖啡: C = require './c' B = require './b' class A extends C b: B someMethod: -> super module.exports = A b.coffee: C = require './c' A = require './a' class B extends C a: A someMethod: -> super module.exports = B 第一个显而易见的问题是,A和B之间存在循环依赖关系。无论哪个先评估,都将作为另一个参考。 为了在一般情况下解决这个问题,我可能会尝试在每个方面做这样的事情: 一杯咖啡: C = require './c' class A extends […]

nodejs视图不会在布局中显示

我正在尝试使用CoffeeScript,NodeJS和expressJS创build一个简单的布局。 我的咖啡脚本是 routes.coffee我已经将路由文件夹重命名为应用程序,而我的routes.coffee文件位于身份validation文件夹中,例如apps\authentication\routes.coffee routes = (app) -> app.get "/login", (req , res) -> res.render "#{__dirname}/views/login", title: 'Login', stylesheet: 'login' module.exports = routes login视图我已经更名为path文件夹应用程序和我的login视图在那里authentication文件夹,即apps\authentication\views\login.jade extends ../../../views/layout block content form(action='/sessions', method='post') label | Username input(type='text', name='user') label | Password input(type='password', name='password') input(type='submit', name='Submit') Layout.jade这个文件在默认视图文件夹中。 我正在使用默认布局 doctype html head title= title body #content h1= title block content != […]

哪个IDE支持Node.js应用程序的CoffeeScriptdebugging(源映射,断点和调用堆栈)?

对于整个CoffeeScript场景,我还是个新手。 有没有支持在Node.js上运行的CoffeeScript源代码的debugging的IDE? 我希望能够在.coffee文件中设置断点并查看调用堆栈并检查variables。 WebStorm似乎还不适合这个账单。 WEB-2389 在Chrome中使用CoffeeScriptRedux似乎有这个客户端的解决scheme。 例 还有其他的select吗? 崇高 ? 更新在近一年后再次检查这个问题后,我遇到了这个JetBrains帮助文档 。 它看起来像它支持debugging服务器端咖啡脚本…终于!

如何在Node.js中等待

这是一个关于我认为会是节点js中简单模式的问题。 这是我在coffeescript的例子: db_is_open = false db.open -> db_is_open = true wait = -> wait() until db_is_open 并再次在JavaScript中: var db_is_open = false; db.open(function() { db_is_open = true; }); function wait() {}; while (not db_is_open) { wait()}; 这根本不起作用,因为while循环从不放弃控制,我认为这是有道理的。 但是,我怎么能告诉等待函数尝试队列中的下一个callback?

如何让Stylus在CoffeeScript中使用Express和Connect工作

我的app.coffee看起来像这样: connect = require 'connect' express = require 'express' jade = require 'jade' stylus = require 'stylus' app = express.createServer() # CONFIGURATION app.configure(() -> app.set 'view engine', 'jade' app.set 'views', "#{__dirname}/views" app.use connect.bodyParser() app.use connect.static(__dirname + '/public') app.use express.cookieParser() app.use express.session({secret : "shhhhhhhhhhhhhh!"}) app.use express.logger() app.use express.methodOverride() app.use app.router app.use stylus.middleware({ force: true src: "#{__dirname}/views" […]

上传进度 – 请求

我正在使用Request上传文件。 req = request.post url: "http://foo.com", body: fileAsBuffer, (err, res, body) -> console.log "Uploaded!" 我如何知道实际上传了多less数据? 是否有一些我可以订阅的事件,或者是否有可以轮询的request的属性? 如果没有,上传数据的最佳方法是什么,并知道上传了多less?

摩卡,should.js和断言exception

我有一个文件app.coffee : class TaskList class Task constructor: (@name) -> @status = 'incomplete' complete: -> if @parent? and @parent.status isnt 'completed' throw "Dependent task '#{@parent.name}' is not completed." @status = 'complete' true dependsOn: (@parent) -> @parent.child = @ @status = 'dependent' # Prepare scope stuff root = exports ? window root.TaskList = TaskList root.Task = Task […]

Coffeescript 1.1.3手表只能使用一次

我有nodejs v0.6.3和coffeescript 1.1.3。 在Archlinux上。 我知道他们改变了手表在最新发布的coffeescript中的工作方式,手表至less需要节点v0.6.2。 在我的情况下,它只能工作一次。 之后,当我再次保存一个文件,咖啡不注意。 这里可能是什么问题?