mwalajs 1.0.2 → 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 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
+ ![npm version](https://img.shields.io/npm/v/mwalajs)
543
+ ![GitHub issues](https://img.shields.io/github/issues/mwala400/mwalajs)
544
+ ![License](https://img.shields.io/github/license/mwala400/mwalajs)
542
545
 
package/app.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ //app.mjs
1
2
  import mwalajs from 'mwalajs';
2
3
  import { homeRoutes } from './routes/homeRoutes.mjs';
3
4
  import { fileURLToPath } from 'url';
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.4');
58
59
  process.exit(0);
59
60
 
60
61
  case 'create-project':
package/createProject.mjs CHANGED
@@ -51,9 +51,9 @@ async function createProject() {
51
51
  fs.mkdirSync(newProjectPath);
52
52
 
53
53
  const itemsToCopy = [
54
- "app.mjs", "controllers", "mwalajs", "routes",
55
- "views", "middlewares", "models", "package.json",
56
- "README.md", "public"
54
+ "app.mjs", "controllers", "migrations", "routes",
55
+ "views", "middlewares", "models",
56
+ "README.md","public"
57
57
  ];
58
58
 
59
59
  for (const item of itemsToCopy) {
@@ -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,16 +1,23 @@
1
1
  {
2
2
  "name": "mwalajs",
3
- "version": "1.0.2",
4
- "description": "MwalaJS Framework CLI Tool",
3
+ "version": "1.0.4",
4
+ "description": "MwalaJS Framework CLI Tool and Web Framework for Backend and Frontend Development.",
5
5
  "type": "module",
6
6
  "main": "app.mjs",
7
- "scripts": {
8
- "start": "node app.mjs",
9
- "cli": "node bin/mwala.mjs"
7
+ "exports": {
8
+ ".": "./index.mjs"
10
9
  },
11
10
  "bin": {
12
11
  "mwala": "bin/mwala.mjs"
13
12
  },
13
+ "scripts": {
14
+ "start": "node app.mjs",
15
+ "cli": "node bin/mwala.mjs",
16
+ "test": "echo \"No test specified\" && exit 0",
17
+ "prepare": "npm run build",
18
+ "build": "echo 'Build step if needed'",
19
+ "postinstall": "echo 'Thanks for installing MwalaJS Framework! '"
20
+ },
14
21
  "dependencies": {
15
22
  "dotenv": "^16.4.7",
16
23
  "ejs": "^3.1.10",
@@ -26,33 +33,40 @@
26
33
  "sequelize": "^6.37.6",
27
34
  "sqlite3": "^5.1.7"
28
35
  },
29
- "devDependencies": {
30
- "@vercel/ncc": "^0.38.3",
31
- "nexe": "^5.0.0-beta.4",
32
- "pkg": "^5.8.1"
33
- },
34
- "pkg": {
35
- "assets": [
36
- "views/**/*",
37
- "public/**/*",
38
- "config/**/*.mjs",
39
- "runMigrations.mjs",
40
- "setupMwalajs.mjs",
41
- "createProject.mjs",
42
- ".env",
43
- "README.md",
44
- "package.json"
45
- ],
46
- "targets": [
47
- "node18-win-x64",
48
- "node18-linux-x64",
49
- "node18-macos-x64"
50
- ],
51
- "outputPath": "dist"
52
- },
53
- "author": "HEKIMA AMBALILE MWALA",
36
+ "keywords": [
37
+ "mwalajs",
38
+ "mwala",
39
+ "framework",
40
+ "nodejs",
41
+ "express",
42
+ "mvc",
43
+ "cli",
44
+ "generator",
45
+ "backend",
46
+ "frontend",
47
+ "web-framework",
48
+ "orm",
49
+ "rest-api"
50
+ ],
51
+ "author": {
52
+ "name": "Hekima Ambalile Mwala",
53
+ "email": "biasharaboraofficials@gmail.com",
54
+ "url": "https://github.com/mwala400"
55
+ },
54
56
  "license": "MIT",
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/mwala400/mwalajs.git"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/mwala400/mwalajs/issues"
63
+ },
64
+ "homepage": "https://github.com/mwala400/mwalajs#readme",
55
65
  "engines": {
56
66
  "node": ">=18.0.0"
67
+ },
68
+ "sideEffects": false,
69
+ "publishConfig": {
70
+ "access": "public"
57
71
  }
58
72
  }
@@ -1,16 +0,0 @@
1
- {
2
- "name": "mwalajs",
3
- "version": "1.0.0",
4
- "type": "module",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "description": "",
13
- "dependencies": {
14
- "express": "^4.21.2"
15
- }
16
- }
File without changes