5htp-core 0.6.2-91 → 0.6.2-93
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-
|
|
4
|
+
"version": "0.6.2-93",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -197,9 +197,14 @@ export default class Console {
|
|
|
197
197
|
logErrors: string[],
|
|
198
198
|
settings: ISettings<ILogObj>
|
|
199
199
|
) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
try {
|
|
201
|
+
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
202
|
+
settings.prettyInspectOptions = settings.prettyInspectOptions || {};
|
|
203
|
+
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
204
|
+
origLog(logMetaMarkup + formatWithOptions(settings.prettyInspectOptions, ...logArgs) + logErrorsStr);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
origLog("Error formatting log", error);
|
|
207
|
+
}
|
|
203
208
|
},
|
|
204
209
|
}
|
|
205
210
|
});
|
package/server/app/index.ts
CHANGED
|
@@ -105,6 +105,10 @@ export abstract class Application<
|
|
|
105
105
|
this.on('error', (e, request) => this.container.handleBug(e, "An error occured in the application", request));
|
|
106
106
|
|
|
107
107
|
process.on('unhandledRejection', (error: any, promise: any) => {
|
|
108
|
+
|
|
109
|
+
// Log so we know it's coming from unhandledRejection
|
|
110
|
+
console.error("unhandledRejection", error);
|
|
111
|
+
|
|
108
112
|
// We don't log the error here because it's the role of the app to decidehiw to log errors
|
|
109
113
|
this.runHook('error', error);
|
|
110
114
|
});
|
|
@@ -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
|
|
58
|
+
export type TApiRegisterArgs<TRouter extends TServerRouter> = ([
|
|
59
59
|
path: string,
|
|
60
60
|
controller: TServerController<TRouter>
|
|
61
61
|
] | [
|
|
@@ -64,7 +64,7 @@ export type TApiRegisterArgs<TRouter extends ServerRouter<Application>> = ([
|
|
|
64
64
|
controller: TServerController<TRouter>
|
|
65
65
|
])
|
|
66
66
|
|
|
67
|
-
export type TServerController<TRouter extends
|
|
67
|
+
export type TServerController<TRouter extends TServerRouter> = (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,7 @@ export type HttpHeaders = { [cle: string]: string }
|
|
|
83
83
|
const LogPrefix = '[router]';
|
|
84
84
|
|
|
85
85
|
export type Config<
|
|
86
|
-
|
|
87
|
-
TAdditionnalSsrData extends {}
|
|
86
|
+
TServices extends TRouterServicesList
|
|
88
87
|
> = {
|
|
89
88
|
|
|
90
89
|
debug: boolean,
|
|
@@ -98,9 +97,9 @@ export type Config<
|
|
|
98
97
|
context: (
|
|
99
98
|
request: ServerRequest<TServerRouter>,
|
|
100
99
|
app: Application
|
|
101
|
-
) =>
|
|
100
|
+
) => {},
|
|
102
101
|
|
|
103
|
-
plugins:
|
|
102
|
+
plugins: TServices
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
// Set it as a function, so when we instanciate the services, we can callthis.router to pass the router instance in roiuter services
|
|
@@ -118,16 +117,15 @@ export type TControllerDefinition = {
|
|
|
118
117
|
controller: TServerController<TServerRouter>,
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
export type TServerRouter = ServerRouter<Application,
|
|
120
|
+
export type TServerRouter = ServerRouter<Application, TRouterServicesList, Config<TRouterServicesList>>;
|
|
122
121
|
|
|
123
122
|
/*----------------------------------
|
|
124
123
|
- CLASSE
|
|
125
124
|
----------------------------------*/
|
|
126
125
|
export default class ServerRouter<
|
|
127
126
|
TApplication extends Application,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
TAdditionnalSsrData extends {}
|
|
127
|
+
TServices extends TRouterServicesList,
|
|
128
|
+
TConfig extends Config<TServices>,
|
|
131
129
|
>
|
|
132
130
|
extends Service<TConfig, Hooks, TApplication> implements BaseRouter {
|
|
133
131
|
|
|
@@ -156,7 +154,7 @@ export default class ServerRouter<
|
|
|
156
154
|
- SERVICE
|
|
157
155
|
----------------------------------*/
|
|
158
156
|
|
|
159
|
-
public constructor( ...args: TServiceArgs< ServerRouter<TApplication,
|
|
157
|
+
public constructor( ...args: TServiceArgs< ServerRouter<TApplication, TServices, TConfig> >) {
|
|
160
158
|
|
|
161
159
|
super(...args);
|
|
162
160
|
|
|
@@ -12,7 +12,7 @@ import express from 'express';
|
|
|
12
12
|
|
|
13
13
|
// Core
|
|
14
14
|
import { Application } from '@server/app';
|
|
15
|
-
import type ServerRouter from '@server/services/router';
|
|
15
|
+
import type { default as ServerRouter, TServerRouter } from '@server/services/router';
|
|
16
16
|
import ServerRequest from '@server/services/router/request';
|
|
17
17
|
import { TRoute, TAnyRoute, TDomainsList } from '@common/router';
|
|
18
18
|
import { NotFound, Forbidden, Anomaly } from '@common/errors';
|
|
@@ -38,7 +38,7 @@ export type TBasicSSrData = {
|
|
|
38
38
|
domains: TDomainsList
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export type TRouterContext<TRouter extends
|
|
41
|
+
export type TRouterContext<TRouter extends TServerRouter> = (
|
|
42
42
|
// Request context
|
|
43
43
|
{
|
|
44
44
|
app: TRouter["app"],
|
|
@@ -56,13 +56,13 @@ export type TRouterContext<TRouter extends ServerRouter = ServerRouter> = (
|
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
export type TRouterContextServices<
|
|
59
|
-
TRouter extends
|
|
59
|
+
TRouter extends TServerRouter,
|
|
60
60
|
TPlugins = TRouter["config"]["plugins"]
|
|
61
61
|
> = (
|
|
62
62
|
// Custom context via servuces
|
|
63
63
|
// For each roiuter service, return the request service (returned by roiuterService.requestService() )
|
|
64
64
|
{
|
|
65
|
-
[serviceName in keyof TPlugins]: TPlugins[serviceName]
|
|
65
|
+
[serviceName in keyof TPlugins]: TRouter["config"]["plugins"]//TPlugins[serviceName]
|
|
66
66
|
}
|
|
67
67
|
)
|
|
68
68
|
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"
|
|
1
|
+
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"check-circle"|"rocket"|"user-circle"|"plane-departure"|"plus-circle"|"comments-alt"|"chart-bar"|"crosshairs"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"at"|"phone"|"brands/linkedin"|"search"|"lightbulb"|"magnet"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"brands/whatsapp"|"plus"|"minus"|"trash"|"check"|"clock"|"cog"|"ellipsis-h"|"play"|"stop"|"regular/shield-check"|"angle-down"|"angle-up"|"solid/crown"|"eye"|"pen"|"file"|"envelope"|"coins"|"download"|"exclamation-circle"|"times-circle"|"bars"|"arrow-left"|"meh-rolling-eyes"|"minus-circle"|"chevron-left"|"bolt"|"key"|"power-off"|"comment-alt"|"external-link"|"question-circle"|"wind"|"broom"|"brands/google"|"copy"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"users"|"bug"|"binoculars"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"coin"|"plug"|"angle-left"|"angle-right"|"arrow-to-bottom"|"magic"|"solid/magic"|"map-marker"|"fire"|"globe"|"industry"|"calendar"|"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"
|