o3-panther-cli
Version:
Panther CLI for developing and editing sites.
29 lines (25 loc) • 897 B
JavaScript
const fs = require('fs');
const path = require('path');
const https = require('https');
const express = require('express');
const cnf = require(path.resolve(process.cwd(),'o3.json'));
const proxy = require('express-http-proxy')(cnf.remote.domain, {
https: cnf.remote.https
});
const app = express();
module.exports = () => {
app.use(express.static(cnf.local.www));
app.use('/', (req, res, next) => {
proxy(req, res, next);
});
if (cnf.remote.https) {
https.createServer({
key: fs.readFileSync(path.resolve(__dirname, '../keys/key.pem')),
cert: fs.readFileSync(path.resolve(__dirname, '../keys/cert.pem')),
passphrase: '1234'
}, app).listen(cnf.local.port);
} else {
app.listen(cnf.local.port);
}
console.log('Please open your browser and enter the following address: http' + (cnf.remote.https ? 's' : '') + '://localhost:' + cnf.local.port);
}