-
Notifications
You must be signed in to change notification settings - Fork 390
/
vercel.js
32 lines (30 loc) · 830 Bytes
/
vercel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const path = require('path');
const Application = require('thinkjs');
const Loader = require('thinkjs/lib/loader');
const app = new Application({
ROOT_PATH: __dirname,
APP_PATH: path.join(__dirname, 'src'),
VIEW_PATH: path.join(__dirname, 'view'),
proxy: true, // use proxy
env: 'vercel',
external: {
package: path.join(__dirname, 'package.json'),
qiniu: path.join(__dirname, 'node_modules/qiniu/qiniu'),
static: {
www: path.join(__dirname, 'www')
}
}
});
const loader = new Loader(app.options);
loader.loadAll('worker');
module.exports = function (req, res) {
return think.beforeStartServer().catch(err => {
think.logger.error(err);
}).then(() => {
const callback = think.app.callback();
return callback(req, res);
})
.then(() => {
think.app.emit('appReady');
});
};