Browse Source

Added very preliminary support for plugins

master
Muthu Kumar 7 years ago
parent
commit
b84dd4107f
  1. 1
      .gitignore
  2. 12
      config.js
  3. 5
      php.js
  4. 10
      plugins/main.js
  5. 15
      server.js

1
.gitignore

@ -1,3 +1,4 @@
node_modules
php
wp
plugins/*/

12
config.js

@ -1,13 +1,11 @@
'use strict'
const { normalize } = require('path')
module.exports =
{
port: 8080,
php: {
bin: normalize(__dirname + '/php/php-cgi.exe')
},
wp: {
path: normalize(__dirname + '/wp'),
root: normalize(__dirname + '/wp/index.php')
}
phpBin: normalize(__dirname + '/php/php-cgi.exe'),
wpPath: normalize(__dirname + '/wp'),
plugins: []
}

5
php.js

@ -1,6 +1,9 @@
// The base work for this module was found at
// https://npmjs.com/package/node-php
// Credits to original author
// All credits to original author
// I've ES6'd and fixed deprecated Express functions
'use strict'
const url = require('url')
const child = require('child_process')

10
plugins/main.js

@ -0,0 +1,10 @@
'use strict'
function plugins() {
const { plugins } = require('../config')
plugins.forEach(element => {
require('../plugins/' + element + '/main.js')
})
}
module.exports = plugins

15
server.js

@ -1,11 +1,16 @@
var express = require('express')
var php = require("./php")
'use strict'
const express = require('express')
const php = require("./php")
const config = require('./config')
const plugins = require('./plugins/main')
var app = express()
const app = express()
app
.use("/", php.cgi(config.wp.path, config.php.bin))
.use("/", php.cgi(config.wpPath, config.phpBin))
.listen(config.port)
console.log(`Server listening at ${config.port}!`)
console.log(`⚡ Server listening at ${config.port}!`)
plugins() // Run any plugins you need to while server runs

Loading…
Cancel
Save