mwalajs 1.0.7 → 1.0.8

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.
@@ -0,0 +1,778 @@
1
+ <!-- include partials/header -->
2
+ <%- include('partials/header') %>
3
+
4
+ <!DOCTYPE html>
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="UTF-8" />
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
9
+ <title>MwalaJS Framework Documentation</title>
10
+
11
+ <!-- Bootstrap CSS for responsive design -->
12
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
13
+
14
+ <!-- Font Awesome for icons (HCI-friendly visual cues) -->
15
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
16
+
17
+ <!-- Meta Info for SEO & Social Sharing -->
18
+ <meta name="description" content="MwalaJS - Lightweight MVC JavaScript framework for full-stack web apps. Comprehensive documentation including installation, commands, structure, and examples.">
19
+ <meta name="keywords" content="MwalaJS, MVC, Node.js framework, JavaScript framework, documentation, installation, CLI commands, file structure">
20
+ <meta name="author" content="Hekima Ambalile Mwala">
21
+
22
+ <!-- Open Graph (for social media cards) -->
23
+ <meta property="og:title" content="MwalaJS - MVC Framework Documentation">
24
+ <meta property="og:description" content="Detailed guide for MwalaJS framework: installation, commands, project structure, examples, and more.">
25
+ <meta property="og:image" content="https://mwalajs.biasharabora.com/images/mwala-logo.png">
26
+ <meta property="og:url" content="https://mwalajs.biasharabora.com">
27
+
28
+ <!-- Twitter Cards -->
29
+ <meta name="twitter:card" content="summary_large_image">
30
+
31
+ <!-- Favicon -->
32
+ <link rel="icon" href="https://mwalajs.biasharabora.com/favicon.ico" type="image/x-icon" />
33
+
34
+ <!-- Custom Styles for attractive, HCI-compliant design -->
35
+ <style>
36
+ :root {
37
+ --primary-color: #0d6efd; /* Bootstrap primary blue */
38
+ --secondary-color: #6c757d;
39
+ --success-color: #198754;
40
+ --info-color: #0dcaf0;
41
+ --warning-color: #ffc107;
42
+ --danger-color: #dc3545;
43
+ --light-color: #f8f9fa;
44
+ --dark-color: #212529;
45
+ --accent-gradient: linear-gradient(135deg, #0d6efd, #6610f2);
46
+ }
47
+
48
+ body {
49
+ background-color: var(--light-color);
50
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
51
+ line-height: 1.6;
52
+ color: var(--dark-color);
53
+ overflow-x: hidden; /* Prevent horizontal scroll */
54
+ }
55
+
56
+ h1, h2, h3, h4, h5, h6 {
57
+ color: var(--primary-color);
58
+ font-weight: 600;
59
+ margin-bottom: 1rem;
60
+ }
61
+
62
+ .navbar {
63
+ background: var(--accent-gradient) !important;
64
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
65
+ }
66
+
67
+ .nav-link {
68
+ color: white !important;
69
+ transition: color 0.3s ease;
70
+ }
71
+
72
+ .nav-link:hover {
73
+ color: var(--warning-color) !important;
74
+ }
75
+
76
+ .help-content, .section-card {
77
+ background-color: #ffffff;
78
+ padding: 2rem;
79
+ border-radius: 12px;
80
+ box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
81
+ margin-bottom: 2rem;
82
+ transition: transform 0.3s ease;
83
+ }
84
+
85
+ .section-card:hover {
86
+ transform: translateY(-5px);
87
+ }
88
+
89
+ pre {
90
+ background-color: #1e1e1e;
91
+ color: #f1f1f1;
92
+ padding: 1.5rem;
93
+ border-radius: 12px;
94
+ overflow-x: auto;
95
+ font-size: 0.95rem;
96
+ box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
97
+ }
98
+
99
+ code {
100
+ padding: 0.2rem 0.4rem;
101
+ border-radius: 4px;
102
+ font-family: 'Courier New', Courier, monospace;
103
+ }
104
+
105
+ .table {
106
+ border-radius: 8px;
107
+ overflow: hidden;
108
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
109
+ }
110
+
111
+ .table thead {
112
+ background: var(--accent-gradient);
113
+ color: white;
114
+ }
115
+
116
+ .table-striped tbody tr:nth-of-type(odd) {
117
+ background-color: rgba(0, 0, 0, 0.05);
118
+ }
119
+
120
+ footer {
121
+ background: var(--accent-gradient);
122
+ color: #ffffff;
123
+ padding: 2rem 0;
124
+ margin-top: 3rem;
125
+ text-align: center;
126
+ }
127
+
128
+ .whatsapp-box {
129
+ background-color: #d1e7dd;
130
+ padding: 1.5rem;
131
+ border-left: 6px solid var(--success-color);
132
+ border-radius: 8px;
133
+ margin: 2rem 0;
134
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
135
+ }
136
+
137
+ .whatsapp-box a {
138
+ color: var(--success-color);
139
+ font-weight: bold;
140
+ text-decoration: none;
141
+ transition: color 0.3s ease;
142
+ }
143
+
144
+ .whatsapp-box a:hover {
145
+ color: var(--primary-color);
146
+ }
147
+
148
+ .note {
149
+ background-color: var(--info-color);
150
+ color: white;
151
+ padding: 1rem;
152
+ border-radius: 8px;
153
+ margin: 1rem 0;
154
+ font-style: italic;
155
+ }
156
+
157
+ /* Search Bar Styles */
158
+ #searchInput {
159
+ border-radius: 50px;
160
+ padding: 0.75rem 1.5rem;
161
+ border: 1px solid var(--secondary-color);
162
+ transition: border-color 0.3s ease;
163
+ }
164
+
165
+ #searchInput:focus {
166
+ border-color: var(--primary-color);
167
+ box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
168
+ }
169
+
170
+ .search-results {
171
+ display: none;
172
+ background-color: white;
173
+ border: 1px solid var(--secondary-color);
174
+ border-radius: 8px;
175
+ padding: 1rem;
176
+ margin-top: 1rem;
177
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
178
+ }
179
+
180
+ /* HCI Improvements: Buttons with icons */
181
+ .btn-icon {
182
+ display: inline-flex;
183
+ align-items: center;
184
+ gap: 0.5rem;
185
+ }
186
+
187
+ /* Responsive Adjustments */
188
+ @media (max-width: 768px) {
189
+ h1 { font-size: 2rem; }
190
+ h2 { font-size: 1.5rem; }
191
+ pre { font-size: 0.85rem; padding: 1rem; }
192
+ .container { padding: 1rem; }
193
+ iframe { width: 100%; height: auto; }
194
+ }
195
+
196
+ @media (max-width: 576px) {
197
+ .table-responsive { overflow-x: auto; }
198
+ .nav-item { text-align: center; }
199
+ }
200
+
201
+ /* Attractive Animations */
202
+ .fade-in {
203
+ opacity: 0;
204
+ animation: fadeIn 1s ease-in forwards;
205
+ }
206
+
207
+ @keyframes fadeIn {
208
+ to { opacity: 1; }
209
+ }
210
+ </style>
211
+ </head>
212
+ <body>
213
+
214
+ <!-- Navigation Bar with Search -->
215
+ <nav class="navbar navbar-expand-lg navbar-dark">
216
+ <div class="container">
217
+ <a class="navbar-brand" href="/"><i class="fas fa-code me-2"></i>MwalaJS</a>
218
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
219
+ <span class="navbar-toggler-icon"></span>
220
+ </button>
221
+ <div class="collapse navbar-collapse" id="navbarNav">
222
+ <ul class="navbar-nav me-auto">
223
+ <li class="nav-item"><a class="nav-link" href="#overview"><i class="fas fa-info-circle me-1"></i>Overview</a></li>
224
+ <li class="nav-item"><a class="nav-link" href="#installation"><i class="fas fa-download me-1"></i>Installation</a></li>
225
+ <li class="nav-item"><a class="nav-link" href="#commands"><i class="fas fa-terminal me-1"></i>Commands</a></li>
226
+ <li class="nav-item"><a class="nav-link" href="#structure"><i class="fas fa-folder-tree me-1"></i>Structure</a></li>
227
+ <li class="nav-item"><a class="nav-link" href="#examples"><i class="fas fa-code-branch me-1"></i>Examples</a></li>
228
+ <li class="nav-item"><a class="nav-link" href="#about"><i class="fas fa-users me-1"></i>About</a></li>
229
+ </ul>
230
+ <!-- Search Bar for Terms -->
231
+ <form class="d-flex" role="search">
232
+ <input class="form-control me-2" type="search" id="searchInput" placeholder="Search terms..." aria-label="Search">
233
+ <button class="btn btn-outline-light" type="button" onclick="performSearch()"><i class="fas fa-search"></i></button>
234
+ </form>
235
+ </div>
236
+ </div>
237
+ </nav>
238
+
239
+ <!-- Main Content Container -->
240
+ <div class="container my-5">
241
+ <h1 class="text-center mb-5 fade-in"><i class="fas fa-book-open me-2"></i>MwalaJS Framework Documentation</h1>
242
+
243
+ <!-- Search Results Section -->
244
+ <div id="searchResults" class="search-results"></div>
245
+
246
+ <!-- Overview Section -->
247
+ <section id="overview" class="section-card fade-in">
248
+ <h2><i class="fas fa-eye me-2"></i>Overview</h2>
249
+ <p><strong>MwalaJS</strong> is a lightweight and modular JavaScript framework designed for building scalable server-side applications using modern Node.js features. It follows the MVC (Model-View-Controller) pattern, making it easy to organize code for full-stack web applications. With built-in support for databases, routing, and middleware, MwalaJS accelerates development while keeping things simple and efficient.</p>
250
+ <p>Key Features:</p>
251
+ <ul>
252
+ <li><i class="fas fa-check-circle text-success me-1"></i>MVC Architecture for clean code separation</li>
253
+ <li><i class="fas fa-check-circle text-success me-1"></i>CLI Tools for project scaffolding and management</li>
254
+ <li><i class="fas fa-check-circle text-success me-1"></i>Database Migrations and Models</li>
255
+ <li><i class="fas fa-check-circle text-success me-1"></i>Customizable Middleware</li>
256
+ <li><i class="fas fa-check-circle text-success me-1"></i>Support for .mjs and .js modules</li>
257
+ <li><i class="fas fa-check-circle text-success me-1"></i>Responsive and secure by design</li>
258
+ </ul>
259
+ </section>
260
+
261
+ <!-- Installation Section -->
262
+ <section id="installation" class="section-card fade-in">
263
+ <h2><i class="fas fa-download me-2"></i>Installation</h2>
264
+ <p>Install MwalaJS globally to use CLI tools:</p>
265
+ <pre><code>npm install -g mwalajs</code></pre>
266
+ <p>If you're using it in a specific project, install locally:</p>
267
+ <pre><code>npm install mwalajs</code></pre>
268
+ <p><strong>Note:</strong> In case of errors regarding missing <code>fs-extra</code>, install it manually:</p>
269
+ <pre><code>npm install -g fs-extra</code></pre>
270
+ <p><strong>Note 2:</strong> MwalaJS is now an NPM package—no need to download .ZIP, .RAR, or .EXE files for versions 1.0.4 or above. Before creating a project, run <code>npm init</code> to create a <code>package.json</code> file. Ensure it includes:</p>
271
+ <pre><code>"dependencies": {
272
+ "mwalajs": "^1.0.5"
273
+ },
274
+ "type": "module"</code></pre>
275
+ <p>These settings are crucial before running <code>mwala serve</code>.</p>
276
+
277
+ <h3><i class="fas fa-windows me-2"></i>Windows Installation Guide</h3>
278
+ <p><strong>What You’ll Need:</strong></p>
279
+ <ul>
280
+ <li><i class="fas fa-computer me-1"></i>A computer (Windows preferred)</li>
281
+ <li><i class="fas fa-wifi me-1"></i>Internet connection</li>
282
+ <li><i class="fas fa-brain me-1"></i>Basic computer knowledge (copy, paste, extracting files)</li>
283
+ <li><i class="fas fa-node-js me-1"></i><a href="https://nodejs.org" target="_blank">Node.js installed</a></li>
284
+ </ul>
285
+ <h4>Step-by-Step Instructions</h4>
286
+ <ol>
287
+ <li><strong>Download MwalaJS:</strong> Go to <a href="https://mwalajs.biasharabora.com" target="_blank">https://mwalajs.biasharabora.com</a> and download ZIP or RAR.</li>
288
+ <li><strong>Extract the File:</strong> Right-click and extract to get the <code>mwalajs</code> folder.</li>
289
+ <li><strong>Move to Program Files:</strong> Paste into <code>C:\Program Files</code>.</li>
290
+ <li><strong>Add to Environment Variables:</strong> Edit system Path and add <code>C:\Program Files\mwalajs</code>.</li>
291
+ <li><strong>Test:</strong> Open CMD and run <code>mwala</code>.</li>
292
+ </ol>
293
+
294
+ <h3><i class="fab fa-linux me-2"></i>Linux Installation (Ubuntu/Debian/Fedora/Others)</h3>
295
+ <ol>
296
+ <li><strong>Download:</strong> From the website, get ZIP or TAR.GZ.</li>
297
+ <li><strong>Extract:</strong> Use <code>unzip</code> or <code>tar -xvzf</code>.</li>
298
+ <li><strong>Move:</strong> <code>sudo mv mwalajs /opt/</code></li>
299
+ <li><strong>Make Executable:</strong> <code>sudo chmod +x /opt/mwalajs/mwala.mjs</code></li>
300
+ <li><strong>Create Symlink:</strong> <code>sudo ln -s /opt/mwalajs/mwala.mjs /usr/local/bin/mwala</code></li>
301
+ <li><strong>Test:</strong> Run <code>mwala</code>.</li>
302
+ </ol>
303
+
304
+ <h4>Troubleshooting</h4>
305
+ <div class="table-responsive">
306
+ <table class="table table-striped table-bordered">
307
+ <thead>
308
+ <tr>
309
+ <th>Issue</th>
310
+ <th>Solution</th>
311
+ </tr>
312
+ </thead>
313
+ <tbody>
314
+ <tr>
315
+ <td><code>mwala</code> not recognized</td>
316
+ <td>Recheck path, restart terminal</td>
317
+ </tr>
318
+ <tr>
319
+ <td>File won’t extract</td>
320
+ <td>Install 7-Zip or WinRAR</td>
321
+ </tr>
322
+ <tr>
323
+ <td>Node.js not found</td>
324
+ <td>Download from official site</td>
325
+ </tr>
326
+ <tr>
327
+ <td>Permission denied</td>
328
+ <td>Use <code>sudo</code> or check permissions</td>
329
+ </tr>
330
+ </tbody>
331
+ </table>
332
+ </div>
333
+
334
+ <h3>Installation Video Guide</h3>
335
+ <div class="ratio ratio-16x9">
336
+ <iframe src="https://www.youtube.com/embed/Zzj0WnvDET4?si=NsgUZDlF0uRuqe1P" title="YouTube video player" allowfullscreen></iframe>
337
+ </div>
338
+ </section>
339
+
340
+ <!-- Commands Section -->
341
+ <section id="commands" class="section-card fade-in">
342
+ <h2><i class="fas fa-terminal me-2"></i>Available Commands</h2>
343
+ <p>Use the MwalaJS CLI to manage your projects efficiently. Run <code>mwala help</code> for a full list.</p>
344
+ <pre>
345
+ <span class="command">mwala create-project &lt;projectName&gt;</span> → Create a new MVC project.
346
+ <span class="command">mwala app.mjs</span> → Start the main application file.
347
+ <span class="command">Database Commands:</span>
348
+ - mwala create-db → Create database.
349
+ - mwala create-table &lt;name&gt; → Create a table.
350
+ - mwala drop-table &lt;name&gt; → Drop a table.
351
+ - mwala migrate all → Run migrations.
352
+ - mwala rollback all → Undo last migration.
353
+
354
+ <span class="command">Code Generation:</span>
355
+ - mwala generate model &lt;name&gt; → Generate a model file.
356
+ - mwala generate controller &lt;name&gt; → Generate a controller file.
357
+ - mwala generate route &lt;name&gt; → Generate a route file.
358
+ - mwala generate view &lt;name&gt; → Generate a view file.
359
+ - mwala generate midware &lt;name&gt; → Generate middleware.
360
+
361
+ <span class="command">mwala serve</span> → Start local server.
362
+ <span class="command">mwala help</span> → List all available commands.
363
+ <span class="command">mwala -v</span> → Check version.
364
+ <span class="command">mwala init</span> → Initialize MwalaJS in a project.
365
+ </pre>
366
+
367
+ <h3>CLI Commands Table</h3>
368
+ <div class="table-responsive">
369
+ <table class="table table-striped table-bordered">
370
+ <thead>
371
+ <tr>
372
+ <th>Command</th>
373
+ <th>Description</th>
374
+ </tr>
375
+ </thead>
376
+ <tbody>
377
+ <tr>
378
+ <td><code>mwala create-project &lt;name&gt;</code></td>
379
+ <td>Create a new project</td>
380
+ </tr>
381
+ <tr>
382
+ <td><code>mwala init</code></td>
383
+ <td>Initialize MwalaJS</td>
384
+ </tr>
385
+ <tr>
386
+ <td><code>mwala serve</code></td>
387
+ <td>Run in development mode</td>
388
+ </tr>
389
+ <tr>
390
+ <td><code>mwala help</code></td>
391
+ <td>Display help</td>
392
+ </tr>
393
+ <tr>
394
+ <td><code>mwala generate model &lt;name&gt;</code></td>
395
+ <td>Generate model</td>
396
+ </tr>
397
+ <!-- Add more rows for all commands to make it longer -->
398
+ <tr>
399
+ <td><code>mwala generate controller &lt;name&gt;</code></td>
400
+ <td>Generate controller</td>
401
+ </tr>
402
+ <tr>
403
+ <td><code>mwala generate route &lt;name&gt;</code></td>
404
+ <td>Generate route</td>
405
+ </tr>
406
+ <tr>
407
+ <td><code>mwala generate view &lt;name&gt;</code></td>
408
+ <td>Generate view</td>
409
+ </tr>
410
+ <tr>
411
+ <td><code>mwala generate midware &lt;name&gt;</code></td>
412
+ <td>Generate middleware</td>
413
+ </tr>
414
+ <tr>
415
+ <td><code>mwala create-db</code></td>
416
+ <td>Create database</td>
417
+ </tr>
418
+ <tr>
419
+ <td><code>mwala create-table &lt;name&gt;</code></td>
420
+ <td>Create table</td>
421
+ </tr>
422
+ <tr>
423
+ <td><code>mwala drop-table &lt;name&gt;</code></td>
424
+ <td>Drop table</td>
425
+ </tr>
426
+ <tr>
427
+ <td><code>mwala migrate all</code></td>
428
+ <td>Run all migrations</td>
429
+ </tr>
430
+ <tr>
431
+ <td><code>mwala rollback all</code></td>
432
+ <td>Undo migrations</td>
433
+ </tr>
434
+ </tbody>
435
+ </table>
436
+ </div>
437
+ </section>
438
+
439
+ <!-- Structure Section -->
440
+ <section id="structure" class="section-card fade-in">
441
+ <h2><i class="fas fa-folder-tree me-2"></i>Project Structure</h2>
442
+ <p>MwalaJS follows a standard MVC structure for organization. The main entry point is <code>app.mjs</code> (use <code>.mjs</code> for ES modules; fallback to <code>.js</code> if needed, but <code>app.mjs</code> is required as MwalaJS points to it).</p>
443
+ <p>In other folders, use <code>filename.mjs</code> or <code>filename.js</code> if <code>.mjs</code> causes errors.</p>
444
+ <pre>
445
+ mwalajs-project/
446
+ ├── app.mjs # Main application entry point (must be .mjs)
447
+ ├── migrations/ # Database migration files (e.g., migration001.js or .mjs)
448
+ ├── models/ # Database models (e.g., UserModel.js or .mjs)
449
+ ├── controllers/ # Application logic (e.g., UserController.js or .mjs)
450
+ ├── routes/ # API routes (e.g., userRoutes.js or .mjs)
451
+ ├── middlewares/ # Custom middleware (e.g., authMiddleware.js or .mjs)
452
+ ├── config/ # Configuration files (e.g., database.js or .mjs, appSettings.js)
453
+ ├── public/ # Static assets (CSS, JS, images)
454
+ │ ├── css/ # Stylesheets
455
+ │ ├── js/ # Client-side scripts
456
+ │ └── images/ # Images and icons
457
+ ├── views/ # Template views for server-side rendering (e.g., index.html or .ejs)
458
+ ├── package.json # NPM dependencies and scripts
459
+ └── README.md # Project documentation
460
+ </pre>
461
+ <p><strong>Notes on File Extensions:</strong></p>
462
+ <ul>
463
+ <li><i class="fas fa-exclamation-triangle text-warning me-1"></i>Use <code>.mjs</code> for modern ES modules.</li>
464
+ <li><i class="fas fa-exclamation-triangle text-warning me-1"></i>If compatibility issues arise, switch to <code>.js</code> except for <code>app.mjs</code>.</li>
465
+ <li><i class="fas fa-info-circle text-info me-1"></i>Example: <code>controllers/UserController.mjs</code> or <code>UserController.js</code>.</li>
466
+ </ul>
467
+ </section>
468
+
469
+ <!-- Examples Section -->
470
+ <section id="examples" class="section-card fade-in">
471
+ <h2><i class="fas fa-code-branch me-2"></i>Examples</h2>
472
+ <p>Here are some code examples to get you started with MwalaJS.</p>
473
+
474
+ <h3>Creating a Simple Controller</h3>
475
+ <pre><code>// controllers/homeController.mjs
476
+ //homeController.mjs
477
+ export const homeController = {
478
+ getHomePage: (req, res) => {
479
+ res.render('index', { title: 'Welcome to MwalaJS MVC' });
480
+ }
481
+
482
+ };
483
+
484
+
485
+ export const Steps = {
486
+ getSteps: (req, res) => {
487
+ res.render('steps', { title: 'Welcome to MwalaJS MVC' });
488
+ }
489
+ };
490
+
491
+ export const welcome = {
492
+ getwelcome: (req, res) => {
493
+ res.render('welcome', { title: 'Welcome to MwalaJS MVC' });
494
+ }
495
+ };
496
+
497
+
498
+ export const about = {
499
+ getabout: (req, res) => {
500
+ res.render('about', { title: 'Welcome to MwalaJS MVC' });
501
+ }
502
+ };
503
+
504
+
505
+ </code></pre>
506
+
507
+ <h3>Defining a Route</h3>
508
+ <pre><code>// routes/homeRoutes.mjs
509
+ import mwalajs from 'mwalajs';
510
+ import { homeController,Steps,welcome,about } from '../controllers/homeController.mjs';
511
+
512
+ const router = mwalajs.Router(); // Corrected Router usage
513
+
514
+ router.get('/', homeController.getHomePage);
515
+ router.get('/steps',Steps.getSteps);
516
+ router.get('/welcome',welcome.getwelcome);
517
+ router.get('/about',about.getabout);
518
+
519
+
520
+ export { router as homeRoutes };
521
+ </code></pre>
522
+
523
+ <h3>App Entry Point</h3>
524
+ <pre><code>// app.mjs
525
+ //app.mjs
526
+ import mwalajs from 'mwalajs';
527
+ import { homeRoutes } from './routes/homeRoutes.mjs';
528
+ import { fileURLToPath } from 'url';
529
+ import path from 'path';
530
+
531
+ const __filename = fileURLToPath(import.meta.url);
532
+ const __dirname = path.dirname(__filename);
533
+
534
+ // Use mwalajs directly (it's an instance now)
535
+ mwalajs.set('view engine', 'ejs');
536
+ mwalajs.set('views', path.join(__dirname, 'views'));
537
+ // Serve static files correctly
538
+ mwalajs.useStatic(path.join(__dirname, 'public'));
539
+ // Use routes
540
+ mwalajs.use('/', homeRoutes);
541
+ mwalajs.use('/steps', homeRoutes);
542
+ mwalajs.use('/about', homeRoutes);
543
+ mwalajs.use('/welcome', homeRoutes);
544
+ mwalajs.get('/mwalajs-framework-documentation', (req, res) => {
545
+ res.render('mwalajs-framework-documentation');
546
+ });
547
+
548
+ // Start server
549
+ const port = process.env.PORT || 2025;
550
+ mwalajs.listen(port, () => {
551
+ console.log(`Server running on http://localhost:${port}`);
552
+ });
553
+
554
+ <h3>Generating a Model</h3>
555
+ <p>Run <code>mwala generate model User</code> to create a model file.</p>
556
+ <pre><code>// models/User.mjs
557
+ export class User {
558
+ // Model logic here
559
+ }
560
+
561
+ EXAMPLE
562
+
563
+ import db from '../config/db.js';
564
+
565
+ export const getAllResources = async (filters = {}) => {
566
+ let query = `
567
+ SELECT r.*, u.fullname AS uploaded_by_name,
568
+ c.name AS category_name,
569
+ l.name AS level_name,
570
+ s.subject_name
571
+ FROM resources r
572
+ LEFT JOIN users u ON r.uploaded_by = u.id
573
+ LEFT JOIN categories c ON r.category_id = c.id
574
+ LEFT JOIN levels l ON r.level_id = l.id
575
+ LEFT JOIN subjects s ON r.subject_id = s.id
576
+ WHERE 1=1
577
+ `;
578
+ const params = [];
579
+
580
+ if (filters.category_id) {
581
+ query += ' AND r.category_id = ?';
582
+ params.push(filters.category_id);
583
+ }
584
+ if (filters.level_id) {
585
+ query += ' AND r.level_id = ?';
586
+ params.push(filters.level_id);
587
+ }
588
+ if (filters.subject_id) {
589
+ query += ' AND r.subject_id = ?';
590
+ params.push(filters.subject_id);
591
+ }
592
+
593
+ query += ' ORDER BY r.id DESC';
594
+ const [rows] = await db.query(query, params);
595
+ return rows;
596
+ };
597
+
598
+ export const getResourceById = async (id) => {
599
+ const [rows] = await db.query('SELECT * FROM resources WHERE id = ?', [id]);
600
+ return rows[0];
601
+ };
602
+
603
+ export const createResource = async (resource) => {
604
+ const sql = `
605
+ INSERT INTO resources
606
+ (title, description, google_drive_link, category_id, level_id, subject_id, uploaded_by)
607
+ VALUES (?, ?, ?, ?, ?, ?, ?)
608
+ `;
609
+ const params = [
610
+ resource.title,
611
+ resource.description,
612
+ resource.google_drive_link,
613
+ resource.category_id,
614
+ resource.level_id,
615
+ resource.subject_id,
616
+ resource.uploaded_by
617
+ ];
618
+ await db.query(sql, params);
619
+ };
620
+
621
+ export const updateResource = async (id, resource) => {
622
+ const sql = `
623
+ UPDATE resources SET
624
+ title = ?, description = ?, google_drive_link = ?,
625
+ category_id = ?, level_id = ?, subject_id = ?
626
+ WHERE id = ?
627
+ `;
628
+ const params = [
629
+ resource.title,
630
+ resource.description,
631
+ resource.google_drive_link,
632
+ resource.category_id,
633
+ resource.level_id,
634
+ resource.subject_id,
635
+ id
636
+ ];
637
+ await db.query(sql, params);
638
+ };
639
+
640
+ export const deleteResource = async (id) => {
641
+ await db.query('DELETE FROM resources WHERE id = ?', [id]);
642
+ };
643
+
644
+ </code></pre>
645
+
646
+ <p>More examples available in the official repository or by joining the support group.</p>
647
+ </section>
648
+
649
+ <!-- About Section -->
650
+ <section id="about" class="section-card fade-in">
651
+ <h2><i class="fas fa-users me-2"></i>About MwalaJS</h2>
652
+ <p>MwalaJS is developed by Hekima Ambalile Mwala and the MwalaJS Team. It's open-source under the MIT License, aimed at simplifying Node.js development for beginners and experts alike.</p>
653
+ <h3>Security Notes</h3>
654
+ <ul>
655
+ <li><i class="fas fa-shield-alt text-success me-1"></i>Keep dependencies updated with <code>npm update</code>.</li>
656
+ <li><i class="fas fa-shield-alt text-success me-1"></i>Sanitize user inputs to prevent vulnerabilities.</li>
657
+ <li><i class="fas fa-shield-alt text-success me-1"></i>Run <code>npm audit</code> regularly for security checks.</li>
658
+ <li><i class="fas fa-shield-alt text-success me-1"></i>Use HTTPS in production.</li>
659
+ <li><i class="fas fa-shield-alt text-success me-1"></i>Implement authentication middleware.</li>
660
+ </ul>
661
+ <h3>License</h3>
662
+ <p>MIT License © 2025 Hekima Mwala and MwalaJS Team. All rights reserved for contributions.</p>
663
+ </section>
664
+
665
+ <!-- Download Section -->
666
+ <section class="section-card fade-in">
667
+ <h2><i class="fas fa-cloud-download-alt me-2"></i>MwalaJS Release Downloads</h2>
668
+ <p>For versions below 1.0.2, download .EXE, .ZIP, or .RAR. For latest, use NPM.</p>
669
+
670
+ <h4 class="text-success">Version 1.0.1</h4>
671
+ <div class="table-responsive">
672
+ <table class="table table-bordered table-hover">
673
+ <thead>
674
+ <tr>
675
+ <th>File Type</th>
676
+ <th>Description</th>
677
+ <th>Download</th>
678
+ </tr>
679
+ </thead>
680
+ <tbody>
681
+ <tr>
682
+ <td>ZIP</td>
683
+ <td>Latest release ZIP</td>
684
+ <td><a class="btn btn-primary btn-sm btn-icon" href="https://mwalajs.biasharabora.com/files/mwalajsv101.zip"><i class="fas fa-download"></i>Download</a></td>
685
+ </tr>
686
+ <tr>
687
+ <td>RAR</td>
688
+ <td>Latest release RAR</td>
689
+ <td><a class="btn btn-primary btn-sm btn-icon" href="https://mwalajs.biasharabora.com/files/mwalajsv101.rar"><i class="fas fa-download"></i>Download</a></td>
690
+ </tr>
691
+ </tbody>
692
+ </table>
693
+ </div>
694
+
695
+ <h4 class="text-secondary mt-4">Version 1.0.0</h4>
696
+ <div class="table-responsive">
697
+ <table class="table table-bordered table-hover">
698
+ <thead>
699
+ <tr>
700
+ <th>File Type</th>
701
+ <th>Description</th>
702
+ <th>Download</th>
703
+ </tr>
704
+ </thead>
705
+ <tbody>
706
+ <tr>
707
+ <td>EXE</td>
708
+ <td>Installer (.exe)</td>
709
+ <td><a class="btn btn-success btn-sm btn-icon" href="https://mwalajs.biasharabora.com/files/mwalaJS_installer.exe"><i class="fas fa-download"></i>Download</a></td>
710
+ </tr>
711
+ <tr>
712
+ <td>ZIP</td>
713
+ <td>v1.0.0 ZIP</td>
714
+ <td><a class="btn btn-secondary btn-sm btn-icon" href="https://mwalajs.biasharabora.com/files/mwalajsm.zip"><i class="fas fa-download"></i>Download</a></td>
715
+ </tr>
716
+ <tr>
717
+ <td>RAR</td>
718
+ <td>v1.0.0 RAR</td>
719
+ <td><a class="btn btn-secondary btn-sm btn-icon" href="https://mwalajs.biasharabora.com/files/mwalajsm.rar"><i class="fas fa-download"></i>Download</a></td>
720
+ </tr>
721
+ </tbody>
722
+ </table>
723
+ </div>
724
+ </section>
725
+
726
+ <!-- WhatsApp Support Box -->
727
+ <div class="whatsapp-box fade-in">
728
+ <h5><i class="fab fa-whatsapp me-2 text-success"></i>Join the MwalaJS WhatsApp Support Group</h5>
729
+ <p>Get real-time help from the community and developers.</p>
730
+ <a href="https://chat.whatsapp.com/F8x1p8R1EhZ5b7RX7PO6dR?mode=r_t" target="_blank" class="btn btn-success btn-icon"><i class="fas fa-external-link-alt"></i>Click here to join</a>
731
+ </div>
732
+ </div>
733
+
734
+ <!-- Footer -->
735
+ <!-- <footer>
736
+ <div class="container">
737
+ <p>&copy; MwalaJS Framework. Built by Hekima Mwala and the MwalaJS Development Team. <i class="fas fa-heart text-danger"></i></p>
738
+ <p>Contact: <a href="mailto:biasharaboraofficials@biasharabora.com" class="text-white"><i class="fas fa-envelope me-1"></i>biasharaboraofficials@biasharabora.com</a> | <a href="https://mwalajs.biasharabora.com" target="_blank" class="text-white"><i class="fas fa-globe me-1"></i>Official Website</a></p>
739
+ </div>
740
+ </footer> -->
741
+
742
+ <!-- Bootstrap JS -->
743
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
744
+
745
+ <!-- Custom JavaScript for Search Functionality -->
746
+ <script>
747
+ function performSearch() {
748
+ const query = document.getElementById('searchInput').value.toLowerCase();
749
+ const sections = document.querySelectorAll('section, div.help-content');
750
+ const resultsContainer = document.getElementById('searchResults');
751
+ resultsContainer.innerHTML = '';
752
+ resultsContainer.style.display = 'none';
753
+
754
+ if (!query) return;
755
+
756
+ let results = [];
757
+ sections.forEach(section => {
758
+ const text = section.textContent.toLowerCase();
759
+ if (text.includes(query)) {
760
+ const title = section.querySelector('h2') ? section.querySelector('h2').textContent : 'Match Found';
761
+ results.push(`<div class="mb-3"><strong>${title}</strong><p>${text.substring(text.indexOf(query) - 50, text.indexOf(query) + 100)}...</p><a href="#${section.id}" class="btn btn-sm btn-primary">Go to Section</a></div>`);
762
+ }
763
+ });
764
+
765
+ if (results.length > 0) {
766
+ resultsContainer.innerHTML = results.join('');
767
+ resultsContainer.style.display = 'block';
768
+ } else {
769
+ resultsContainer.innerHTML = '<p>No results found.</p>';
770
+ resultsContainer.style.display = 'block';
771
+ }
772
+ }
773
+ </script>
774
+
775
+ </body>
776
+ </html>
777
+
778
+ <%- include('partials/footer') %>