Muthu Kumar
6 years ago
7 changed files with 2072 additions and 171 deletions
File diff suppressed because it is too large
@ -1,13 +1,13 @@ |
|||
'use strict' |
|||
|
|||
const { EOL } = require('os') |
|||
const { EOL } = require('os'); |
|||
|
|||
function plugins() { |
|||
function plugins(app) { |
|||
const { plugins } = require('../config') |
|||
return plugins.map(plugin => { |
|||
require('../plugins/' + plugin + '/main.js') |
|||
console.log(EOL + 'Loaded plugin ' + plugin + '...') |
|||
}) |
|||
} |
|||
require('../plugins/' + plugin)(app); |
|||
console.log(EOL + 'Loaded plugin ' + plugin + '...'); |
|||
}); |
|||
}; |
|||
|
|||
module.exports = plugins |
|||
module.exports = plugins; |
|||
|
@ -1,38 +1,26 @@ |
|||
'use strict' |
|||
'use strict'; |
|||
|
|||
const path = require('path') |
|||
const fs = require('fs') |
|||
const { EOL } = require('os') |
|||
const fs = require('fs'); |
|||
const { EOL } = require('os'); |
|||
|
|||
const express = require('express') |
|||
const chalk = require('chalk') |
|||
const express = require('express'); |
|||
const chalk = require('chalk'); |
|||
|
|||
const php = require('./php') |
|||
const config = require('./config') |
|||
const plugins = require('./plugins/loader') |
|||
const php = require('./php'); |
|||
const config = require('./config'); |
|||
const plugins = require('./plugins/loader'); |
|||
|
|||
const htaccess = require('express-htaccess-middleware') |
|||
const RewriteOptions = { |
|||
file: path.resolve(config.publicPath, '.htaccess'), |
|||
verbose: (process.env.ENV_NODE == 'development'), |
|||
watch: (process.env.ENV_NODE == 'development'), |
|||
} |
|||
const app = express(); |
|||
|
|||
const app = express() |
|||
app.use("/", php.cgi(config)); |
|||
|
|||
app |
|||
.use("/", php.cgi(config.publicPath, config.phpBin)) |
|||
.use(htaccess(RewriteOptions)) |
|||
plugins(app); // Load any plugins declared in config
|
|||
|
|||
plugins() // Load any plugins declared in config
|
|||
|
|||
app.listen(config.port) |
|||
|
|||
const fancy = fs.readFileSync('./fancy.txt') |
|||
const fancy = fs.readFileSync('./fancy.txt'); |
|||
const listeningMsg = ( |
|||
chalk.yellow(fancy) + EOL + |
|||
chalk.green(` Server listening on port ${config.port}` + EOL + |
|||
'+---------------------------------+') |
|||
) |
|||
); |
|||
|
|||
console.log(listeningMsg) |
|||
app.listen(config.port, () => console.log(listeningMsg)); |
|||
|
Loading…
Reference in new issue