Sails.js v 10.2缺少快速应用程序 [英] Sails.js v 10.2 missing express app
本文介绍了Sails.js v 10.2缺少快速应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当在sails.0.9x中,我们可以通过
$访问快速应用程序实例b$ b
sails.express.app
升级到0.10后,快捷功能缺少
我们如何调用应用程序?
我们的测试用例使用最高级别失败,我们如何修复sails.express.app问题
var request = require(supertest);
describe(TestController,function(){
describe(。plain,function(){
it(返回200,状态完成,function )$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ expect(Content-Type,/ json /)
.end(function(err,res){
if(err)return done(err);
done();
$ b});
});
解决方案
在Sails v0.10中,基础HTTP服务器(即Express应用程序)可用作:
sails.hooks.http.app
How can we access express app instance from Sails global object after upgrade?
When in sails.0.9x we can access express app instance by
sails.express.app
after upgrading to 0.10, the express function is missing
How can we call the app?
Our test case failed since using supertest, how can we fixed the sails.express.app problem
var request = require("supertest");
describe("TestController", function() {
describe(".plain", function () {
it("returns 200 with status done", function(done) {
request(sails.express.app)
.get("/test/plain")
.expect(200, { status: "done" })
.expect("Content-Type", /json/)
.end(function(err, res) {
if (err) return done(err);
done();
});
});
});
解决方案
In Sails v0.10 the underlying HTTP server (i.e. the Express app) is available as:
sails.hooks.http.app
这篇关于Sails.js v 10.2缺少快速应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文