js-mvc-framework
Advanced tools
Comparing version 1.5.3 to 1.5.5
@@ -7,7 +7,13 @@ export default { | ||
target: 'localhost', | ||
middlewares: [ | ||
['json', [{}]], | ||
['static', ['static', {}]], | ||
['static', ['localhost', {}]], | ||
], | ||
methods: [ | ||
['get', function getIndex($request, $response, $next) { | ||
['get', function getIndex($request, $response) { | ||
$response.send("HELLO ALL DOGS") | ||
}] | ||
], | ||
errors: [], | ||
} |
@@ -7,2 +7,7 @@ export default { | ||
target: 'localhost/test', | ||
middlewares: [ | ||
// $path, $options | ||
['static', ['static', {}]], | ||
['static', ['localhost', {}]], | ||
], | ||
methods: [ | ||
@@ -9,0 +14,0 @@ ['get', function getIndex($request, $response, $next) { |
@@ -67,4 +67,3 @@ import Test from '../../test/index.js' | ||
const testPath = [testGroup.path, $testID].join('/') | ||
// const | ||
const testVerification = new Test($testSettings) | ||
const testVerification = new Test(testSettings) | ||
if(testVerification.method.constructor.name === 'AsyncFunction') { | ||
@@ -71,0 +70,0 @@ await testVerification.asyncExecute() |
export default class Test extends EventTarget { | ||
#settings | ||
#_method | ||
#_boundMethod | ||
#_detail | ||
#_pass | ||
#method | ||
#detail | ||
#pass | ||
#boundMethod | ||
constructor($settings) { | ||
super() | ||
console.log($settings) | ||
this.#settings = $settings | ||
this.#boundMethod = this.method.bind(this) | ||
} | ||
@@ -17,23 +19,18 @@ get id() { return this.#settings.id } | ||
get collect() { return this.#settings.collect } | ||
get detail() { return this.#_detail } | ||
get detail() { return this.#detail } | ||
set detail($detail) { | ||
if(this.#_detail !== undefined) return | ||
this.#_detail = $detail | ||
if(this.#detail !== undefined) return | ||
this.#detail = $detail | ||
} | ||
get pass() { return this.#_pass } | ||
get pass() { return this.#pass } | ||
set pass($pass) { | ||
if(this.#_pass !== undefined) return | ||
this.#_pass = $pass | ||
if(this.#pass !== undefined) return | ||
this.#pass = $pass | ||
} | ||
get async() { return this.#settings.async } | ||
get method() { | ||
if(this.#_method !== undefined) return this.#_method | ||
this.#_method = this.#settings.method | ||
return this.#_method | ||
if(this.#method !== undefined) return this.#method | ||
this.#method = this.#settings.method | ||
return this.#method | ||
} | ||
get #boundMethod() { | ||
if(this.#_boundMethod !== undefined) return this.#_boundMethod | ||
this.#_boundMethod = this.method.bind(this) | ||
return this.#_boundMethod | ||
} | ||
execute() { | ||
@@ -40,0 +37,0 @@ if(this.pass !== undefined) return this |
export default { | ||
active: false, | ||
active: true, | ||
name: 'Test | Content', | ||
@@ -35,2 +35,6 @@ path: '/test/content', | ||
ignore: [], | ||
inputOptions: {}, | ||
outputOptions: { | ||
sourceMap: true, | ||
}, | ||
}], | ||
@@ -40,4 +44,2 @@ scripts: [{ | ||
type: 'scripts', | ||
input: 'index.js', | ||
output: 'index.js', | ||
watch: [ | ||
@@ -53,3 +55,12 @@ '**/*.js', | ||
], | ||
external: ['/dependencies/mvc-framework.js'] | ||
input: 'index.js', | ||
output: 'index.js', | ||
inputOptions: { | ||
logLevel: 'silent', | ||
external: ['/dependencies/mvc-framework.js'] | ||
}, | ||
outputOptions: { | ||
format: 'es', | ||
sourcemap: true, | ||
}, | ||
}], | ||
@@ -59,20 +70,26 @@ structs: [{ | ||
type: 'structs', | ||
localsName: '$content', | ||
outputType: 'server', | ||
model: 'index.json', | ||
watch: ['**/*.{ejs,json}'], | ||
ignore: ['**/$*.ejs'], | ||
input: 'index.ejs', | ||
output: 'index.html', | ||
watch: ['**/*.{ejs,json}'], | ||
ignore: ['**/\$*.ejs'], | ||
outputOptions: { | ||
localsName: '$content', | ||
root: ['templates'], | ||
}, | ||
}, { | ||
name: 'EJSPiler', | ||
type: 'structs', | ||
localsName: '$content', | ||
outputType: 'client', | ||
watch: ['**/$*.ejs'], | ||
ignore: [], | ||
input: '**/*.ejs', | ||
output: '', | ||
watch: ['**/\$*.ejs'], | ||
ignore: [], | ||
outputOptions: { | ||
localsName: '$content', | ||
root: [''], | ||
}, | ||
}], | ||
} | ||
} |
export default { | ||
active: true, | ||
active: false, | ||
name: 'Test | Draft 6', | ||
@@ -7,7 +7,11 @@ path: '/test/draft/6', | ||
target: 'localhost/test/draft/6', | ||
middlewares: [ | ||
['static', ['static', {}]], | ||
['static', ['localhost', {}]], | ||
], | ||
methods: [ | ||
// ['get', function getIndex($request, $response, $next) { | ||
// $response.send("HELLO ALL DOGS") | ||
// }] | ||
['get', function getIndex($request, $response, $next) { | ||
$response.send("HELLO ALL DOGS") | ||
}] | ||
], | ||
} |
export default { | ||
active: true, | ||
active: false, | ||
name: 'Test | Schema', | ||
@@ -7,4 +7,10 @@ path: '/test/schema', | ||
target: 'localhost/test/schema', | ||
middlewares: [ | ||
// $path, $options | ||
['static', ['static', {}]], | ||
['static', ['localhost', {}]], | ||
], | ||
methods: [ | ||
['get', function getIndex($request, $response, $next) { | ||
console.log($request) | ||
$response.send("HELLO ALL DOGS") | ||
@@ -11,0 +17,0 @@ }] |
@@ -9,4 +9,8 @@ { | ||
"scripts": { | ||
"start": "nodemon --config nodemon.config.json" | ||
"start": "pm2 start ecosystem.config.cjs", | ||
"restart": "pm2 restart ecosystem.config.cjs", | ||
"stop": "pm2 stop ecosystem.config.cjs", | ||
"delete": "pm2 delete ecosystem.config.cjs", | ||
"dfc:documents": "dfc --config \"./dfc.documents.json\"" | ||
} | ||
} |
@@ -9,3 +9,6 @@ { | ||
"scripts": { | ||
"start": "nodemon --config nodemon.config.json", | ||
"start": "npx pm2 start ecosystem.config.cjs", | ||
"restart": "npx pm2 restart ecosystem.config.cjs", | ||
"stop": "npx pm2 stop ecosystem.config.cjs", | ||
"delete": "npx pm2 delete ecosystem.config.cjs", | ||
"distribute": "rollup --config ./rollup.config.js" | ||
@@ -15,4 +18,4 @@ }, | ||
"@rollup/plugin-commonjs": "^28.0.1", | ||
"nodemon": "^3.1.7", | ||
"rollup": "^4.28.1" | ||
"@rollup/plugin-node-resolve": "^16.0.0", | ||
"rollup": "^4.34.6" | ||
}, | ||
@@ -19,0 +22,0 @@ "dependencies": { |
import commonjs from '@rollup/plugin-commonjs' | ||
import nodeResolve from '@rollup/plugin-node-resolve' | ||
export default { | ||
@@ -16,5 +17,6 @@ input: './index.js', | ||
], | ||
plugins: [commonjs({ | ||
transformMixedEsModules: true | ||
})] | ||
plugins: [ | ||
commonjs({ transformMixedEsModules: true }), | ||
nodeResolve(), | ||
] | ||
} |
@@ -1,2 +0,2 @@ | ||
import { match } from '../../../../node_modules/path-to-regexp/dist/index.js' | ||
import { match } from 'path-to-regexp' | ||
export default class Route extends EventTarget { | ||
@@ -3,0 +3,0 @@ #_settings |
# Socket Router Guide | ||
**MVC Framework \| Guide \| *Socket Router*** | ||
Socket Router facilitates Message Event routing through specialized Socket Message Adapters. | ||
Socket Router facilitates Socket Message Event routing through specialized Socket Message Adapters. | ||
## Socket Message Adapter | ||
``` | ||
import { MessageAdapter } from '/dependencies/mvc-framework.js' | ||
const RESTAdapter = new MessageAdapter({ | ||
name: 'RESTAdapter', | ||
message: function message($event, $isBinary) { | ||
const { data } = $event | ||
try { | ||
const [$type, $detail] = [].concat(JSON.parse(stringifyBuffer(data))) | ||
if(this.messages.includes(type)) { return { type: $type, detail: $detail } } | ||
} | ||
catch($err) { console.log($err) } | ||
}, | ||
messages: ['get', 'post', 'delete'], | ||
}) | ||
``` | ||
## Socket Router | ||
``` | ||
const { webSocket } = new SocketRouter({ | ||
active: true, | ||
name: 'Some Socket Name', | ||
protocol: "wss:", | ||
port: 8000, | ||
host: "some.host.name", | ||
path: '/some/path', | ||
}) | ||
``` | ||
## Socket Router With Message Adapter | ||
``` | ||
const socket = new SocketRouter({ | ||
active: true, | ||
name: 'Some Socket Name', | ||
protocol: "wss:", | ||
port: 8000, | ||
host: "some.host.name", | ||
path: '/some/path', | ||
messageAdapters: [RESTAdapter], | ||
events: { | ||
'webSocket open': function openWebSocket($event) { | ||
this.send('get') | ||
}, | ||
'webSocket get': function getWebSocket($event) { | ||
console.log($event) | ||
}, | ||
}, | ||
}) | ||
``` | ||
## Socket Router Without Message Adapter | ||
``` | ||
const socket = new SocketRouter({ | ||
active: true, | ||
name: 'Some Socket Name', | ||
protocol: "wss:", | ||
port: 8000, | ||
host: "some.host.name", | ||
path: '/some/path', | ||
events: { | ||
'webSocket open': function webSocketOpen($event) { | ||
this.send('get') | ||
}, | ||
'webSocket message': function webSocketOessage($event) { | ||
this.send('get') | ||
}, | ||
'webSocket error': function webSocketOrror($event) { | ||
this.send('get') | ||
}, | ||
'webSocket close': function webSocketOlose($event) { | ||
this.send('get') | ||
}, | ||
}, | ||
}) | ||
``` |
{ | ||
"name": "js-mvc-framework", | ||
"author": "Thomas Patrick Welborn", | ||
"version": "1.5.3", | ||
"version": "1.5.5", | ||
"type": "module", | ||
"scripts": { | ||
"demonstrate": "concurrently \"npm run start --workspace development\" \"npm run start --workspace demonstrament\"", | ||
"develop": "npm run start --workspace development", | ||
"demonstrate:start": "concurrently \"npm run start --workspace development\" \"npm run start --workspace demonstrament\"", | ||
"demonstrate:restart": "concurrently \"npm run restart --workspace development\" \"npm run restart --workspace demonstrament\"", | ||
"demonstrate:stop": "concurrently \"npm run stop --workspace development\" \"npm run stop --workspace demonstrament\"", | ||
"demonstrate:delete": "concurrently \"npm run delete --workspace development\" \"npm run delete --workspace demonstrament\"", | ||
"develop:start": "npm run start --workspace development", | ||
"develop:restart": "npm run restart --workspace development", | ||
"develop:stop": "npm run stop --workspace development", | ||
"develop:delete": "npm run delete --workspace development", | ||
"distribute": "npm run distribute --workspace development" | ||
@@ -20,4 +26,5 @@ }, | ||
"devDependencies": { | ||
"concurrently": "^9.0.1" | ||
"concurrently": "^9.0.1", | ||
"pm2": "^5.4.3" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2468315
375
26213
2