mwalajs 1.0.3 → 1.0.5

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 CHANGED
@@ -77,6 +77,59 @@ mwala serve
77
77
  ### app.mjs
78
78
  Here is an example of the default `app.mjs` file for starting the server:
79
79
 
80
+
81
+ git clone https://github.com/mwala400/mwalajs.git
82
+ ![npm version](https://img.shields.io/npm/v/mwalajs)
83
+ ![GitHub issues](https://img.shields.io/github/issues/mwala400/mwalajs)
84
+ ![License](https://img.shields.io/github/license/mwala400/mwalajs)
85
+ # MwalaJS Framework
86
+
87
+ MwalaJS is a modern CLI tool and web framework built on top of Javascript,Node.js and Express.js for powerful and fast backend and frontend development. It simplifies creating MVC applications, managing databases, and generating code scaffolding.
88
+
89
+ ---
90
+
91
+ ## Table of Contents
92
+
93
+ - [Features](#features)
94
+ - [Requirements](#requirements)
95
+ - [Installation](#installation)
96
+ - [Setup](#setup)
97
+ - [Usage](#usage)
98
+ - [CLI Commands](#cli-commands)
99
+ - [Project Structure](#project-structure)
100
+ - [Contributing](#contributing)
101
+ - [License](#license)
102
+
103
+ ---
104
+
105
+ ## Features
106
+
107
+ - Lightweight Express.js wrapper with MVC pattern
108
+ - CLI tool for project scaffolding and database management
109
+ - Support for multiple databases: MongoDB, MySQL, PostgreSQL, SQLite
110
+ - Built-in middleware integration (session, cors, helmet, compression)
111
+ - Easy static file serving and routing
112
+ - Code generation for models, controllers, routes, views, and middleware
113
+ - Migration support for database schema changes
114
+
115
+ ---
116
+
117
+ ## Requirements
118
+
119
+ - Node.js v18 or higher
120
+ - npm (comes with Node.js)
121
+ - Supported databases (MongoDB, MySQL, PostgreSQL, SQLite) installed and configured
122
+
123
+ ---
124
+
125
+ ## Installation
126
+
127
+ Install MwalaJS globally via npm:
128
+
129
+ ```bash
130
+ npm install -g mwalajs
131
+
132
+
80
133
  ```javascript
81
134
  import mwalajs from 'mwalajs';
82
135
  import { homeRoutes } from './routes/homeRoutes.mjs';
@@ -89,7 +142,7 @@ const __dirname = path.dirname(__filename);
89
142
  mwalajs.set('view engine', 'ejs');
90
143
  mwalajs.set('views', path.join(__dirname, 'views'));
91
144
 
92
- mwalajs.static(path.join(__dirname, 'public'));
145
+ mwalajs.useStatic(path.join(__dirname, 'public'));
93
146
 
94
147
  mwalajs.use('/', homeRoutes);
95
148
 
@@ -106,7 +159,7 @@ Here is an example of the default `homeRoutes.mjs` file:
106
159
  import mwalajs from 'mwalajs';
107
160
  import { homeController, Steps, welcome, about } from '../controllers/homeController.mjs';
108
161
 
109
- const router = mwalajs.constructor.Router();
162
+ const router = mwalajs.Router();
110
163
 
111
164
  router.get('/', homeController.getHomePage);
112
165
  router.get('/steps', Steps.getSteps);
@@ -154,8 +207,8 @@ export const about = {
154
207
  - `mwala help` | `mwala h` → Show this help message.
155
208
 
156
209
  #### Project Management:
157
- - `mwala create-project <name>` → Create a new MwalaJS project.
158
- - `mwala init` → Initialize MwalaJS in the current project.
210
+ - `mwala create-project ` → Create a new MwalaJS project Then will request project name.
211
+ - `mwala init` → Initialize MwalaJS in the current project I N OLD VERSION .
159
212
 
160
213
  #### Running the Application:
161
214
  - `mwala serve` | `mwala app.mjs` → Start the MwalaJS application.
@@ -188,7 +241,7 @@ Clone the repository from GitHub:
188
241
 
189
242
  git clone https://github.com/mwala400/mwalajs.git
190
243
 
191
- Using a ZIP, EXE, or RAR File
244
+ Using a ZIP, EXE, or RAR File
192
245
  Download and extract the files from the available compressed format:
193
246
 
194
247
  ZIP: Extract using WinRAR or 7-Zip.
@@ -208,9 +261,9 @@ Click below to download rar file mwalajs framework :
208
261
 
209
262
 
210
263
 
211
- 2. Setting Up MwalaJS
264
+ 2. Setting Up MwalaJS if installed through .exe,zip or rar
212
265
  Initialize MwalaJS
213
- mwala init
266
+ mwala init
214
267
  Creating a New Project
215
268
  mwala create-project
216
269
  3. Running the Application
@@ -366,8 +419,8 @@ Summary of MwalaJS Commands
366
419
  🔹 To execute a command, use:
367
420
  mwala
368
421
 
369
- mwalajsm/ # Root directory
370
- mwalajsm/ # Root directory
422
+ mwalajs/ # Root directory
423
+ mwalajs/ # Root directory
371
424
  │── app.mjs # Main application file
372
425
  │── runMigrations.mjs # Handles database migrations
373
426
  │── createProject.mjs # Script for creating new projects
@@ -447,7 +500,7 @@ Your MwalaJS file structure is well-organized, but to make it more convincing fo
447
500
  Here’s a structured breakdown:
448
501
  FOLDERS
449
502
 
450
- -- mwalajsm/ # Root directory
503
+ -- mwalajs/ # Root directory
451
504
  │── app.mjs # Main application entry point
452
505
  │── ATTENDANCE/ # Attendance-related files (clarify purpose)
453
506
  │── bin/ # Executable scripts
@@ -536,7 +589,3 @@ Click below to download zip file mwalajs framework:
536
589
 
537
590
 
538
591
  Click below to download rar file mwalajs framework :
539
-
540
-
541
- git clone https://github.com/mwala400/mwalajs.git
542
-
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.1');
58
+ console.log('MwalaJS Version: 1.0.5');
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
- use(route, handler) {
16
- if (typeof route === 'string') {
17
- this.app.use(route, handler);
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(pathDir) {
24
- this.app.use(express.static(pathDir));
18
+ // Serve static files
19
+ useStatic(dirPath) {
20
+ this.app.use(express.static(dirPath));
25
21
  }
26
22
 
27
- listen(port, callback) {
28
- this.app.listen(port, callback);
23
+ // Route methods
24
+ get(...args) {
25
+ this.app.get(...args);
29
26
  }
30
27
 
31
- Router() {
32
- return express.Router();
28
+ post(...args) {
29
+ this.app.post(...args);
33
30
  }
34
31
 
35
-
36
- // ADD THESE METHODS to support GET/POST/PUT/DELETE
37
- get(path, handler) {
38
- this.app.get(path, handler);
32
+ put(...args) {
33
+ this.app.put(...args);
39
34
  }
40
35
 
41
- post(path, handler) {
42
- this.app.post(path, handler);
36
+ delete(...args) {
37
+ this.app.delete(...args);
43
38
  }
44
39
 
45
- put(path, handler) {
46
- this.app.put(path, handler);
40
+ listen(port, callback) {
41
+ this.app.listen(port, callback);
47
42
  }
48
43
 
49
- delete(path, handler) {
50
- this.app.delete(path, handler);
44
+ Router() {
45
+ return express.Router();
51
46
  }
52
47
 
53
- // Proxy core express middleware
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
- 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
-
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 morgan(format) {
81
- const { default: morgan } = await import('morgan');
82
- return morgan(format);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mwalajs",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "MwalaJS Framework CLI Tool and Web Framework for Backend and Frontend Development.",
5
5
  "type": "module",
6
6
  "main": "app.mjs",