millas 0.2.12-beta → 0.2.12-beta-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/package.json +3 -16
- package/src/auth/Auth.js +13 -8
- package/src/auth/AuthController.js +3 -1
- package/src/auth/AuthUser.js +98 -0
- package/src/cli.js +1 -1
- package/src/commands/serve.js +81 -110
- package/src/container/AppInitializer.js +158 -0
- package/src/container/Application.js +278 -253
- package/src/container/HttpServer.js +156 -0
- package/src/container/MillasApp.js +23 -280
- package/src/container/MillasConfig.js +163 -0
- package/src/core/auth.js +9 -0
- package/src/core/db.js +8 -0
- package/src/core/foundation.js +67 -0
- package/src/core/http.js +11 -0
- package/src/core/mail.js +6 -0
- package/src/core/queue.js +7 -0
- package/src/core/validation.js +29 -0
- package/src/facades/Admin.js +1 -1
- package/src/facades/Auth.js +22 -39
- package/src/facades/Cache.js +21 -10
- package/src/facades/Database.js +1 -1
- package/src/facades/Events.js +18 -17
- package/src/facades/Facade.js +197 -0
- package/src/facades/Http.js +42 -45
- package/src/facades/Log.js +25 -49
- package/src/facades/Mail.js +27 -32
- package/src/facades/Queue.js +22 -15
- package/src/facades/Storage.js +18 -10
- package/src/facades/Url.js +53 -0
- package/src/http/HttpClient.js +673 -0
- package/src/http/ResponseDispatcher.js +18 -111
- package/src/http/UrlGenerator.js +375 -0
- package/src/http/WelcomePage.js +273 -0
- package/src/http/adapters/ExpressAdapter.js +315 -0
- package/src/http/adapters/HttpAdapter.js +168 -0
- package/src/http/adapters/index.js +9 -0
- package/src/index.js +5 -144
- package/src/logger/formatters/PrettyFormatter.js +15 -5
- package/src/logger/internal.js +2 -2
- package/src/logger/patchConsole.js +91 -81
- package/src/middleware/MiddlewareRegistry.js +62 -82
- package/src/orm/migration/ModelInspector.js +339 -340
- package/src/providers/AuthServiceProvider.js +9 -5
- package/src/providers/CacheStorageServiceProvider.js +3 -1
- package/src/providers/EventServiceProvider.js +2 -1
- package/src/providers/LogServiceProvider.js +3 -2
- package/src/providers/MailServiceProvider.js +3 -2
- package/src/providers/QueueServiceProvider.js +3 -2
- package/src/router/Router.js +119 -152
- package/src/scaffold/templates.js +8 -7
- package/src/facades/Validation.js +0 -69
package/src/facades/Mail.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
const { MailMessage, TemplateEngine, SmtpDriver, SendGridDriver, MailgunDriver, LogDriver, MailServiceProvider } = require('../core');
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
7
|
+
* Mail facade.
|
|
5
8
|
*
|
|
6
|
-
*
|
|
9
|
+
* @class
|
|
10
|
+
* @property {function(MailMessage|object): Promise<void>} send
|
|
11
|
+
* @property {function(MailMessage|object): Promise<void>} queue
|
|
12
|
+
* @property {function(string, string=): MailMessage} to
|
|
13
|
+
* @property {function(object): void} swap
|
|
14
|
+
* @property {function(): void} restore
|
|
7
15
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
16
|
+
* — MailMessage builder (returned by Mail.to())
|
|
17
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.to
|
|
18
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.cc
|
|
19
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.bcc
|
|
20
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.from
|
|
21
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.replyTo
|
|
22
|
+
* @property {function(string): MailMessage} MailMessage.prototype.subject
|
|
23
|
+
* @property {function(string): MailMessage} MailMessage.prototype.html
|
|
24
|
+
* @property {function(string): MailMessage} MailMessage.prototype.text
|
|
25
|
+
* @property {function(string, object=): MailMessage} MailMessage.prototype.view
|
|
26
|
+
* @property {function(string, string=, string=): MailMessage} MailMessage.prototype.attach
|
|
27
|
+
* @property {function(number): MailMessage} MailMessage.prototype.priority
|
|
28
|
+
* @property {function(): Promise<void>} MailMessage.prototype.send
|
|
29
|
+
* @property {function(): Promise<void>} MailMessage.prototype.queue
|
|
12
30
|
*
|
|
13
|
-
*
|
|
14
|
-
* await Mail.to(user.email)
|
|
15
|
-
* .subject('Reset your password')
|
|
16
|
-
* .view('emails/reset', { token, user })
|
|
17
|
-
* .send();
|
|
31
|
+
* @see src/mail/Mail.js
|
|
18
32
|
*/
|
|
33
|
+
class Mail extends createFacade('mail') {}
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
Mail,
|
|
22
|
-
MailMessage,
|
|
23
|
-
TemplateEngine,
|
|
24
|
-
SmtpDriver,
|
|
25
|
-
SendGridDriver,
|
|
26
|
-
MailgunDriver,
|
|
27
|
-
LogDriver,
|
|
28
|
-
MailServiceProvider,
|
|
29
|
-
} = require('../index');
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
Mail,
|
|
33
|
-
MailMessage,
|
|
34
|
-
TemplateEngine,
|
|
35
|
-
SmtpDriver,
|
|
36
|
-
SendGridDriver,
|
|
37
|
-
MailgunDriver,
|
|
38
|
-
LogDriver,
|
|
39
|
-
MailServiceProvider,
|
|
40
|
-
};
|
|
35
|
+
module.exports = Mail
|
package/src/facades/Queue.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* const { Queue, Job, dispatch } = require('millas/facades/Queue');
|
|
7
|
-
*
|
|
8
|
-
* class SendWelcomeEmail extends Job {
|
|
9
|
-
* async handle() {
|
|
10
|
-
* await Mail.to(this.data.email).subject('Welcome').send();
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
6
|
+
* Queue facade.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* @class
|
|
9
|
+
* @property {function(Job): Promise<void>} push
|
|
10
|
+
* @property {function(string=): Promise<number>} size
|
|
11
|
+
* @property {function(string=): Promise<void>} clear
|
|
12
|
+
* @property {function(function): void} register
|
|
13
|
+
* @property {function(object): void} swap
|
|
14
|
+
* @property {function(): void} restore
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
* await dispatch(new SendWelcomeEmail({ email }), { delay: 60 });
|
|
16
|
+
* @see src/queue/Queue.js
|
|
19
17
|
*/
|
|
18
|
+
class Queue extends createFacade('queue') {}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Shorthand for Queue.push(job).
|
|
22
|
+
*
|
|
23
|
+
* @param {Job} job
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
async function dispatch(job) {
|
|
27
|
+
return Queue.push(job);
|
|
28
|
+
}
|
|
22
29
|
|
|
23
|
-
module.exports =
|
|
30
|
+
module.exports = Queue;
|
package/src/facades/Storage.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Storage facade.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
8
|
+
* @class
|
|
9
|
+
* @property {function(string, Buffer|string, object=): Promise<void>} put
|
|
10
|
+
* @property {function(string): Promise<Buffer|string>} get
|
|
11
|
+
* @property {function(string): Promise<boolean>} exists
|
|
12
|
+
* @property {function(string): Promise<void>} delete
|
|
13
|
+
* @property {function(string): Promise<object>} metadata
|
|
14
|
+
* @property {function(string): string} url
|
|
15
|
+
* @property {function(string): string} path
|
|
16
|
+
* @property {function(string, object, object=): void} stream
|
|
17
|
+
* @property {function(string): Storage} disk
|
|
18
|
+
* @property {function(object): void} swap
|
|
19
|
+
* @property {function(): void} restore
|
|
7
20
|
*
|
|
8
|
-
*
|
|
9
|
-
* const url = await Storage.url('avatars/user-5.jpg');
|
|
10
|
-
* const data = await Storage.get('avatars/user-5.jpg');
|
|
11
|
-
* await Storage.delete('avatars/user-5.jpg');
|
|
12
|
-
* const exists = await Storage.exists('avatars/user-5.jpg');
|
|
21
|
+
* @see src/storage/Storage.js
|
|
13
22
|
*/
|
|
23
|
+
class Storage extends createFacade('storage') {}
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
module.exports = { Storage, LocalDriver, StorageServiceProvider };
|
|
25
|
+
module.exports = Storage;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {createFacade} = require('./Facade');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* URL facade — Laravel-like URL generation.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
*
|
|
10
|
+
* — Base
|
|
11
|
+
* @property {function(): string} base
|
|
12
|
+
*
|
|
13
|
+
* — URL generation
|
|
14
|
+
* @property {function(string, object=): string} to
|
|
15
|
+
* @property {function(string, object=): string} secure
|
|
16
|
+
* @property {function(string, object=): string} relative
|
|
17
|
+
*
|
|
18
|
+
* — Named routes
|
|
19
|
+
* @property {function(string, object=, object=): string} route
|
|
20
|
+
*
|
|
21
|
+
* — Assets
|
|
22
|
+
* @property {function(string): string} asset
|
|
23
|
+
* @property {function(string): string} secureAsset
|
|
24
|
+
*
|
|
25
|
+
* — Current / previous request
|
|
26
|
+
* @property {function(): string|null} current
|
|
27
|
+
* @property {function(): string|null} currentPath
|
|
28
|
+
* @property {function(string=): string} previous
|
|
29
|
+
*
|
|
30
|
+
* — Signed URLs
|
|
31
|
+
* @property {function(string, object=, number=): string} signedRoute
|
|
32
|
+
* @property {function(string, number=): string} signedUrl
|
|
33
|
+
* @property {function(object): boolean} hasValidSignature
|
|
34
|
+
*
|
|
35
|
+
* — Scheme control
|
|
36
|
+
* @property {function(boolean=): UrlGenerator} forceHttps
|
|
37
|
+
* @property {function(string): UrlGenerator} forceScheme
|
|
38
|
+
* @property {function(string): UrlGenerator} useAssetOrigin
|
|
39
|
+
*
|
|
40
|
+
* — Introspection
|
|
41
|
+
* @property {function(string): boolean} isValid
|
|
42
|
+
* @property {function(...string): boolean} is
|
|
43
|
+
*
|
|
44
|
+
* — Testing
|
|
45
|
+
* @property {function(object): void} swap
|
|
46
|
+
* @property {function(): void} restore
|
|
47
|
+
*
|
|
48
|
+
* @see src/http/UrlGenerator.js
|
|
49
|
+
*/
|
|
50
|
+
class URL extends createFacade('url') {
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = URL;
|