@raketa-cloud/admin 0.0.12 → 0.0.13
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
CHANGED
package/src/Adapter.js
CHANGED
package/src/HonoAdapter.js
CHANGED
|
@@ -84,113 +84,117 @@ export default class HonoAdapter extends Adapter {
|
|
|
84
84
|
]) {
|
|
85
85
|
const method = this.getMethod(verb);
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (redirect) return routerCtx.redirect(redirect);
|
|
134
|
-
|
|
135
|
-
if (json) {
|
|
136
|
-
return routerCtx.json(json);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
assigns.beforeFilterAssigns = beforeFilterAssigns;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Process action
|
|
87
|
+
Object.keys(this.globalConfig.i18n.locales).forEach((currentLocale) => {
|
|
88
|
+
const completePath = `/${currentLocale}${path}`;
|
|
89
|
+
|
|
90
|
+
// A terrible, terrible hack...
|
|
91
|
+
// So how do we override for the entire handler.. do we need to completely override it, or just partially? Fun stuff?
|
|
92
|
+
this.router.router.routes = this.router.router.routes.filter((route) => {
|
|
93
|
+
return route[0] !== verb || route[1] !== completePath;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
method(completePath, async (routerCtx, next) => {
|
|
97
|
+
const ctx = await this.createContext(
|
|
98
|
+
routerCtx,
|
|
99
|
+
next,
|
|
100
|
+
verb,
|
|
101
|
+
resource,
|
|
102
|
+
action
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
ctx.locales = this.globalConfig.i18n.locales;
|
|
106
|
+
ctx.defaultLocale = this.globalConfig.i18n.defaultLocale;
|
|
107
|
+
ctx.locale = currentLocale;
|
|
108
|
+
|
|
109
|
+
const _context = {
|
|
110
|
+
locales: ctx.locales,
|
|
111
|
+
locale: ctx.locale,
|
|
112
|
+
defaultLocale: ctx.defaultLocale,
|
|
113
|
+
path: ctx.req.path,
|
|
114
|
+
query: ctx.query || {},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
console.info(
|
|
118
|
+
`\x1b[35m[${ctx.method}] ${ctx.rawPath}\x1b[0m -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const assigns = {
|
|
122
|
+
beforeFilterAssigns: {},
|
|
123
|
+
actionAssigns: {},
|
|
124
|
+
afterFilterAssigns: {},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Initialize global context
|
|
128
|
+
ctx.initGlobalContext();
|
|
129
|
+
|
|
130
|
+
// Process before filters
|
|
131
|
+
if (before_filter) {
|
|
143
132
|
const {
|
|
144
|
-
headers,
|
|
145
133
|
redirect,
|
|
146
134
|
json,
|
|
147
|
-
assigns:
|
|
148
|
-
} = (
|
|
149
|
-
assigns.actionAssigns = actionAssigns;
|
|
150
|
-
|
|
151
|
-
this.applyHeaders(headers, routerCtx);
|
|
135
|
+
assigns: beforeFilterAssigns = {},
|
|
136
|
+
} = before_filter(ctx) || {};
|
|
152
137
|
|
|
153
138
|
if (redirect) return routerCtx.redirect(redirect);
|
|
154
139
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
redirect,
|
|
159
|
-
json,
|
|
160
|
-
assigns: afterFilterAssigns = {},
|
|
161
|
-
} = after_filter(ctx) || {};
|
|
140
|
+
if (json) {
|
|
141
|
+
return routerCtx.json(json);
|
|
142
|
+
}
|
|
162
143
|
|
|
163
|
-
|
|
144
|
+
assigns.beforeFilterAssigns = beforeFilterAssigns;
|
|
145
|
+
}
|
|
164
146
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
147
|
+
// Process action
|
|
148
|
+
const {
|
|
149
|
+
headers,
|
|
150
|
+
redirect,
|
|
151
|
+
json,
|
|
152
|
+
assigns: actionAssigns = {},
|
|
153
|
+
} = (await handler(ctx)) || {};
|
|
154
|
+
assigns.actionAssigns = actionAssigns;
|
|
168
155
|
|
|
169
|
-
|
|
170
|
-
|
|
156
|
+
this.applyHeaders(headers, routerCtx);
|
|
157
|
+
|
|
158
|
+
if (redirect) return routerCtx.redirect(redirect);
|
|
159
|
+
|
|
160
|
+
// Process after filters
|
|
161
|
+
if (after_filter) {
|
|
162
|
+
const {
|
|
163
|
+
redirect,
|
|
164
|
+
json,
|
|
165
|
+
assigns: afterFilterAssigns = {},
|
|
166
|
+
} = after_filter(ctx) || {};
|
|
171
167
|
|
|
172
|
-
|
|
173
|
-
...ctx.assigns,
|
|
174
|
-
...assigns.beforeFilterAssigns,
|
|
175
|
-
...assigns.actionAssigns,
|
|
176
|
-
...assigns.afterFilterAssigns,
|
|
177
|
-
_context: _context,
|
|
178
|
-
};
|
|
168
|
+
if (redirect) return routerCtx.redirect(redirect);
|
|
179
169
|
|
|
180
170
|
if (json) {
|
|
181
171
|
return routerCtx.json(json);
|
|
182
172
|
}
|
|
183
173
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
174
|
+
assigns.afterFilterAssigns = afterFilterAssigns;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const fullAssigns = {
|
|
178
|
+
...ctx.assigns,
|
|
179
|
+
...assigns.beforeFilterAssigns,
|
|
180
|
+
...assigns.actionAssigns,
|
|
181
|
+
...assigns.afterFilterAssigns,
|
|
182
|
+
_context: _context,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
if (json) {
|
|
186
|
+
return routerCtx.json(json);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const rendered = this.renderAction({
|
|
190
|
+
views,
|
|
191
|
+
action,
|
|
192
|
+
assigns: fullAssigns,
|
|
191
193
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
|
|
195
|
+
return routerCtx.html(rendered);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
routeCollection(mapping) {
|