mwalajs 1.0.1
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/.env +5 -0
- package/LICENSE +21 -0
- package/README.md +542 -0
- package/app.mjs +23 -0
- package/bin/backupnewclean.js +162 -0
- package/bin/mwala.mjs +176 -0
- package/config/createTablesetdb.mjs +38 -0
- package/config/createdatabase.mjs +157 -0
- package/config/serverConfig.mjs +1 -0
- package/controllers/fileController.mjs +15 -0
- package/controllers/homeController.mjs +28 -0
- package/createProject.mjs +120 -0
- package/migrations/20250308115724_create_users.mjs +45 -0
- package/migrations/20250724111240_create_transactions.mjs +19 -0
- package/migrations/migration_log.json +1 -0
- package/models/exampleModel.mjs +5 -0
- package/mwala +5 -0
- package/mwala.cmd +2 -0
- package/mwalajs/index.js +109 -0
- package/mwalajs/index.mjs +121 -0
- package/mwalajs/package-lock.json +836 -0
- package/mwalajs/package.json +16 -0
- package/package.json +58 -0
- package/public/styles.css +115 -0
- package/routes/homeRoutes.mjs +12 -0
- package/runMigrations.mjs +137 -0
- package/setupMwalajs.mjs +58 -0
- package/ujasi/README.md +542 -0
- package/ujasi/app.mjs +33 -0
- package/ujasi/bin/backupnewclean.js +162 -0
- package/ujasi/bin/mwala.mjs +176 -0
- package/ujasi/config/createTablesetdb.mjs +38 -0
- package/ujasi/config/createdatabase.mjs +156 -0
- package/ujasi/config/serverConfig.mjs +1 -0
- package/ujasi/controllers/fileController.mjs +15 -0
- package/ujasi/controllers/homeController.mjs +28 -0
- package/ujasi/models/exampleModel.mjs +5 -0
- package/ujasi/mwalajs/index.js +109 -0
- package/ujasi/mwalajs/index.mjs +121 -0
- package/ujasi/mwalajs/package-lock.json +836 -0
- package/ujasi/mwalajs/package.json +16 -0
- package/ujasi/package-lock.json +8546 -0
- package/ujasi/package.json +58 -0
- package/ujasi/public/styles.css +115 -0
- package/ujasi/routes/homeRoutes.mjs +12 -0
- package/ujasi/runMigrations.mjs +137 -0
- package/ujasi/setupMwalajs.mjs +58 -0
- package/ujasi/views/about.ejs +159 -0
- package/ujasi/views/index.ejs +227 -0
- package/ujasi/views/sitemap.xml +1 -0
- package/ujasi/views/steps.ejs +514 -0
- package/ujasi/views/welcome.ejs +257 -0
- package/views/about.ejs +159 -0
- package/views/index.ejs +227 -0
- package/views/sitemap.xml +1 -0
- package/views/steps.ejs +514 -0
- package/views/welcome.ejs +257 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { sequelize } from '../config/createTablesetdb.mjs';
|
|
3
|
+
import { DataTypes } from 'sequelize';
|
|
4
|
+
|
|
5
|
+
export const up = async () => {
|
|
6
|
+
await sequelize.getQueryInterface().createTable('users', {
|
|
7
|
+
id: {
|
|
8
|
+
type: DataTypes.INTEGER,
|
|
9
|
+
autoIncrement: true,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
allowNull: false
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
name: {
|
|
15
|
+
type: DataTypes.STRING,
|
|
16
|
+
allowNull: false
|
|
17
|
+
},
|
|
18
|
+
email: {
|
|
19
|
+
type: DataTypes.STRING,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
unique: true
|
|
22
|
+
},
|
|
23
|
+
password: {
|
|
24
|
+
type: DataTypes.STRING,
|
|
25
|
+
allowNull: false
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
createdAt: {
|
|
29
|
+
type: DataTypes.DATE,
|
|
30
|
+
allowNull: false,
|
|
31
|
+
defaultValue: new Date()
|
|
32
|
+
},
|
|
33
|
+
updatedAt: {
|
|
34
|
+
type: DataTypes.DATE,
|
|
35
|
+
allowNull: false,
|
|
36
|
+
defaultValue: new Date()
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
console.log("✅ Table 'users' has been created.");
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const down = async () => {
|
|
43
|
+
await sequelize.getQueryInterface().dropTable('users');
|
|
44
|
+
console.log("❌ Table 'users' has been dropped.");
|
|
45
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { sequelize } from '../config/createTablesetdb.mjs';
|
|
2
|
+
import { DataTypes } from 'sequelize';
|
|
3
|
+
|
|
4
|
+
export const up = async () => {
|
|
5
|
+
await sequelize.getQueryInterface().createTable('transactions', {
|
|
6
|
+
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true, allowNull: false },
|
|
7
|
+
transactionName: { type: DataTypes.STRING, allowNull: false },
|
|
8
|
+
amount: { type: DataTypes.STRING, allowNull: false, unique: true },
|
|
9
|
+
password: { type: DataTypes.STRING, allowNull: false },
|
|
10
|
+
userId: { type: DataTypes.INTEGER, allowNull: true },
|
|
11
|
+
address: { type: DataTypes.STRING, allowNull: true },
|
|
12
|
+
createdAt: { type: DataTypes.DATE, allowNull: false, defaultValue: new Date() },
|
|
13
|
+
updatedAt: { type: DataTypes.DATE, allowNull: false, defaultValue: new Date() }
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const down = async () => {
|
|
18
|
+
await sequelize.getQueryInterface().dropTable('transactions');
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["20250308115724_create_users.mjs","20250724111240_create_transactions.mjs"]
|
package/mwala
ADDED
package/mwala.cmd
ADDED
package/mwalajs/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
|
|
3
|
+
class Mwala {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.app = express();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Set application settings
|
|
9
|
+
set(setting, value) {
|
|
10
|
+
this.app.set(setting, value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Accept multiple middlewares or (path, middleware)
|
|
14
|
+
use(...args) {
|
|
15
|
+
this.app.use(...args);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Serve static files
|
|
19
|
+
useStatic(dirPath) {
|
|
20
|
+
this.app.use(express.static(dirPath));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Route methods
|
|
24
|
+
get(...args) {
|
|
25
|
+
this.app.get(...args);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
post(...args) {
|
|
29
|
+
this.app.post(...args);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
put(...args) {
|
|
33
|
+
this.app.put(...args);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
delete(...args) {
|
|
37
|
+
this.app.delete(...args);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
listen(port, callback) {
|
|
41
|
+
this.app.listen(port, callback);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Router() {
|
|
45
|
+
return express.Router();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Built-in body parsers
|
|
49
|
+
json() {
|
|
50
|
+
return express.json();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
urlencoded(options = { extended: true }) {
|
|
54
|
+
return express.urlencoded(options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Async external middlewares
|
|
58
|
+
async session(options) {
|
|
59
|
+
const { default: session } = await import('express-session');
|
|
60
|
+
return session(options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async cookieParser(secret) {
|
|
64
|
+
const { default: cookieParser } = await import('cookie-parser');
|
|
65
|
+
return cookieParser(secret);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async helmet(options) {
|
|
69
|
+
const { default: helmet } = await import('helmet');
|
|
70
|
+
return helmet(options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async compress(options) {
|
|
74
|
+
const { default: compression } = await import('compression');
|
|
75
|
+
return compression(options);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async morgan(format) {
|
|
79
|
+
const { default: morgan } = await import('morgan');
|
|
80
|
+
return morgan(format);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async override(method) {
|
|
84
|
+
const { default: methodOverride } = await import('method-override');
|
|
85
|
+
return methodOverride(method);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async cors(options) {
|
|
89
|
+
const { default: cors } = await import('cors');
|
|
90
|
+
return cors(options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async rateLimit(options) {
|
|
94
|
+
const { default: rateLimit } = await import('express-rate-limit');
|
|
95
|
+
return rateLimit(options);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async bodyParserJson() {
|
|
99
|
+
const { default: bodyParser } = await import('body-parser');
|
|
100
|
+
return bodyParser.json();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async bodyParserUrlencoded(options = { extended: true }) {
|
|
104
|
+
const { default: bodyParser } = await import('body-parser');
|
|
105
|
+
return bodyParser.urlencoded(options);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default new Mwala();
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
|
|
3
|
+
class Mwala {
|
|
4
|
+
// ... constructor, set, use, etc.
|
|
5
|
+
constructor() {
|
|
6
|
+
this.app = express();
|
|
7
|
+
this.settings = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set(setting, value) {
|
|
11
|
+
this.settings[setting] = value;
|
|
12
|
+
this.app.set(setting, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
use(route, handler) {
|
|
16
|
+
if (typeof route === 'string') {
|
|
17
|
+
this.app.use(route, handler);
|
|
18
|
+
} else {
|
|
19
|
+
this.app.use(route);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static(pathDir) {
|
|
24
|
+
this.app.use(express.static(pathDir));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
listen(port, callback) {
|
|
28
|
+
this.app.listen(port, callback);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Router() {
|
|
32
|
+
return express.Router();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// ADD THESE METHODS to support GET/POST/PUT/DELETE
|
|
37
|
+
get(path, handler) {
|
|
38
|
+
this.app.get(path, handler);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
post(path, handler) {
|
|
42
|
+
this.app.post(path, handler);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
put(path, handler) {
|
|
46
|
+
this.app.put(path, handler);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
delete(path, handler) {
|
|
50
|
+
this.app.delete(path, handler);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ✅ Proxy core express middleware
|
|
54
|
+
json() {
|
|
55
|
+
return express.json();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
urlencoded(options) {
|
|
59
|
+
return express.urlencoded(options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
raw(options) {
|
|
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
|
+
|
|
75
|
+
async session(options) {
|
|
76
|
+
const { default: session } = await import('express-session');
|
|
77
|
+
return session(options);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async morgan(format) {
|
|
81
|
+
const { default: morgan } = await import('morgan');
|
|
82
|
+
return morgan(format);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async helmet(options) {
|
|
86
|
+
const { default: helmet } = await import('helmet');
|
|
87
|
+
return helmet(options);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async compress(options) {
|
|
91
|
+
const { default: compression } = await import('compression');
|
|
92
|
+
return compression(options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async override(method) {
|
|
96
|
+
const { default: methodOverride } = await import('method-override');
|
|
97
|
+
return methodOverride(method);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async cors(options) {
|
|
101
|
+
const { default: cors } = await import('cors');
|
|
102
|
+
return cors(options);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async rateLimit(options) {
|
|
106
|
+
const { default: rateLimit } = await import('express-rate-limit');
|
|
107
|
+
return rateLimit(options);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async bodyParserJson() {
|
|
111
|
+
const { default: bodyParser } = await import('body-parser');
|
|
112
|
+
return bodyParser.json();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async bodyParserUrlencoded(options) {
|
|
116
|
+
const { default: bodyParser } = await import('body-parser');
|
|
117
|
+
return bodyParser.urlencoded(options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default new Mwala();
|