5htp-core 0.6.2-8 → 0.6.2-9

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.6.2-8",
4
+ "version": "0.6.2-9",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -55,7 +55,7 @@ export type { default as Request, UploadedFile } from "./request";
55
55
  export type { default as Response, TRouterContext } from "./response";
56
56
  export type { TRoute, TAnyRoute } from '@common/router';
57
57
 
58
- export type TApiRegisterArgs<TRouter extends ServerRouter> = ([
58
+ export type TApiRegisterArgs<TRouter extends ServerRouter<Application>> = ([
59
59
  path: string,
60
60
  controller: TServerController<TRouter>
61
61
  ] | [
@@ -64,7 +64,7 @@ export type TApiRegisterArgs<TRouter extends ServerRouter> = ([
64
64
  controller: TServerController<TRouter>
65
65
  ])
66
66
 
67
- export type TServerController<TRouter extends ServerRouter> = (context: TRouterContext<TRouter>) => any;
67
+ export type TServerController<TRouter extends ServerRouter<Application>> = (context: TRouterContext<TRouter>) => any;
68
68
 
69
69
  export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'
70
70
  export type TRouteHttpMethod = HttpMethod | '*';
@@ -83,8 +83,8 @@ export type HttpHeaders = { [cle: string]: string }
83
83
  const LogPrefix = '[router]';
84
84
 
85
85
  export type Config<
86
- TServiceList extends TRouterServicesList = TRouterServicesList,
87
- TAdditionnalSsrData extends {} = {}
86
+ TServiceList extends TRouterServicesList,
87
+ TAdditionnalSsrData extends {}
88
88
  > = {
89
89
 
90
90
  debug: boolean,
@@ -96,18 +96,16 @@ export type Config<
96
96
  http: HttpServiceConfig,
97
97
 
98
98
  context: (
99
- request: ServerRequest<ServerRouter>,
99
+ request: ServerRequest<TServerRouter>,
100
100
  app: Application
101
101
  ) => TAdditionnalSsrData,
102
102
 
103
- plugins: {
104
- [routerServiceId: string]: RouterService
105
- }
103
+ plugins: TServiceList
106
104
  }
107
105
 
108
106
  // Set it as a function, so when we instanciate the services, we can callthis.router to pass the router instance in roiuter services
109
107
  type TRouterServicesList = {
110
- [serviceName: string]: RouterService<ServerRouter>
108
+ [serviceName: string]: RouterService<TServerRouter>
111
109
  }
112
110
 
113
111
  export type Hooks = {
@@ -117,14 +115,21 @@ export type Hooks = {
117
115
  export type TControllerDefinition = {
118
116
  path?: string,
119
117
  schema?: zod.ZodSchema,
120
- controller: TServerController<ServerRouter>,
118
+ controller: TServerController<TServerRouter>,
121
119
  }
122
120
 
121
+ export type TServerRouter = ServerRouter<Application, Config<TRouterServicesList, {}>, TRouterServicesList, {}>;
122
+
123
123
  /*----------------------------------
124
124
  - CLASSE
125
125
  ----------------------------------*/
126
- export default class ServerRouter
127
- extends Service<Config, Hooks, Application> implements BaseRouter {
126
+ export default class ServerRouter<
127
+ TApplication extends Application,
128
+ TConfig extends Config<TServiceList, TAdditionnalSsrData>,
129
+ TServiceList extends TRouterServicesList,
130
+ TAdditionnalSsrData extends {}
131
+ >
132
+ extends Service<TConfig, Hooks, TApplication> implements BaseRouter {
128
133
 
129
134
  public disks = this.use<DisksManager>('Core/Disks', { optional: true });
130
135
 
@@ -151,7 +156,7 @@ export default class ServerRouter
151
156
  - SERVICE
152
157
  ----------------------------------*/
153
158
 
154
- public constructor( ...args: TServiceArgs<ServerRouter>) {
159
+ public constructor( ...args: TServiceArgs< ServerRouter<TApplication, TConfig, TServiceList, TAdditionnalSsrData> >) {
155
160
 
156
161
  super(...args);
157
162
 
@@ -52,14 +52,17 @@ export type TRouterContext<TRouter extends ServerRouter = ServerRouter> = (
52
52
 
53
53
  Router: TRouter,
54
54
  }
55
- //& TRouterContextServices<TRouter>
55
+ & TRouterContextServices<TRouter>
56
56
  )
57
57
 
58
- export type TRouterContextServices<TRouter extends ServerRouter> = (
58
+ export type TRouterContextServices<
59
+ TRouter extends ServerRouter<Application>,
60
+ TPlugins = TRouter["config"]["plugins"]
61
+ > = (
59
62
  // Custom context via servuces
60
63
  // For each roiuter service, return the request service (returned by roiuterService.requestService() )
61
64
  {
62
- [serviceName in keyof TRouter["services"]]: ReturnType< TRouter["services"][serviceName]["requestService"] >
65
+ [serviceName in keyof TPlugins]: TPlugins[serviceName]
63
66
  }
64
67
  )
65
68
 
@@ -8,7 +8,7 @@ import { SomeType } from 'zod/v4/core';
8
8
 
9
9
  // Core
10
10
  import {
11
- default as Router, RequestService, Request as ServerRequest
11
+ default as Router, TServerRouter, Request as ServerRequest
12
12
  } from '@server/services/router';
13
13
 
14
14
  // Ap
@@ -28,7 +28,7 @@ export type TConfig = {
28
28
  - SERVICE
29
29
  ----------------------------------*/
30
30
  export default(
31
- request: ServerRequest<Router>,
31
+ request: ServerRequest< TServerRouter >,
32
32
  config: TConfig,
33
33
  router = request.router,
34
34
  app = router.app
@@ -38,10 +38,10 @@ export default(
38
38
 
39
39
  validate( fields: zod.ZodSchema | { [key: string]: zod.ZodSchema } ) {
40
40
 
41
- this.config.debug && console.log(LogPrefix, "Validate request data:", this.request.data);
41
+ config.debug && console.log(LogPrefix, "Validate request data:", request.data);
42
42
 
43
43
  const schema = typeof fields === 'object' ? zod.object(fields) : fields;
44
44
 
45
- return schema.parse(this.request.data);
45
+ return schema.parse(request.data);
46
46
  },
47
47
  })
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"rocket"|"user-circle"|"crosshairs"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"plane-departure"|"plus-circle"|"comments-alt"|"chart-bar"|"calendar-alt"|"paper-plane"|"at"|"search"|"lightbulb"|"magnet"|"phone"|"brands/linkedin"|"brands/whatsapp"|"user"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"plus"|"minus"|"trash"|"play"|"stop"|"clock"|"cog"|"ellipsis-h"|"check"|"regular/shield-check"|"angle-down"|"angle-up"|"solid/crown"|"eye"|"pen"|"file"|"envelope"|"coins"|"download"|"exclamation-circle"|"times-circle"|"meh-rolling-eyes"|"arrow-left"|"bars"|"chevron-left"|"bolt"|"key"|"power-off"|"comment-alt"|"question-circle"|"wind"|"minus-circle"|"external-link"|"brands/google"|"broom"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"copy"|"users"|"bug"|"binoculars"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"coin"|"angle-left"|"angle-right"|"plug"|"arrow-to-bottom"|"solid/magic"|"industry"|"map-marker"|"calendar"|"fire"|"magic"|"globe"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"rocket"|"crosshairs"|"plane-departure"|"plus-circle"|"comments-alt"|"arrow-right"|"chart-bar"|"user-circle"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"at"|"search"|"lightbulb"|"magnet"|"phone"|"brands/linkedin"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"brands/whatsapp"|"user"|"plus"|"minus"|"trash"|"play"|"stop"|"solid/crown"|"eye"|"pen"|"file"|"envelope"|"angle-up"|"angle-down"|"check"|"clock"|"cog"|"ellipsis-h"|"coins"|"regular/shield-check"|"download"|"exclamation-circle"|"times-circle"|"meh-rolling-eyes"|"arrow-left"|"bars"|"chevron-left"|"bolt"|"key"|"power-off"|"comment-alt"|"question-circle"|"minus-circle"|"wind"|"external-link"|"broom"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"brands/google"|"coin"|"angle-left"|"angle-right"|"users"|"bug"|"binoculars"|"arrow-to-bottom"|"plug"|"copy"|"solid/magic"|"map-marker"|"fire"|"globe"|"industry"|"calendar"|"magic"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"