'use strict'; /** * Main program of service of 3rd party **/ const express = require('express'); const bodyParser = require('body-parser'); const {default: aliyunRouter} = require('./router_aliyun.js'); const app = express(); //Express behind proxies app.set('trust proxy', true); app.disable('x-powered-by'); //Serving static files app.use(express.static('public')); // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ limit: '2mb', extended: false })) // parse application/json app.use(bodyParser.json({ limit: '2mb' })) app.get('/', (req, res) => { return res.send('Welcome to @filesite/service-3rd'); }); //阿里云相关接口调用 app.use('/aliyun', aliyunRouter); //error handler app.use((err, req, res, next) => { if (res.headersSent) { return next(err); } console.error('Request error in @filesite/service-3rd: %s', err.stack); var statusCode = 500; if (typeof(err.statusCode) != 'undefined' && err.statusCode) { statusCode = err.statusCode; } return res.status(statusCode).send(err.message); }) // Listen to the App Engine-specified port, or 8080 otherwise const PORT = process.env.PORT || 8081; const HOST = '127.0.0.1'; app.listen(PORT, HOST, async () => { console.log('Server listening on port %s...', PORT); });