Commit 3d6ddb62 authored by rockyl's avatar rockyl

proxy

parent 97cbe806
......@@ -5,6 +5,7 @@ const jsonServer = require('./json-server');
program
.option('-h, --host [string]', 'server host', 'localhost')
.option('-p, --port [number]', 'server port', 3000)
.option('--proxy [string]', 'server proxy address')
.option('-f, --folder [string]', 'folder of json files', './')
.option('-k, --key-file [string]', 'ssl key file')
.option('-c, --cert-file [string]', 'ssl cert file')
......@@ -16,6 +17,7 @@ async function execute() {
jsonServer.start({
host: program.host,
port: program.port,
proxy: program.port,
folder: program.folder,
keyFile: program.keyFile,
certFile: program.certFile,
......
......@@ -31,7 +31,7 @@ function handler(request, response) {
content = fs.readFileSync(targetFile, 'utf-8');
} else if (fs.existsSync(targetFile = filePath + '/index.js')) {
try {
const jsonObject = require(targetFile);
const jsonObject = require(targetFile)();
content = JSON.stringify(jsonObject);
} catch (e) {
console.log(e);
......@@ -60,7 +60,7 @@ function handler(request, response) {
exports.start = function (options) {
return new Promise((resolve, reject) => {
const {port, host, folder, keyFile, certFile} = options;
const {port, host, proxy, folder, keyFile, certFile} = options;
jsonPath = path.resolve(folder);
if (fs.existsSync(jsonPath)) {
......
......@@ -3,6 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment