@harpy-js/core 0.5.7 → 0.5.8
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/dist/client/router.d.ts +11 -0
- package/dist/client/router.js +142 -0
- package/dist/client/use-router.d.ts +6 -0
- package/dist/client/use-router.js +35 -0
- package/dist/core/spa-router.controller.d.ts +4 -0
- package/dist/core/spa-router.controller.js +40 -0
- package/dist/core/types/nav.types.d.ts +1 -0
- package/package.json +1 -1
- package/src/core/types/nav.types.ts +5 -0
- package/dist/core/lazy-route-loader.service.d.ts +0 -28
- package/dist/core/lazy-route-loader.service.js +0 -79
- package/dist/core/lazy-routes.module.d.ts +0 -2
- package/dist/core/lazy-routes.module.js +0 -21
- package/dist/decorators/lazy-route.decorator.d.ts +0 -12
- package/dist/decorators/lazy-route.decorator.js +0 -22
- package/dist/hydration-manifest.json +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RouterOptions {
|
|
2
|
+
onLoadingStart?: () => void;
|
|
3
|
+
onLoadingEnd?: () => void;
|
|
4
|
+
onError?: (error: Error) => void;
|
|
5
|
+
enablePrefetch?: boolean;
|
|
6
|
+
contentSelector?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function prefetchPage(url: string): void;
|
|
9
|
+
export declare function initRouter(options?: RouterOptions): () => void;
|
|
10
|
+
export declare function clearPageCache(): void;
|
|
11
|
+
export declare function navigateTo(url: string, options?: RouterOptions): void;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.prefetchPage = prefetchPage;
|
|
5
|
+
exports.initRouter = initRouter;
|
|
6
|
+
exports.clearPageCache = clearPageCache;
|
|
7
|
+
exports.navigateTo = navigateTo;
|
|
8
|
+
const pageCache = new Map();
|
|
9
|
+
let isNavigating = false;
|
|
10
|
+
async function fetchPageData(url) {
|
|
11
|
+
if (pageCache.has(url)) {
|
|
12
|
+
return pageCache.get(url);
|
|
13
|
+
}
|
|
14
|
+
const response = await fetch(url, {
|
|
15
|
+
headers: {
|
|
16
|
+
'X-Harpy-SPA': 'true',
|
|
17
|
+
'Accept': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`Failed to fetch page: ${response.status} ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
pageCache.set(url, data);
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
function updatePageContent(html, title, contentSelector) {
|
|
28
|
+
if (title) {
|
|
29
|
+
document.title = title;
|
|
30
|
+
}
|
|
31
|
+
const container = document.querySelector(contentSelector);
|
|
32
|
+
if (!container) {
|
|
33
|
+
console.error(`[Harpy Router] Content container not found: ${contentSelector}`);
|
|
34
|
+
window.location.reload();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
container.innerHTML = html;
|
|
38
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
39
|
+
const scripts = container.querySelectorAll('script');
|
|
40
|
+
scripts.forEach((oldScript) => {
|
|
41
|
+
const newScript = document.createElement('script');
|
|
42
|
+
Array.from(oldScript.attributes).forEach((attr) => {
|
|
43
|
+
newScript.setAttribute(attr.name, attr.value);
|
|
44
|
+
});
|
|
45
|
+
newScript.textContent = oldScript.textContent;
|
|
46
|
+
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function navigate(url, options) {
|
|
50
|
+
console.log('[Harpy Router] navigate() called for:', url, 'isNavigating:', isNavigating);
|
|
51
|
+
if (isNavigating) {
|
|
52
|
+
console.log('[Harpy Router] Navigation already in progress, skipping');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
isNavigating = true;
|
|
56
|
+
try {
|
|
57
|
+
console.log('[Harpy Router] Starting navigation...');
|
|
58
|
+
window.dispatchEvent(new Event('harpy:loading-start'));
|
|
59
|
+
options.onLoadingStart?.();
|
|
60
|
+
console.log('[Harpy Router] Fetching page data...');
|
|
61
|
+
const data = await fetchPageData(url);
|
|
62
|
+
console.log('[Harpy Router] Received page data:', data);
|
|
63
|
+
updatePageContent(data.html, data.title, options.contentSelector || '#__harpy_content');
|
|
64
|
+
window.dispatchEvent(new Event('harpy:loading-end'));
|
|
65
|
+
options.onLoadingEnd?.();
|
|
66
|
+
console.log('[Harpy Router] Navigation complete');
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('[Harpy Router] Navigation error:', error);
|
|
70
|
+
window.dispatchEvent(new Event('harpy:loading-end'));
|
|
71
|
+
options.onError?.(error);
|
|
72
|
+
console.log('[Harpy Router] Falling back to full page navigation');
|
|
73
|
+
window.location.href = url;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
isNavigating = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function prefetchPage(url) {
|
|
80
|
+
if (pageCache.has(url) || !url.startsWith('/')) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
fetchPageData(url).catch((err) => {
|
|
84
|
+
console.warn('[Harpy Router] Prefetch failed:', err);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function initRouter(options = {}) {
|
|
88
|
+
if (typeof window === 'undefined') {
|
|
89
|
+
console.warn('[Harpy Router] Cannot initialize router on server');
|
|
90
|
+
return () => { };
|
|
91
|
+
}
|
|
92
|
+
console.log('[Harpy Router] Initializing SPA router');
|
|
93
|
+
const handlePopState = (event) => {
|
|
94
|
+
const url = window.location.pathname + window.location.search;
|
|
95
|
+
console.log('[Harpy Router] Popstate event, navigating to:', url);
|
|
96
|
+
navigate(url, options);
|
|
97
|
+
};
|
|
98
|
+
const handleLinkHover = (event) => {
|
|
99
|
+
if (!options.enablePrefetch)
|
|
100
|
+
return;
|
|
101
|
+
const target = event.target;
|
|
102
|
+
const link = target.closest('a');
|
|
103
|
+
if (link && link.href.startsWith(window.location.origin)) {
|
|
104
|
+
const url = new URL(link.href);
|
|
105
|
+
prefetchPage(url.pathname + url.search);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
window.addEventListener('popstate', handlePopState);
|
|
109
|
+
if (options.enablePrefetch) {
|
|
110
|
+
document.addEventListener('mouseover', handleLinkHover);
|
|
111
|
+
}
|
|
112
|
+
const handleCustomNavigation = ((event) => {
|
|
113
|
+
const url = event.detail.url;
|
|
114
|
+
console.log('[Harpy Router] Received harpy:navigate event for:', url);
|
|
115
|
+
navigate(url, options);
|
|
116
|
+
});
|
|
117
|
+
const handlePrefetchEvent = ((event) => {
|
|
118
|
+
const url = event.detail.url;
|
|
119
|
+
console.log('[Harpy Router] Received harpy:prefetch event for:', url);
|
|
120
|
+
prefetchPage(url);
|
|
121
|
+
});
|
|
122
|
+
console.log('[Harpy Router] Adding event listeners');
|
|
123
|
+
window.addEventListener('harpy:navigate', handleCustomNavigation);
|
|
124
|
+
window.addEventListener('harpy:prefetch', handlePrefetchEvent);
|
|
125
|
+
return () => {
|
|
126
|
+
console.log('[Harpy Router] Cleaning up router');
|
|
127
|
+
window.removeEventListener('popstate', handlePopState);
|
|
128
|
+
window.removeEventListener('harpy:navigate', handleCustomNavigation);
|
|
129
|
+
window.removeEventListener('harpy:prefetch', handlePrefetchEvent);
|
|
130
|
+
if (options.enablePrefetch) {
|
|
131
|
+
document.removeEventListener('mouseover', handleLinkHover);
|
|
132
|
+
}
|
|
133
|
+
pageCache.clear();
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function clearPageCache() {
|
|
137
|
+
pageCache.clear();
|
|
138
|
+
}
|
|
139
|
+
function navigateTo(url, options = {}) {
|
|
140
|
+
window.history.pushState({}, '', url);
|
|
141
|
+
navigate(url, options);
|
|
142
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useRouter = useRouter;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useRouter() {
|
|
7
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const handleLoadingStart = () => setIsLoading(true);
|
|
10
|
+
const handleLoadingEnd = () => setIsLoading(false);
|
|
11
|
+
window.addEventListener('harpy:loading-start', handleLoadingStart);
|
|
12
|
+
window.addEventListener('harpy:loading-end', handleLoadingEnd);
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener('harpy:loading-start', handleLoadingStart);
|
|
15
|
+
window.removeEventListener('harpy:loading-end', handleLoadingEnd);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
const navigate = (0, react_1.useCallback)((url, replace = false) => {
|
|
19
|
+
const method = replace ? 'replaceState' : 'pushState';
|
|
20
|
+
window.history[method]({}, '', url);
|
|
21
|
+
window.dispatchEvent(new CustomEvent('harpy:navigate', {
|
|
22
|
+
detail: { url, replace },
|
|
23
|
+
}));
|
|
24
|
+
}, []);
|
|
25
|
+
const prefetch = (0, react_1.useCallback)((url) => {
|
|
26
|
+
window.dispatchEvent(new CustomEvent('harpy:prefetch', {
|
|
27
|
+
detail: { url },
|
|
28
|
+
}));
|
|
29
|
+
}, []);
|
|
30
|
+
return {
|
|
31
|
+
isLoading,
|
|
32
|
+
navigate,
|
|
33
|
+
prefetch,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SpaRouterController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let SpaRouterController = class SpaRouterController {
|
|
18
|
+
async handleSpaRequest(req, res) {
|
|
19
|
+
const isSpaRequest = req.headers['x-harpy-spa'] === 'true';
|
|
20
|
+
if (!isSpaRequest) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return res.status(501).send({
|
|
24
|
+
error: 'SPA navigation not yet fully implemented',
|
|
25
|
+
message: 'The SPA router is being set up. Full implementation coming soon.',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.SpaRouterController = SpaRouterController;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, common_1.Get)('*'),
|
|
32
|
+
__param(0, (0, common_1.Req)()),
|
|
33
|
+
__param(1, (0, common_1.Res)()),
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
36
|
+
__metadata("design:returntype", Promise)
|
|
37
|
+
], SpaRouterController.prototype, "handleSpaRequest", null);
|
|
38
|
+
exports.SpaRouterController = SpaRouterController = __decorate([
|
|
39
|
+
(0, common_1.Controller)()
|
|
40
|
+
], SpaRouterController);
|
package/package.json
CHANGED
|
@@ -14,6 +14,11 @@ export interface NavItem {
|
|
|
14
14
|
* If omitted, registration order is used as a tiebreaker.
|
|
15
15
|
*/
|
|
16
16
|
order?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Optional badge to display next to the item (e.g., 'NEW', 'BETA', 'UPDATED').
|
|
19
|
+
* Used to highlight newly added or updated navigation items.
|
|
20
|
+
*/
|
|
21
|
+
badge?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export interface NavSection {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Type } from '@nestjs/common';
|
|
2
|
-
import { LazyModuleLoader } from '@nestjs/core';
|
|
3
|
-
import type { FastifyRequest, FastifyReply } from 'fastify';
|
|
4
|
-
export interface LazyRouteConfig {
|
|
5
|
-
id: string;
|
|
6
|
-
path: string;
|
|
7
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
8
|
-
moduleLoader: () => Promise<Type<any>>;
|
|
9
|
-
controllerLoader: () => Promise<Type<any>>;
|
|
10
|
-
handlerMethod: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class LazyRouteLoaderService {
|
|
13
|
-
private readonly lazyModuleLoader;
|
|
14
|
-
private readonly logger;
|
|
15
|
-
private readonly loadedModules;
|
|
16
|
-
private readonly registeredRoutes;
|
|
17
|
-
constructor(lazyModuleLoader: LazyModuleLoader);
|
|
18
|
-
registerLazyRoute(config: LazyRouteConfig): void;
|
|
19
|
-
getRegisteredRoutes(): LazyRouteConfig[];
|
|
20
|
-
handleLazyRoute(config: LazyRouteConfig, req: FastifyRequest, reply: FastifyReply): Promise<any>;
|
|
21
|
-
isModuleLoaded(moduleId: string): boolean;
|
|
22
|
-
getStatistics(): {
|
|
23
|
-
totalRegistered: number;
|
|
24
|
-
totalLoaded: number;
|
|
25
|
-
loadedModules: string[];
|
|
26
|
-
registeredRoutes: string[];
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var LazyRouteLoaderService_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.LazyRouteLoaderService = void 0;
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
|
-
const core_1 = require("@nestjs/core");
|
|
16
|
-
let LazyRouteLoaderService = LazyRouteLoaderService_1 = class LazyRouteLoaderService {
|
|
17
|
-
lazyModuleLoader;
|
|
18
|
-
logger = new common_1.Logger(LazyRouteLoaderService_1.name);
|
|
19
|
-
loadedModules = new Map();
|
|
20
|
-
registeredRoutes = new Map();
|
|
21
|
-
constructor(lazyModuleLoader) {
|
|
22
|
-
this.lazyModuleLoader = lazyModuleLoader;
|
|
23
|
-
}
|
|
24
|
-
registerLazyRoute(config) {
|
|
25
|
-
const routeKey = `${config.method}:${config.path}`;
|
|
26
|
-
this.registeredRoutes.set(routeKey, config);
|
|
27
|
-
this.logger.log(`Registered lazy route: ${routeKey} -> ${config.id}`);
|
|
28
|
-
}
|
|
29
|
-
getRegisteredRoutes() {
|
|
30
|
-
return Array.from(this.registeredRoutes.values());
|
|
31
|
-
}
|
|
32
|
-
async handleLazyRoute(config, req, reply) {
|
|
33
|
-
try {
|
|
34
|
-
let moduleRef = this.loadedModules.get(config.id);
|
|
35
|
-
if (!moduleRef) {
|
|
36
|
-
this.logger.log(`Loading lazy module: ${config.id}...`);
|
|
37
|
-
const startTime = Date.now();
|
|
38
|
-
const ModuleClass = await config.moduleLoader();
|
|
39
|
-
moduleRef = await this.lazyModuleLoader.load(() => ModuleClass);
|
|
40
|
-
this.loadedModules.set(config.id, moduleRef);
|
|
41
|
-
const loadTime = Date.now() - startTime;
|
|
42
|
-
this.logger.log(`Lazy module ${config.id} loaded in ${loadTime}ms`);
|
|
43
|
-
}
|
|
44
|
-
const ControllerClass = await config.controllerLoader();
|
|
45
|
-
const controller = moduleRef.get(ControllerClass, { strict: false });
|
|
46
|
-
if (!controller) {
|
|
47
|
-
throw new Error(`Controller instance not found in lazy module ${config.id}`);
|
|
48
|
-
}
|
|
49
|
-
const handler = controller[config.handlerMethod];
|
|
50
|
-
if (!handler || typeof handler !== 'function') {
|
|
51
|
-
throw new Error(`Handler method ${config.handlerMethod} not found in controller`);
|
|
52
|
-
}
|
|
53
|
-
const result = await handler.call(controller, req, reply);
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
58
|
-
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
59
|
-
this.logger.error(`Failed to handle lazy route ${config.id}: ${errorMessage}`, errorStack);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
isModuleLoaded(moduleId) {
|
|
64
|
-
return this.loadedModules.has(moduleId);
|
|
65
|
-
}
|
|
66
|
-
getStatistics() {
|
|
67
|
-
return {
|
|
68
|
-
totalRegistered: this.registeredRoutes.size,
|
|
69
|
-
totalLoaded: this.loadedModules.size,
|
|
70
|
-
loadedModules: Array.from(this.loadedModules.keys()),
|
|
71
|
-
registeredRoutes: Array.from(this.registeredRoutes.keys()),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
exports.LazyRouteLoaderService = LazyRouteLoaderService;
|
|
76
|
-
exports.LazyRouteLoaderService = LazyRouteLoaderService = LazyRouteLoaderService_1 = __decorate([
|
|
77
|
-
(0, common_1.Injectable)(),
|
|
78
|
-
__metadata("design:paramtypes", [core_1.LazyModuleLoader])
|
|
79
|
-
], LazyRouteLoaderService);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.LazyRoutesModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const lazy_route_loader_service_1 = require("./lazy-route-loader.service");
|
|
12
|
-
let LazyRoutesModule = class LazyRoutesModule {
|
|
13
|
-
};
|
|
14
|
-
exports.LazyRoutesModule = LazyRoutesModule;
|
|
15
|
-
exports.LazyRoutesModule = LazyRoutesModule = __decorate([
|
|
16
|
-
(0, common_1.Global)(),
|
|
17
|
-
(0, common_1.Module)({
|
|
18
|
-
providers: [lazy_route_loader_service_1.LazyRouteLoaderService],
|
|
19
|
-
exports: [lazy_route_loader_service_1.LazyRouteLoaderService],
|
|
20
|
-
})
|
|
21
|
-
], LazyRoutesModule);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const LAZY_ROUTE_METADATA = "harpy:lazy-route";
|
|
2
|
-
export interface LazyRouteDecoratorConfig {
|
|
3
|
-
id: string;
|
|
4
|
-
moduleLoader: () => Promise<any>;
|
|
5
|
-
controllerLoader: () => Promise<any>;
|
|
6
|
-
handlerMethod: string;
|
|
7
|
-
}
|
|
8
|
-
export interface LazyRouteMetadata extends LazyRouteDecoratorConfig {
|
|
9
|
-
path: string;
|
|
10
|
-
method: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function LazyRoute(path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH', config: LazyRouteDecoratorConfig): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LAZY_ROUTE_METADATA = void 0;
|
|
4
|
-
exports.LazyRoute = LazyRoute;
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
exports.LAZY_ROUTE_METADATA = 'harpy:lazy-route';
|
|
7
|
-
function LazyRoute(path, method, config) {
|
|
8
|
-
const methodDecorator = method === 'GET'
|
|
9
|
-
? (0, common_1.Get)(path)
|
|
10
|
-
: method === 'POST'
|
|
11
|
-
? (0, common_1.Post)(path)
|
|
12
|
-
: method === 'PUT'
|
|
13
|
-
? (0, common_1.Put)(path)
|
|
14
|
-
: method === 'DELETE'
|
|
15
|
-
? (0, common_1.Delete)(path)
|
|
16
|
-
: (0, common_1.Patch)(path);
|
|
17
|
-
return (0, common_1.applyDecorators)(methodDecorator, (0, common_1.SetMetadata)(exports.LAZY_ROUTE_METADATA, {
|
|
18
|
-
...config,
|
|
19
|
-
path,
|
|
20
|
-
method,
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|