mwalajs 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/bin/mwala.mjs +2 -1
- package/index.mjs +32 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -539,4 +539,7 @@ Click below to download rar file mwalajs framework :
|
|
|
539
539
|
|
|
540
540
|
|
|
541
541
|
git clone https://github.com/mwala400/mwalajs.git
|
|
542
|
+

|
|
543
|
+

|
|
544
|
+

|
|
542
545
|
|
package/bin/mwala.mjs
CHANGED
|
@@ -53,8 +53,9 @@ if (!command || command === 'help' || command === 'h') {
|
|
|
53
53
|
switch (command) {
|
|
54
54
|
case 'version':
|
|
55
55
|
case '-v':
|
|
56
|
+
case 'v':
|
|
56
57
|
case '--version':
|
|
57
|
-
console.log('MwalaJS Version: 1.0.
|
|
58
|
+
console.log('MwalaJS Version: 1.0.4');
|
|
58
59
|
process.exit(0);
|
|
59
60
|
|
|
60
61
|
case 'create-project':
|
package/index.mjs
CHANGED
|
@@ -1,85 +1,68 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
|
|
3
3
|
class Mwala {
|
|
4
|
-
// ... constructor, set, use, etc.
|
|
5
4
|
constructor() {
|
|
6
5
|
this.app = express();
|
|
7
|
-
this.settings = {};
|
|
8
6
|
}
|
|
9
7
|
|
|
8
|
+
// Set application settings
|
|
10
9
|
set(setting, value) {
|
|
11
|
-
this.settings[setting] = value;
|
|
12
10
|
this.app.set(setting, value);
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} else {
|
|
19
|
-
this.app.use(route);
|
|
20
|
-
}
|
|
13
|
+
// Accept multiple middlewares or (path, middleware)
|
|
14
|
+
use(...args) {
|
|
15
|
+
this.app.use(...args);
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
static
|
|
24
|
-
|
|
18
|
+
// Serve static files
|
|
19
|
+
useStatic(dirPath) {
|
|
20
|
+
this.app.use(express.static(dirPath));
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
// Route methods
|
|
24
|
+
get(...args) {
|
|
25
|
+
this.app.get(...args);
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
post(...args) {
|
|
29
|
+
this.app.post(...args);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
get(path, handler) {
|
|
38
|
-
this.app.get(path, handler);
|
|
32
|
+
put(...args) {
|
|
33
|
+
this.app.put(...args);
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
this.app.
|
|
36
|
+
delete(...args) {
|
|
37
|
+
this.app.delete(...args);
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
this.app.
|
|
40
|
+
listen(port, callback) {
|
|
41
|
+
this.app.listen(port, callback);
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
Router() {
|
|
45
|
+
return express.Router();
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
//
|
|
48
|
+
// Built-in body parsers
|
|
54
49
|
json() {
|
|
55
50
|
return express.json();
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
urlencoded(options) {
|
|
53
|
+
urlencoded(options = { extended: true }) {
|
|
59
54
|
return express.urlencoded(options);
|
|
60
55
|
}
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
return express.raw(options);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
text(options) {
|
|
67
|
-
return express.text(options);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async cookieParser(secret) {
|
|
71
|
-
const { default: cookieParser } = await import('cookie-parser');
|
|
72
|
-
return cookieParser(secret);
|
|
73
|
-
}
|
|
74
|
-
|
|
57
|
+
// Async external middlewares
|
|
75
58
|
async session(options) {
|
|
76
59
|
const { default: session } = await import('express-session');
|
|
77
60
|
return session(options);
|
|
78
61
|
}
|
|
79
62
|
|
|
80
|
-
async
|
|
81
|
-
const { default:
|
|
82
|
-
return
|
|
63
|
+
async cookieParser(secret) {
|
|
64
|
+
const { default: cookieParser } = await import('cookie-parser');
|
|
65
|
+
return cookieParser(secret);
|
|
83
66
|
}
|
|
84
67
|
|
|
85
68
|
async helmet(options) {
|
|
@@ -92,6 +75,11 @@ class Mwala {
|
|
|
92
75
|
return compression(options);
|
|
93
76
|
}
|
|
94
77
|
|
|
78
|
+
async morgan(format) {
|
|
79
|
+
const { default: morgan } = await import('morgan');
|
|
80
|
+
return morgan(format);
|
|
81
|
+
}
|
|
82
|
+
|
|
95
83
|
async override(method) {
|
|
96
84
|
const { default: methodOverride } = await import('method-override');
|
|
97
85
|
return methodOverride(method);
|
|
@@ -112,7 +100,7 @@ class Mwala {
|
|
|
112
100
|
return bodyParser.json();
|
|
113
101
|
}
|
|
114
102
|
|
|
115
|
-
async bodyParserUrlencoded(options) {
|
|
103
|
+
async bodyParserUrlencoded(options = { extended: true }) {
|
|
116
104
|
const { default: bodyParser } = await import('body-parser');
|
|
117
105
|
return bodyParser.urlencoded(options);
|
|
118
106
|
}
|