Sails.js v 10.2 missing express app

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

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();         });     });   }); 

回答1:

In Sails v0.10 the underlying HTTP server (i.e. the Express app) is available as:

sails.hooks.http.app 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!