millas 0.1.0 → 0.1.2
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/package.json +11 -8
- package/src/scaffold/maker.js +4 -4
- package/src/scaffold/templates.js +58 -12
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "millas",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
3
|
+
"version": "0.1.02",
|
|
7
4
|
"description": "A modern batteries-included backend framework for Node.js — built on Express, inspired by Laravel, Django, and FastAPI",
|
|
8
5
|
"main": "src/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.js",
|
|
8
|
+
"./src": "./src/index.js",
|
|
9
|
+
"./src/*": "./src/*.js",
|
|
10
|
+
"./bin/*": "./bin/*.js"
|
|
11
|
+
},
|
|
9
12
|
"bin": {
|
|
10
13
|
"millas": "./bin/millas.js"
|
|
11
14
|
},
|
|
@@ -24,14 +27,14 @@
|
|
|
24
27
|
},
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"bcryptjs": "^3.0.3",
|
|
27
|
-
"chalk":
|
|
30
|
+
"chalk": "4.1.2",
|
|
28
31
|
"commander": "^11.0.0",
|
|
29
32
|
"fs-extra": "^11.0.0",
|
|
30
|
-
"inquirer": "
|
|
33
|
+
"inquirer": "8.2.6",
|
|
31
34
|
"jsonwebtoken":"^9.0.3",
|
|
32
35
|
"knex": "^3.1.0",
|
|
33
|
-
"nodemailer":
|
|
34
|
-
"ora": "
|
|
36
|
+
"nodemailer": "^6.9.0",
|
|
37
|
+
"ora": "5.4.1"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
37
40
|
"express": "^4.18.0"
|
package/src/scaffold/maker.js
CHANGED
|
@@ -37,7 +37,7 @@ async function makeController(name, options = {}) {
|
|
|
37
37
|
const content = resource
|
|
38
38
|
? `'use strict';
|
|
39
39
|
|
|
40
|
-
const { Controller } = require('millas
|
|
40
|
+
const { Controller } = require('millas');
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* ${className}
|
|
@@ -81,7 +81,7 @@ module.exports = ${className};
|
|
|
81
81
|
`
|
|
82
82
|
: `'use strict';
|
|
83
83
|
|
|
84
|
-
const { Controller } = require('millas
|
|
84
|
+
const { Controller } = require('millas');
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* ${className}
|
|
@@ -105,7 +105,7 @@ async function makeModel(name, options = {}) {
|
|
|
105
105
|
|
|
106
106
|
const content = `'use strict';
|
|
107
107
|
|
|
108
|
-
const { Model, fields } = require('millas
|
|
108
|
+
const { Model, fields } = require('millas');
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* ${className} Model
|
|
@@ -142,7 +142,7 @@ async function makeMiddleware(name) {
|
|
|
142
142
|
|
|
143
143
|
const content = `'use strict';
|
|
144
144
|
|
|
145
|
-
const { Middleware } = require('millas
|
|
145
|
+
const { Middleware } = require('millas');
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* ${className}
|
|
@@ -11,11 +11,13 @@ function getProjectFiles(projectName) {
|
|
|
11
11
|
main: 'bootstrap/app.js',
|
|
12
12
|
scripts: {
|
|
13
13
|
start: 'node bootstrap/app.js',
|
|
14
|
-
dev:
|
|
14
|
+
dev: 'millas serve',
|
|
15
|
+
serve: 'millas serve',
|
|
15
16
|
},
|
|
16
17
|
dependencies: {
|
|
18
|
+
millas: 'latest',
|
|
17
19
|
express: '^4.18.2',
|
|
18
|
-
dotenv:
|
|
20
|
+
dotenv: '^16.0.3',
|
|
19
21
|
},
|
|
20
22
|
}, null, 2),
|
|
21
23
|
|
|
@@ -86,9 +88,40 @@ module.exports = {
|
|
|
86
88
|
|
|
87
89
|
require('dotenv').config();
|
|
88
90
|
|
|
89
|
-
const express
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
const express = require('express');
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Resolve the millas package whether installed locally (node_modules)
|
|
95
|
+
* or used from a globally installed CLI (millas serve).
|
|
96
|
+
*/
|
|
97
|
+
function resolveMillas() {
|
|
98
|
+
// 1. Try local node_modules first (preferred)
|
|
99
|
+
try { return require('millas/src'); } catch {}
|
|
100
|
+
// 2. Try resolving from the global CLI location
|
|
101
|
+
try {
|
|
102
|
+
const path = require('path');
|
|
103
|
+
const cliPath = require.resolve('millas/bin/millas.js');
|
|
104
|
+
const millasSrc = path.join(path.dirname(cliPath), '..', 'src', 'index.js');
|
|
105
|
+
return require(millasSrc);
|
|
106
|
+
} catch {}
|
|
107
|
+
throw new Error(
|
|
108
|
+
'Cannot find millas. Run: npm install millas\\n' +
|
|
109
|
+
'Or install globally: npm install -g millas'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const {
|
|
114
|
+
Application,
|
|
115
|
+
DatabaseServiceProvider,
|
|
116
|
+
CacheServiceProvider,
|
|
117
|
+
StorageServiceProvider,
|
|
118
|
+
MailServiceProvider,
|
|
119
|
+
QueueServiceProvider,
|
|
120
|
+
EventServiceProvider,
|
|
121
|
+
AuthServiceProvider,
|
|
122
|
+
} = resolveMillas();
|
|
123
|
+
|
|
124
|
+
const AppServiceProvider = require('../providers/AppServiceProvider');
|
|
92
125
|
|
|
93
126
|
const expressApp = express();
|
|
94
127
|
expressApp.use(express.json());
|
|
@@ -99,8 +132,13 @@ const app = new Application(expressApp);
|
|
|
99
132
|
|
|
100
133
|
// ── Register service providers ──────────────────────────────────
|
|
101
134
|
app.providers([
|
|
135
|
+
CacheServiceProvider,
|
|
136
|
+
StorageServiceProvider,
|
|
137
|
+
MailServiceProvider,
|
|
138
|
+
QueueServiceProvider,
|
|
139
|
+
EventServiceProvider,
|
|
102
140
|
AppServiceProvider,
|
|
103
|
-
//
|
|
141
|
+
// AuthServiceProvider, // uncomment when you have a User model
|
|
104
142
|
]);
|
|
105
143
|
|
|
106
144
|
// ── Define routes ────────────────────────────────────────────────
|
|
@@ -119,7 +157,7 @@ app.routes(Route => {
|
|
|
119
157
|
}
|
|
120
158
|
})();
|
|
121
159
|
|
|
122
|
-
module.exports = { app, expressApp };
|
|
160
|
+
module.exports = { app, expressApp, get route() { return app.route; } };
|
|
123
161
|
`,
|
|
124
162
|
|
|
125
163
|
// ─── routes/web.js ────────────────────────────────────────────
|
|
@@ -267,16 +305,25 @@ module.exports = {
|
|
|
267
305
|
// ─── providers/AppServiceProvider.js ──────────────────────────
|
|
268
306
|
'providers/AppServiceProvider.js': `'use strict';
|
|
269
307
|
|
|
270
|
-
|
|
308
|
+
function resolveMillas() {
|
|
309
|
+
try { return require('millas/src'); } catch {}
|
|
310
|
+
try {
|
|
311
|
+
const path = require('path');
|
|
312
|
+
const cli = require.resolve('millas/bin/millas.js');
|
|
313
|
+
return require(path.join(path.dirname(cli), '..', 'src', 'index.js'));
|
|
314
|
+
} catch {}
|
|
315
|
+
throw new Error('Cannot find millas. Run: npm install millas');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const { ServiceProvider } = resolveMillas();
|
|
271
319
|
|
|
272
320
|
/**
|
|
273
321
|
* AppServiceProvider
|
|
274
322
|
*
|
|
275
|
-
* Register and bootstrap your application
|
|
323
|
+
* Register and bootstrap your application services here.
|
|
276
324
|
*
|
|
277
325
|
* register() — bind things into the container
|
|
278
|
-
* boot() — called after all providers have registered
|
|
279
|
-
* safe to resolve other bindings here
|
|
326
|
+
* boot() — called after all providers have registered
|
|
280
327
|
*/
|
|
281
328
|
class AppServiceProvider extends ServiceProvider {
|
|
282
329
|
register(container) {
|
|
@@ -287,7 +334,6 @@ class AppServiceProvider extends ServiceProvider {
|
|
|
287
334
|
|
|
288
335
|
async boot(container, app) {
|
|
289
336
|
// const logger = container.make('Logger');
|
|
290
|
-
// logger.info('App booted');
|
|
291
337
|
}
|
|
292
338
|
}
|
|
293
339
|
|