环回应用程序功能错误
Loopback Applications Functions Errors
我正在使用环回和 mysql 开发 vuejs 应用程序。当我 运行 我得到错误的应用程序是
app.start 不是函数 .
这是我的代码server.js ..
// Copyright IBM Corp. 2016. All Rights Reserved.
// Node module: loopback-workspace
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
module.exports = function(app) {
// Install a "/ping" route that returns "pong"
app.get('/ping', function(req, res) {
res.send('pong');
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
这是我的 route.js 文件代码
'use strict';
module.exports = function(app) {
var router = app.loopback.Router();
router.get('/ping', function(req, res) {
res.send('pongaroo');
});
app.use(router);
};
所有 server.js 文件都应包含一个名为 app.start 的函数。在此功能中,只有服务器启动。在 server.js 文件中尝试添加 app.start(),希望能解决您的问题。请参阅下面的 app.start 函数的代码。
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
我正在使用环回和 mysql 开发 vuejs 应用程序。当我 运行 我得到错误的应用程序是 app.start 不是函数 .
这是我的代码server.js ..
// Copyright IBM Corp. 2016. All Rights Reserved.
// Node module: loopback-workspace
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
module.exports = function(app) {
// Install a "/ping" route that returns "pong"
app.get('/ping', function(req, res) {
res.send('pong');
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
这是我的 route.js 文件代码
'use strict';
module.exports = function(app) {
var router = app.loopback.Router();
router.get('/ping', function(req, res) {
res.send('pongaroo');
});
app.use(router);
};
所有 server.js 文件都应包含一个名为 app.start 的函数。在此功能中,只有服务器启动。在 server.js 文件中尝试添加 app.start(),希望能解决您的问题。请参阅下面的 app.start 函数的代码。
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};