我试图在一个应用程序中托管多个节点服务。所以我使用express,vhost和connect通过以下答案路由它们:Combine multiple node js services
我有我的app.js片段:
var path = require('path');
var AWS = require('aws-sdk');
var util = require('util');
var vhost = require('vhost');
var connect = require('connect');
var async = require('async');
var serveStatic = require('serve-static');
var port = process.env.PORT || 3000,
http = require('http');
var log4js = require('log4js');
var moment = require('moment');
var express = require('express'),
main = express();
main.use(vhost('*.site1.com',require('./')));
当节点尝试执行最后一行时,我收到错误。
这是我在./index.js中获取请求的方式:
var myservice = require('./myService').handler;
myservice({
eventjson...
...
},function(err) {
console.log('Some error!');
});
var app = express();
app.get('/', function(req,res){
res.send('Home Page');
});
我的应用层次结构是:
myservice
|__app.js
|__index.js
|__myservice.js
|__package.json
我认为require('./')
会出现问题,但我该如何更改呢?