document-process-manager
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -14,5 +14,5 @@ import path from 'node:path' | ||
#_watcher | ||
#_boundAdd | ||
#_boundChange | ||
#_boundUnlink | ||
#boundAdd = this.#add.bind(this) | ||
#boundChange = this.#change.bind(this) | ||
#boundUnlink = this.#unlink.bind(this) | ||
constructor($settings, $dpm) { | ||
@@ -49,17 +49,2 @@ super() | ||
} | ||
get #boundAdd() { | ||
if(this.#_boundAdd !== undefined) { return this.#_boundAdd} | ||
this.#_boundAdd = this.#add.bind(this) | ||
return this.#_boundAdd | ||
} | ||
get #boundChange() { | ||
if(this.#_boundChange !== undefined) { return this.#_boundChange} | ||
this.#_boundChange = this.#change.bind(this) | ||
return this.#_boundChange | ||
} | ||
get #boundUnlink() { | ||
if(this.#_boundUnlink !== undefined) { return this.#_boundUnlink} | ||
this.#_boundUnlink = this.#unlink.bind(this) | ||
return this.#_boundUnlink | ||
} | ||
async #add($path) { | ||
@@ -66,0 +51,0 @@ const addPath = path.join(process.env.PWD, $path) |
import './coutil/persist/index.js' | ||
import recursiveAssign from './coutil/recursiveAssign/index.js' | ||
import path from 'node:path' | ||
@@ -48,3 +49,3 @@ import inspector from 'node:inspector' | ||
this.#settings.server.https, | ||
this.router.expressRouter | ||
this.router.express | ||
) | ||
@@ -74,2 +75,3 @@ this.#server.listen( | ||
if(this.#router !== undefined) { return this.#router } | ||
// if(this.server === undefined) return | ||
this.#router = new Router(this.#settings.router || {}, this) | ||
@@ -81,3 +83,3 @@ return this.#router | ||
if(this.#sockets !== undefined) { return this.#sockets } | ||
if(this.server === undefined) { return undefined } | ||
if(this.#server === undefined) { return undefined } | ||
if(this.#settings.sockets !== undefined) { | ||
@@ -100,18 +102,10 @@ this.#sockets = new Sockets(this.#settings.sockets, this) | ||
if(this.#settings.browserSync === undefined) return | ||
const browserSyncServerOptions = { | ||
ui: false, | ||
open: false, | ||
https: this.#settings.browserSync.https, | ||
host: this.#settings.browserSync.host, | ||
port: this.#settings.browserSync.port, | ||
files: this.#settings.browserSync.files, | ||
const browserSyncServerOptions = recursiveAssign(this.#settings.browserSync, { | ||
proxy: { | ||
target: [ | ||
"https://", | ||
target: "https://".concat( | ||
this.#settings.server.https.host, ":", | ||
this.#settings.server.https.port, | ||
].join(''), | ||
ws: this.#settings.browserSync.proxy.ws, | ||
), | ||
}, | ||
} | ||
}) | ||
this.#browserSync = browserSync.create() | ||
@@ -118,0 +112,0 @@ this.#browserSync.init(browserSyncServerOptions) |
@@ -12,3 +12,3 @@ import path from 'node:path' | ||
#watcher | ||
#_boundPile | ||
#boundPile = this.pile.bind(this) | ||
constructor($settings, $document) { | ||
@@ -78,7 +78,2 @@ super() | ||
} | ||
get #boundPile() { | ||
if(this.#_boundPile !== undefined) { return this.#_boundPile } | ||
this.#_boundPile = this.pile.bind(this) | ||
return this.#_boundPile | ||
} | ||
} |
@@ -8,3 +8,3 @@ import path from 'node:path' | ||
#path | ||
#_boundPile | ||
#boundPile = this.pile.bind(this) | ||
constructor($settings, $document) { | ||
@@ -35,7 +35,2 @@ super() | ||
} | ||
get #boundPile() { | ||
if(this.#_boundPile !== undefined) { return this.#_boundPile } | ||
this.#_boundPile = this.pile.bind(this) | ||
return this.#_boundPile | ||
} | ||
} |
@@ -11,10 +11,13 @@ import path from 'node:path' | ||
#dpm | ||
#expressRouter | ||
#static | ||
#express | ||
#expressRoute | ||
#middlewares | ||
#methods | ||
#errors | ||
#source | ||
#target | ||
#_watcher | ||
#_boundAdd | ||
#_boundChange | ||
#_boundUnlink | ||
#boundAdd = this.#add.bind(this) | ||
#boundChange = this.#change.bind(this) | ||
#boundUnlink = this.#unlink.bind(this) | ||
constructor($settings, $dpm) { | ||
@@ -24,10 +27,17 @@ super() | ||
this.#dpm = $dpm | ||
this.static | ||
this.middlewares | ||
this.methods | ||
this.errors | ||
this.#watcher | ||
} | ||
get expressRouter() { | ||
if(this.#expressRouter !== undefined) { return this.#expressRouter } | ||
this.#expressRouter = express(this.#settings.router || {}) | ||
return this.#expressRouter | ||
get express() { | ||
if(this.#express !== undefined) { return this.#express } | ||
this.#express = express(this.#settings.router || {}) | ||
return this.#express | ||
} | ||
get expressRoute() { | ||
if(this.#expressRoute !== undefined) { return this.#expressRoute } | ||
this.#expressRoute = this.express.route(this.path) | ||
return this.#expressRoute | ||
} | ||
get #config() { return this.#settings.config } | ||
@@ -39,16 +49,73 @@ get source() { | ||
} | ||
get static() { | ||
if(this.#static !== undefined) { return this.#static } | ||
if(this.#settings.static !== undefined) { | ||
const staticElements = [] | ||
for(const [$staticPath, $staticOptions] of this.#settings.static) { | ||
const staticPath = path.join(process.env.PWD, $staticPath) | ||
const staticElement = express.static(staticPath, $staticOptions) | ||
this.expressRouter.use(staticElement) | ||
staticElements.push([staticPath, staticElement]) | ||
get middlewares() { | ||
if(this.#middlewares !== undefined) { return this.#middlewares } | ||
if(this.#settings.middlewares !== undefined) { | ||
const middlewares = [] | ||
for(const $middleware of this.#settings.middlewares) { | ||
let middleware | ||
if($middleware.length === 1 && typeof $middleware === 'function') { | ||
middleware = $middleware[0] | ||
} | ||
else { | ||
const middlewareName = $middleware.splice(0, 1)[0] | ||
const middlewareArguments = $middleware.flat() | ||
if(['json', 'static', 'urlencoded'].includes(middlewareName)) { | ||
middleware = express[middlewareName](...middlewareArguments) | ||
} | ||
else { | ||
middleware = this.express[middlewareName](...middlewareArguments) | ||
} | ||
} | ||
if(middleware) { | ||
this.express.use(this.path, middleware) | ||
middlewares.push(middleware) | ||
} | ||
} | ||
this.#static = staticElements | ||
this.#middlewares = middlewares | ||
} | ||
return this.#static | ||
return this.#middlewares | ||
} | ||
get methods() { | ||
if(this.#methods !== undefined) { return this.#methods } | ||
if(this.#settings.methods !== undefined) { | ||
const methods = [] | ||
for(const [$methodName, $method] of this.#settings.methods) { | ||
const method = this.expressRoute[$methodName]($method) | ||
methods.push(method) | ||
} | ||
this.#methods = methods | ||
} | ||
return this.#methods | ||
} | ||
get errors() { | ||
if(this.#errors !== undefined) { return this.#errors } | ||
if(this.#settings.errors !== undefined) { | ||
const errors = [] | ||
for(const $error of this.#settings.errors) { | ||
let error | ||
if($error.length === 1 && typeof $error === 'function') { | ||
error = $error[0] | ||
this.express.use(this.path, error) | ||
} | ||
errors.push(error) | ||
} | ||
this.#errors = errors | ||
} | ||
return this.#errors | ||
} | ||
// get static() { | ||
// if(this.#static !== undefined) { return this.#static } | ||
// if(this.#settings.static !== undefined) { | ||
// const staticElements = [] | ||
// for(const [$staticPath, $staticOptions] of this.#settings.static) { | ||
// const staticPath = path.join(process.env.PWD, $staticPath) | ||
// const staticElement = express.static(staticPath, $staticOptions) | ||
// this.express.use(staticElement) | ||
// staticElements.push([staticPath, staticElement]) | ||
// } | ||
// this.#static = staticElements | ||
// } | ||
// return this.#static | ||
// } | ||
get #watcher() { | ||
@@ -67,17 +134,2 @@ if(this.#_watcher !== undefined) { return this.#_watcher } | ||
} | ||
get #boundAdd() { | ||
if(this.#_boundAdd !== undefined) { return this.#_boundAdd} | ||
this.#_boundAdd = this.#add.bind(this) | ||
return this.#_boundAdd | ||
} | ||
get #boundChange() { | ||
if(this.#_boundChange !== undefined) { return this.#_boundChange} | ||
this.#_boundChange = this.#change.bind(this) | ||
return this.#_boundChange | ||
} | ||
get #boundUnlink() { | ||
if(this.#_boundUnlink !== undefined) { return this.#_boundUnlink} | ||
this.#_boundUnlink = this.#unlink.bind(this) | ||
return this.#_boundUnlink | ||
} | ||
async #add($path) { | ||
@@ -84,0 +136,0 @@ const routePath = path.join(process.env.PWD, $path) |
@@ -6,6 +6,9 @@ import path from 'node:path' | ||
#router | ||
#expressRouter | ||
#expressRoute | ||
#source | ||
#static | ||
#middlewares | ||
#methods | ||
#errors | ||
#active = false | ||
@@ -18,5 +21,11 @@ constructor($settings, $router) { | ||
} | ||
get expressRouter() { | ||
if(this.#expressRouter !== undefined) { return this.#expressRouter } | ||
this.#expressRouter = express.Router() | ||
this.#router.express.use(this.#expressRouter) | ||
return this.#expressRouter | ||
} | ||
get expressRoute() { | ||
if(this.#expressRoute !== undefined) { return this.#expressRoute } | ||
this.#expressRoute = this.#router.expressRouter.route(this.path) | ||
this.#expressRoute = this.expressRouter.route(this.path) | ||
return this.#expressRoute | ||
@@ -29,3 +38,5 @@ } | ||
this.static | ||
this.middlewares | ||
this.methods | ||
this.errors | ||
} | ||
@@ -36,6 +47,6 @@ else if($active === false) { | ||
let spliceLayers = [] | ||
const { stack } = this.#router.expressRouter._router | ||
const { stack } = this.#router.express._router | ||
for(const $layer of stack) { | ||
if($layer.route) { | ||
if($layer.route.path === this.path) { spliceLayers.push(layerIndex) } | ||
if($layer.name === 'router' && $layer.handle) { | ||
if($layer.handle === this.expressRouter) { spliceLayers.push(layerIndex) } | ||
} | ||
@@ -47,3 +58,3 @@ layerIndex++ | ||
} | ||
this.#static = undefined | ||
this.#middlewares = undefined | ||
this.#methods = undefined | ||
@@ -60,15 +71,29 @@ } | ||
} | ||
get static() { | ||
if(this.#static !== undefined) { return this.#static } | ||
if(this.#settings.static !== undefined) { | ||
const staticElements = [] | ||
for(const [$staticPath, $staticOptions] of this.#settings.static) { | ||
const staticPath = path.join(process.env.PWD, $staticPath) | ||
const staticElement = express.static(staticPath, $staticOptions) | ||
this.#expressRoute.use(staticElement) | ||
staticElements.push([staticPath, staticElement]) | ||
get middlewares() { | ||
if(this.#middlewares !== undefined) { return this.#middlewares } | ||
if(this.#settings.middlewares !== undefined) { | ||
const middlewares = [] | ||
for(const $middleware of this.#settings.middlewares) { | ||
let middleware | ||
if($middleware.length === 1 && typeof $middleware === 'function') { | ||
middleware = $middleware[0] | ||
} | ||
else { | ||
const middlewareName = $middleware.splice(0, 1)[0] | ||
const middlewareArguments = $middleware.flat() | ||
if(['json', 'static', 'urlencoded'].includes(middlewareName)) { | ||
middleware = express[middlewareName](...middlewareArguments) | ||
} | ||
else { | ||
middleware = this.expressRouter[middlewareName](...middlewareArguments) | ||
} | ||
} | ||
if(middleware) { | ||
this.expressRouter.use(this.path, middleware) | ||
middlewares.push(middleware) | ||
} | ||
} | ||
this.#static = staticElements | ||
this.#middlewares = middlewares | ||
} | ||
return this.#static | ||
return this.#middlewares | ||
} | ||
@@ -87,3 +112,18 @@ get methods() { | ||
} | ||
get errors() { | ||
if(this.#errors !== undefined) { return this.#errors } | ||
if(this.#settings.errors !== undefined) { | ||
const errors = [] | ||
for(const $error of this.#settings.errors) { | ||
let error | ||
if($error.length === 1 && typeof $error === 'function') { | ||
error = $error[0] | ||
this.expressRouter.use(this.path, error) | ||
} | ||
errors.push(error) | ||
} | ||
this.#errors = errors | ||
} | ||
return this.#errors | ||
} | ||
} |
@@ -15,13 +15,9 @@ import path from 'node:path' | ||
#target | ||
#boundAdd | ||
#boundChange | ||
#boundUnlink | ||
#boundServerUpgrade | ||
#boundServerUpgrade = this.#serverUpgrade.bind(this) | ||
#boundAdd = this.#add.bind(this) | ||
#boundChange = this.#change.bind(this) | ||
#boundUnlink = this.#unlink.bind(this) | ||
#_watcher | ||
constructor($settings, $dpm) { | ||
super() | ||
this.#boundServerUpgrade = this.#serverUpgrade.bind(this) | ||
this.#boundAdd = this.#add.bind(this) | ||
this.#boundChange = this.#change.bind(this) | ||
this.#boundUnlink = this.#unlink.bind(this) | ||
this.#settings = $settings | ||
@@ -28,0 +24,0 @@ this.#dpm = $dpm |
@@ -17,12 +17,8 @@ import { URL } from 'node:url' | ||
#_webSocketError | ||
#boundWebSocketMessage | ||
#boundWebSocketServerConnection | ||
#boundWebSocketServerClose | ||
#boundWebSocketServerError | ||
#boundWebSocketServerConnection = this.#webSocketServerConnection.bind(this) | ||
#boundWebSocketServerClose = this.#webSocketServerClose.bind(this) | ||
#boundWebSocketServerError = this.#webSocketServerError.bind(this) | ||
#boundWebSocketMessage = this.#webSocketMessage.bind(this) | ||
constructor($settings, $sockets) { | ||
super() | ||
this.#boundWebSocketServerConnection = this.#webSocketServerConnection.bind(this) | ||
this.#boundWebSocketServerClose = this.#webSocketServerClose.bind(this) | ||
this.#boundWebSocketServerError = this.#webSocketServerError.bind(this) | ||
this.#boundWebSocketMessage = this.#webSocketMessage.bind(this) | ||
this.#settings = $settings | ||
@@ -29,0 +25,0 @@ this.#sockets = $sockets |
@@ -5,3 +5,3 @@ { | ||
"description": "Document Process Manager (DPM)", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"license": "ISC", | ||
@@ -8,0 +8,0 @@ "type": "module", |
@@ -11,3 +11,21 @@ > [!WARNING] | ||
# Document Process Manager | ||
Early Bird Gets The Wormhole | ||
# Document Process Manager (DPM) | ||
Document Process Manager ministrates web projects: | ||
- Document (Markup Piler, Style Piler, Script Piler, etc.) | ||
- [EJS](https://www.npmjs.com/package/ejs) Markup Piler | ||
- [SASS](https://www.npmjs.com/package/sass) Style Piler | ||
- [Rollup](https://www.npmjs.com/package/rollup) Script Piler | ||
- Server (HTTP/HTTPS, WebSocket, Inspector) | ||
- Node [HTTP](https://nodejs.org/api/http.html) | ||
- Node [HTTPS](https://nodejs.org/api/https.html) | ||
- Router | ||
- [Express](https://www.npmjs.com/package/express) | ||
- Web Sockets | ||
- [WS](https://www.npmjs.com/package/ws) | ||
- Web Browser | ||
- [BrowserSync](https://www.npmjs.com/package/browser-sync) | ||
- Node [Inspector](https://nodejs.org/api/inspector.html) | ||
## Guide | ||
- [Setup](./document/guide/setup/index.md) | ||
- [Configuration](./document/guide/configuration/index.md) |
76757
58
1683
30
21