@vulkano/core 1.26.0 → 1.27.0
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/AGENTS.md +3 -1
- package/libs/View.js +23 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
`@vulkano/core` (v1.
|
|
5
|
+
`@vulkano/core` (v1.27.0) is the engine of the Vulkano MVC framework. It bootstraps the environment, connects to the database, and auto-loads all models, controllers, services, and responses before starting the Express server. The user app only calls `require('@vulkano/core')`.
|
|
6
6
|
|
|
7
7
|
```
|
|
8
8
|
/**
|
|
@@ -112,6 +112,7 @@ extension**, PascalCase by convention:
|
|
|
112
112
|
| `core/libs/ApiClient.js` | `global.ApiClient` |
|
|
113
113
|
| `core/libs/Crontab.js` | `global.Crontab` |
|
|
114
114
|
| `core/libs/i18n.js` | `global.i18n` |
|
|
115
|
+
| `core/libs/View.js` | `global.View` |
|
|
115
116
|
|
|
116
117
|
> `ActiveRecord` and `AppController` are explicitly excluded from globals even if present.
|
|
117
118
|
|
|
@@ -292,6 +293,7 @@ These are set automatically — never import them manually:
|
|
|
292
293
|
| `ApiClient` | `services.js` | Outbound HTTP client |
|
|
293
294
|
| `Crontab` | `services.js` | Cron job scheduler |
|
|
294
295
|
| `i18n` | `services.js` | i18next instance |
|
|
296
|
+
| `View` | `services.js` | `View.render(view, data)` → Promise<html>, renders outside the request/response cycle |
|
|
295
297
|
| `_` | `app.js` | Underscore.js |
|
|
296
298
|
|
|
297
299
|
---
|
package/libs/View.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View
|
|
3
|
+
*
|
|
4
|
+
* Renders a view to an HTML string without sending an HTTP response —
|
|
5
|
+
* useful for email bodies, PDF generation, or any place that needs
|
|
6
|
+
* rendered markup outside the normal request/response cycle.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
|
|
11
|
+
render(view, data) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
app.vulkano.render(view, data, (err, html) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
reject(err);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
resolve(html);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
};
|