5htp-core 0.2.9 → 0.3.0-2
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 +7 -5
- package/src/client/app/component.tsx +2 -2
- package/src/client/assets/css/text/titres.less +4 -0
- package/src/client/components/Dialog/card.tsx +1 -1
- package/src/client/components/Dialog/index.less +3 -3
- package/src/client/components/inputv3/date/index.tsx +1 -1
- package/src/client/components/inputv3/index.tsx +14 -4
- package/src/client/pages/_layout/index.tsx +3 -3
- package/src/client/pages/_messages/400.tsx +2 -2
- package/src/client/pages/_messages/401.tsx +2 -2
- package/src/client/pages/_messages/403.tsx +2 -2
- package/src/client/pages/_messages/404.tsx +2 -2
- package/src/client/pages/_messages/500.tsx +2 -2
- package/src/client/pages/useHeader.tsx +2 -1
- package/src/client/services/router/components/router.tsx +1 -1
- package/src/client/services/router/index.tsx +26 -1
- package/src/client/services/router/response/index.tsx +5 -2
- package/src/common/data/objets.ts +0 -25
- package/src/common/router/index.ts +8 -12
- package/src/common/router/layouts.ts +3 -1
- package/src/common/router/register.ts +5 -3
- package/src/common/router/response/index.ts +3 -3
- package/src/common/validation/validators.ts +12 -1
- package/src/server/app/commands.ts +11 -4
- package/src/server/app/{config.ts → container/config.ts} +5 -1
- package/src/server/app/container/index.ts +87 -0
- package/src/server/app/index.ts +73 -136
- package/src/server/app/instance.ts +3 -0
- package/src/server/app/service/container.ts +140 -0
- package/src/server/app/service/index.ts +235 -0
- package/src/server/app.tsconfig.json +2 -0
- package/src/server/index.ts +9 -3
- package/src/server/services/cache/index.ts +45 -17
- package/src/server/services/cache/service.json +6 -0
- package/src/server/services/console/index.ts +40 -23
- package/src/server/services/console/service.json +6 -0
- package/src/server/services/cron/index.ts +16 -12
- package/src/server/services/cron/service.json +6 -0
- package/src/server/services/database/connection.ts +26 -34
- package/src/server/services/database/index.ts +45 -21
- package/src/server/services/database/metas.ts +12 -7
- package/src/server/services/database/repository.ts +0 -9
- package/src/server/services/database/service.json +6 -0
- package/src/server/services/database/stats.ts +3 -3
- package/src/server/services/disks/driver.ts +13 -7
- package/src/server/services/disks/drivers/local/index.ts +199 -0
- package/src/server/services/disks/drivers/local/service.json +6 -0
- package/src/server/services/disks/drivers/s3/index.ts +282 -0
- package/src/server/services/disks/drivers/s3/service.json +6 -0
- package/src/server/services/disks/index.ts +52 -19
- package/src/server/services/disks/service.json +6 -0
- package/src/server/services/email/index.ts +21 -5
- package/src/server/services/email/service.json +6 -0
- package/src/server/services/fetch/index.ts +52 -8
- package/src/server/services/fetch/service.json +6 -0
- package/src/server/services/router/http/index.ts +12 -9
- package/src/server/services/router/index.ts +97 -68
- package/src/server/services/router/request/api.ts +1 -1
- package/src/server/services/router/response/index.ts +13 -19
- package/src/server/services/router/service.json +6 -0
- package/src/server/services/router/service.ts +21 -30
- package/src/server/services/schema/{router.ts → router/index.ts} +19 -7
- package/src/server/services/schema/router/service.json +6 -0
- package/src/server/services/schema/service.json +6 -0
- package/src/server/services/security/encrypt/{aes.ts → aes/index.ts} +25 -9
- package/src/server/services/security/encrypt/aes/service.json +6 -0
- package/src/server/services/socket/index.ts +35 -23
- package/src/server/services/socket/service.json +6 -0
- package/src/server/services/users/index.ts +21 -5
- package/src/server/services/users/old.ts +1 -1
- package/src/server/services/users/router/index.ts +21 -14
- package/src/server/services/users/router/service.json +6 -0
- package/src/server/services/users/service.json +6 -0
- package/src/types/aliases.d.ts +5 -0
- package/tsconfig.common.json +2 -0
- package/src/server/app/service.ts +0 -109
- /package/src/server/{patch.ts → app/container/patch.ts} +0 -0
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.2
|
|
4
|
+
"version": "0.3.0-2",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"framework"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@wojtekmaj/react-daterange-picker": "^
|
|
16
|
+
"@wojtekmaj/react-daterange-picker": "^5.0.2",
|
|
17
17
|
"accepts": "^1.3.7",
|
|
18
18
|
"activity-detector": "^3.0.0",
|
|
19
19
|
"ansi-to-html": "^0.7.1",
|
|
20
20
|
"array-move": "^3.0.1",
|
|
21
|
+
"aws-sdk": "^2.1415.0",
|
|
21
22
|
"axios": "^1.2.1",
|
|
22
23
|
"bowser": "^2.11.0",
|
|
23
24
|
"chart.js": "^3.6.2",
|
|
@@ -60,10 +61,12 @@
|
|
|
60
61
|
"mysql2": "^2.3.0",
|
|
61
62
|
"nodemailer": "^6.6.3",
|
|
62
63
|
"object-sizeof": "^1.6.3",
|
|
64
|
+
"ololog": "^1.1.175",
|
|
63
65
|
"path-to-regexp": "^6.2.0",
|
|
64
66
|
"picomatch": "^2.3.1",
|
|
65
67
|
"preact": "^10.5.15",
|
|
66
68
|
"preact-render-to-string": "^5.1.19",
|
|
69
|
+
"react-datetime-picker": "^5.0.3",
|
|
67
70
|
"react-scrollbars-custom": "^4.0.27",
|
|
68
71
|
"react-slider": "^2.0.1",
|
|
69
72
|
"react-textarea-autosize": "^8.3.3",
|
|
@@ -72,7 +75,6 @@
|
|
|
72
75
|
"request": "^2.88.2",
|
|
73
76
|
"sharp": "^0.29.1",
|
|
74
77
|
"sql-formatter": "^4.0.2",
|
|
75
|
-
"tslog": "^3.2.2",
|
|
76
78
|
"uuid": "^8.3.2",
|
|
77
79
|
"uuid-by-string": "^3.0.4",
|
|
78
80
|
"validator": "^13.7.0",
|
|
@@ -92,9 +94,9 @@
|
|
|
92
94
|
"@types/webpack-env": "^1.16.2",
|
|
93
95
|
"@types/ws": "^7.4.7",
|
|
94
96
|
"@types/yargs-parser": "^21.0.0",
|
|
95
|
-
"babel-plugin-glob-import": "^0.0.
|
|
97
|
+
"babel-plugin-glob-import": "^0.0.7"
|
|
96
98
|
},
|
|
97
99
|
"peerDependencies": {
|
|
98
|
-
"5htp": "0.
|
|
100
|
+
"5htp": "0.3.0-1"
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -11,7 +11,7 @@ import { ReactClientContext } from '@/client/context';
|
|
|
11
11
|
import DialogManager from '@client/components/Dialog/Manager'
|
|
12
12
|
|
|
13
13
|
// Core components
|
|
14
|
-
import
|
|
14
|
+
import RouterComponent from '@client/services/router/components/router';
|
|
15
15
|
import type { TClientOrServerContext } from '@common/router';
|
|
16
16
|
|
|
17
17
|
/*----------------------------------
|
|
@@ -35,7 +35,7 @@ export default function App ({ context }: {
|
|
|
35
35
|
|
|
36
36
|
{!layout ? <>
|
|
37
37
|
{/* TODO: move to app, because here, we're not aware that the router service has been defined */}
|
|
38
|
-
<
|
|
38
|
+
<RouterComponent service={context.Router} />
|
|
39
39
|
</> : <>
|
|
40
40
|
<layout.Component context={context} />
|
|
41
41
|
</>}
|
|
@@ -169,7 +169,7 @@ export default ({
|
|
|
169
169
|
) : title}
|
|
170
170
|
|
|
171
171
|
{(!prison && close) && (
|
|
172
|
-
<Button class="close" icon="
|
|
172
|
+
<Button class="close" icon="times" size="s" shape="pill" onClick={async () => {
|
|
173
173
|
if (typeof close === "function") {
|
|
174
174
|
|
|
175
175
|
if (onClose !== undefined)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@toast-zindex: 999;
|
|
2
2
|
|
|
3
|
-
#modals,
|
|
3
|
+
#modals,
|
|
4
|
+
#toasts {
|
|
4
5
|
|
|
5
6
|
z-index: @toast-zindex;
|
|
6
7
|
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
// Desktop = vertically center the modal
|
|
61
62
|
@media (min-width: 900px) {
|
|
62
63
|
justify-content: center;
|
|
63
|
-
padding: @spacing;
|
|
64
|
+
//padding: @spacing;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
// Pour les animations (ex: conffetis
|
|
@@ -79,7 +80,6 @@
|
|
|
79
80
|
min-width: 300px;
|
|
80
81
|
max-height: 100vh;
|
|
81
82
|
box-shadow: none;
|
|
82
|
-
padding: @spacing * 2;
|
|
83
83
|
overflow-y: auto;
|
|
84
84
|
|
|
85
85
|
// Pas d'anim quand pas card,
|
|
@@ -58,7 +58,7 @@ export default ({
|
|
|
58
58
|
- INIT
|
|
59
59
|
----------------------------------*/
|
|
60
60
|
|
|
61
|
-
const [{ value, focus, fieldProps }, setValue, commitValue, setState] = useInput(props, '');
|
|
61
|
+
const [{ value, focus, fieldProps }, setValue, commitValue, setState] = useInput(props, '' );
|
|
62
62
|
|
|
63
63
|
// Trigger onchange oly when finished typing
|
|
64
64
|
const refCommit = React.useRef<NodeJS.Timeout | null>(null);
|
|
@@ -71,7 +71,17 @@ export default ({
|
|
|
71
71
|
|
|
72
72
|
}, [value]);
|
|
73
73
|
|
|
74
|
-
const updateValue = v =>
|
|
74
|
+
const updateValue = v => {
|
|
75
|
+
if (type === 'number') {
|
|
76
|
+
|
|
77
|
+
// Fix on Safari: the browser allows to input text in input number
|
|
78
|
+
const numberValue = parseFloat(v);
|
|
79
|
+
if (!Number.isNaN( numberValue ))
|
|
80
|
+
setValue(numberValue);
|
|
81
|
+
|
|
82
|
+
} else
|
|
83
|
+
setValue(v);
|
|
84
|
+
}
|
|
75
85
|
|
|
76
86
|
const refInput = inputRef || React.useRef<HTMLInputElement>();
|
|
77
87
|
|
|
@@ -154,12 +164,12 @@ export default ({
|
|
|
154
164
|
// @ts-ignore: Property 'ref' does not exist on type 'IntrinsicAttributes'
|
|
155
165
|
ref={refInput}
|
|
156
166
|
value={value}
|
|
157
|
-
|
|
158
167
|
onFocus={() => setState({ focus: true })}
|
|
159
168
|
onBlur={() => setState({ focus: false })}
|
|
160
169
|
onChange={(e) => updateValue(e.target.value)}
|
|
161
170
|
|
|
162
|
-
onKeyDown={(e) => {
|
|
171
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
172
|
+
|
|
163
173
|
if (onPressEnter && e.key === 'Enter' && value !== undefined) {
|
|
164
174
|
commitValue();
|
|
165
175
|
onPressEnter(value)
|
|
@@ -7,7 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import type { ComponentChild } from 'preact';
|
|
8
8
|
|
|
9
9
|
// Core
|
|
10
|
-
import
|
|
10
|
+
import RouterComponent from '@client/services/router/components/router';
|
|
11
11
|
import { ClientContext } from '@/client/context';
|
|
12
12
|
|
|
13
13
|
// Core components
|
|
@@ -28,14 +28,14 @@ export default function App ({ context, menu }: {
|
|
|
28
28
|
menu: ComponentChild
|
|
29
29
|
}) {
|
|
30
30
|
|
|
31
|
-
const {
|
|
31
|
+
const { Router, page, toast } = context;
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<div id="internaLlayout">
|
|
35
35
|
|
|
36
36
|
<div class="center row al-fill">
|
|
37
37
|
|
|
38
|
-
<
|
|
38
|
+
<RouterComponent service={Router} />
|
|
39
39
|
|
|
40
40
|
</div>
|
|
41
41
|
</div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { Router } from '@app';
|
|
10
10
|
import { Button } from '@client/components';
|
|
11
11
|
|
|
12
12
|
// App
|
|
@@ -15,7 +15,7 @@ import useHeader from '@client/pages/useHeader';
|
|
|
15
15
|
/*----------------------------------
|
|
16
16
|
- CONTROLEUR
|
|
17
17
|
----------------------------------*/
|
|
18
|
-
|
|
18
|
+
Router.error( 400, ({ message, modal }) => {
|
|
19
19
|
|
|
20
20
|
useHeader({
|
|
21
21
|
title: 'Bad request',
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { Router } from '@app';
|
|
10
10
|
import { Button } from '@client/components';
|
|
11
11
|
|
|
12
12
|
// App
|
|
@@ -19,7 +19,7 @@ import useHeader from '@client/pages/useHeader';
|
|
|
19
19
|
/*----------------------------------
|
|
20
20
|
- CONTROLEUR
|
|
21
21
|
----------------------------------*/
|
|
22
|
-
|
|
22
|
+
Router.error( 401, ({ message, request, page }) => {
|
|
23
23
|
|
|
24
24
|
request.response?.redirect('/');
|
|
25
25
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { Router } from '@app';
|
|
10
10
|
import { Button } from '@client/components';
|
|
11
11
|
|
|
12
12
|
// App
|
|
@@ -15,7 +15,7 @@ import useHeader from '@client/pages/useHeader';
|
|
|
15
15
|
/*----------------------------------
|
|
16
16
|
- CONTROLEUR
|
|
17
17
|
----------------------------------*/
|
|
18
|
-
|
|
18
|
+
Router.error( 403, ({ message, modal }) => {
|
|
19
19
|
|
|
20
20
|
useHeader({
|
|
21
21
|
title: 'Access Denied.',
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { Router } from '@app';
|
|
10
10
|
import { Button } from '@client/components';
|
|
11
11
|
|
|
12
12
|
// App
|
|
@@ -15,7 +15,7 @@ import useHeader from '@client/pages/useHeader';
|
|
|
15
15
|
/*----------------------------------
|
|
16
16
|
- CONTROLEUR
|
|
17
17
|
----------------------------------*/
|
|
18
|
-
|
|
18
|
+
Router.error( 404, ({ message, modal }) => {
|
|
19
19
|
|
|
20
20
|
useHeader({
|
|
21
21
|
title: 'Page Not Found',
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { Router } from '@app';
|
|
10
10
|
import { Button } from '@client/components';
|
|
11
11
|
|
|
12
12
|
// App
|
|
@@ -15,7 +15,7 @@ import useHeader from '@client/pages/useHeader';
|
|
|
15
15
|
/*----------------------------------
|
|
16
16
|
- CONTROLEUR
|
|
17
17
|
----------------------------------*/
|
|
18
|
-
|
|
18
|
+
Router.error( 500, ({ message }) => {
|
|
19
19
|
|
|
20
20
|
useHeader({
|
|
21
21
|
title: 'Technical Error',
|
|
@@ -127,7 +127,7 @@ export default ({ service: router }: { service: Router }) => {
|
|
|
127
127
|
return history?.listen(async (locationUpdate) => {
|
|
128
128
|
|
|
129
129
|
// Load the concerned route
|
|
130
|
-
const request = new ClientRequest(locationUpdate.location, context.
|
|
130
|
+
const request = new ClientRequest(locationUpdate.location, context.Router);
|
|
131
131
|
await resolvePage(request);
|
|
132
132
|
|
|
133
133
|
// Scroll to the selected content via url hash
|
|
@@ -61,10 +61,16 @@ export type Response = ClientResponse<ClientRouter> | ServerResponse<ServerRoute
|
|
|
61
61
|
- TYPES: ROUTES LOADING
|
|
62
62
|
----------------------------------*/
|
|
63
63
|
|
|
64
|
+
// WARN: To be updated with the mplemenations list of Router.page
|
|
65
|
+
// (both server and client side)
|
|
64
66
|
export type TRegisterPageArgs<TProvidedData extends TFetcherList = {}, TRouter extends Router = Router> = ([
|
|
65
67
|
path: string,
|
|
66
68
|
controller: TDataProvider<TProvidedData> | null,
|
|
67
69
|
renderer: TFrontRenderer<TProvidedData>
|
|
70
|
+
] | [
|
|
71
|
+
path: string,
|
|
72
|
+
options: Partial<TRoute["options"]>,
|
|
73
|
+
renderer: TFrontRenderer<TProvidedData>
|
|
68
74
|
] | [
|
|
69
75
|
path: string,
|
|
70
76
|
options: Partial<TRoute["options"]>,
|
|
@@ -119,7 +125,7 @@ type THookName = 'location.change' | 'page.changed'
|
|
|
119
125
|
|
|
120
126
|
type Config<TAdditionnalContext extends {} = {}> = {
|
|
121
127
|
preload: string[], // List of globs
|
|
122
|
-
context: () => TAdditionnalContext
|
|
128
|
+
context: (router: ClientRouter) => TAdditionnalContext
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
/*----------------------------------
|
|
@@ -215,6 +221,25 @@ export default class ClientRouter<
|
|
|
215
221
|
return currentRoute;
|
|
216
222
|
}
|
|
217
223
|
|
|
224
|
+
public page(
|
|
225
|
+
path: string,
|
|
226
|
+
controller: TDataProvider<{}> | null,
|
|
227
|
+
renderer: TFrontRenderer<{}>
|
|
228
|
+
): TRoute;
|
|
229
|
+
|
|
230
|
+
public page(
|
|
231
|
+
path: string,
|
|
232
|
+
options: Partial<TRoute["options"]>,
|
|
233
|
+
renderer: TFrontRenderer<{}>
|
|
234
|
+
): TRoute;
|
|
235
|
+
|
|
236
|
+
public page(
|
|
237
|
+
path: string,
|
|
238
|
+
options: Partial<TRoute["options"]>,
|
|
239
|
+
controller: TDataProvider<{}> | null,
|
|
240
|
+
renderer: TFrontRenderer<{}>
|
|
241
|
+
): TRoute;
|
|
242
|
+
|
|
218
243
|
public page(...args: TRegisterPageArgs): TRoute {
|
|
219
244
|
|
|
220
245
|
const { path, options, controller, renderer, layout } = getRegisterPageArgs(...args);
|
|
@@ -27,13 +27,16 @@ export type TPageResponse<TRouter extends ClientRouter> = (
|
|
|
27
27
|
ServerResponse<ServerRouter, ClientPage>
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
export type TRouterContext<
|
|
30
|
+
export type TRouterContext<
|
|
31
|
+
TRouter extends ClientRouter = ClientRouter,
|
|
32
|
+
TApplication extends ClientApplication = ClientApplication
|
|
33
|
+
> = (
|
|
31
34
|
// ClientPage context
|
|
32
35
|
{
|
|
33
36
|
app: TApplication,
|
|
34
37
|
context: TRouterContext<TRouter, TApplication>,
|
|
35
38
|
request: ClientRequest<TRouter>,
|
|
36
|
-
route: TRoute<
|
|
39
|
+
route: TRoute<TRouterContext>,
|
|
37
40
|
api: ClientRequest<TRouter>["api"],
|
|
38
41
|
page: ClientPage<TRouter>,
|
|
39
42
|
user: User
|
|
@@ -117,29 +117,4 @@ export const chemin = {
|
|
|
117
117
|
valA[ brancheVal ] = val;
|
|
118
118
|
|
|
119
119
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export const callableInstance = <TInstance extends object, TCallableName extends keyof TInstance>(
|
|
123
|
-
instance: TInstance,
|
|
124
|
-
funcName: TCallableName
|
|
125
|
-
): TInstance[TCallableName] & TInstance => {
|
|
126
|
-
|
|
127
|
-
const callableFunc = instance[funcName];
|
|
128
|
-
if (typeof callableFunc !== 'function')
|
|
129
|
-
throw new Error(`instance[funcName] isn't callable.`);
|
|
130
|
-
|
|
131
|
-
const callable = callableFunc.bind(instance);
|
|
132
|
-
|
|
133
|
-
const methods = [
|
|
134
|
-
...Object.getOwnPropertyNames( Object.getPrototypeOf( instance )),
|
|
135
|
-
...Object.getOwnPropertyNames( instance )
|
|
136
|
-
];
|
|
137
|
-
|
|
138
|
-
for (const method of methods)
|
|
139
|
-
if (method !== 'constructor')
|
|
140
|
-
callable[ method ] = typeof instance[ method ] === 'function'
|
|
141
|
-
? instance[ method ].bind( instance )
|
|
142
|
-
: instance[ method ];
|
|
143
|
-
|
|
144
|
-
return callable as TInstance[TCallableName] & TInstance;
|
|
145
120
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
- DEPENDANCES
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
|
-
import { Layout } from './layouts';
|
|
6
|
-
|
|
7
5
|
// types
|
|
8
6
|
import type {
|
|
9
7
|
default as ClientRouter,
|
|
@@ -22,9 +20,6 @@ import type { TUserRole } from '@server/services/users';
|
|
|
22
20
|
import type { TAppArrowFunction } from '@common/app';
|
|
23
21
|
|
|
24
22
|
// Specfic
|
|
25
|
-
import type ApiClient from './request/api';
|
|
26
|
-
import type Request from './request';
|
|
27
|
-
import type Response from './response';
|
|
28
23
|
import type { default as Page, TFrontRenderer } from './response/page';
|
|
29
24
|
|
|
30
25
|
/*----------------------------------
|
|
@@ -57,12 +52,13 @@ export type TErrorRoute<RouterContext extends TClientOrServerContext = TClientOr
|
|
|
57
52
|
options: TRouteOptions
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
export type TClientOrServerContext
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
export type TAnyRoute<RouterContext extends TClientOrServerContext = TClientOrServerContext> =
|
|
56
|
+
TRoute<RouterContext> | TErrorRoute<RouterContext>
|
|
57
|
+
|
|
58
|
+
export type TClientOrServerContext = (
|
|
63
59
|
(
|
|
64
|
-
{[serverContextKey in keyof ServerRouterContext/*Omit<ClientRouterContext, TClientOnlyContextKeys>*/]: undefined}
|
|
65
|
-
|
|
60
|
+
//{[serverContextKey in keyof ServerRouterContext/*Omit<ClientRouterContext, TClientOnlyContextKeys>*/]: undefined}
|
|
61
|
+
//&
|
|
66
62
|
ClientRouterContext
|
|
67
63
|
)
|
|
68
64
|
|
|
|
@@ -72,8 +68,8 @@ export type TClientOrServerContext<
|
|
|
72
68
|
// When we destructure the context from the page controller
|
|
73
69
|
// While making reference to a key only available in client context
|
|
74
70
|
// So here, we put the
|
|
75
|
-
{[clientContextKey in keyof ClientRouterContext/*Omit<ClientRouterContext, TClientOnlyContextKeys>*/]: undefined}
|
|
76
|
-
|
|
71
|
+
//{[clientContextKey in keyof ClientRouterContext/*Omit<ClientRouterContext, TClientOnlyContextKeys>*/]: undefined}
|
|
72
|
+
//&
|
|
77
73
|
ServerRouterContext
|
|
78
74
|
)
|
|
79
75
|
)
|
|
@@ -42,8 +42,10 @@ export const getLayout = (routePath: string, routeOptions?: TRouteOptions): Layo
|
|
|
42
42
|
|
|
43
43
|
// options.id has been injected via the babel plugon
|
|
44
44
|
const chunkId = routeOptions["id"];
|
|
45
|
-
if (chunkId === undefined)
|
|
45
|
+
if (chunkId === undefined) {
|
|
46
|
+
console.error("Route informations where ID cas not injected:", routeOptions);
|
|
46
47
|
throw new Error(`ID has not injected for the following page route: ${routePath}`);
|
|
48
|
+
}
|
|
47
49
|
|
|
48
50
|
// Layout via name
|
|
49
51
|
if (routeOptions.layout !== undefined) {
|
|
@@ -24,10 +24,12 @@ export const getRegisterPageArgs = (...args: TRegisterPageArgs) => {
|
|
|
24
24
|
let controller: TDataProvider|null;
|
|
25
25
|
let renderer: TFrontRenderer;
|
|
26
26
|
|
|
27
|
-
if (args.length ===
|
|
28
|
-
([path, controller, renderer] = args)
|
|
29
|
-
else
|
|
27
|
+
if (args.length === 4)
|
|
30
28
|
([path, options, controller, renderer] = args)
|
|
29
|
+
else if (typeof args[1] === 'object')
|
|
30
|
+
([path, options, renderer] = args)
|
|
31
|
+
else
|
|
32
|
+
([path, controller, renderer] = args)
|
|
31
33
|
|
|
32
34
|
// Automatic layout form the nearest _layout folder
|
|
33
35
|
const layout = getLayout(path, options);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { FunctionalComponent } from "preact";
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import {
|
|
9
|
+
import { TAnyRoute } from "..";
|
|
10
10
|
import type ClientRequest from '@client/services/router';
|
|
11
11
|
import Page from '@client/services/router/response/page'
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ export default abstract class BaseResponse<
|
|
|
26
26
|
|
|
27
27
|
public data?: TData;
|
|
28
28
|
public request: TRequest;
|
|
29
|
-
public route?:
|
|
29
|
+
public route?: TAnyRoute;
|
|
30
30
|
|
|
31
31
|
public constructor(
|
|
32
32
|
request: TRequest,
|
|
@@ -36,7 +36,7 @@ export default abstract class BaseResponse<
|
|
|
36
36
|
this.request = request as TRequest;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
public setRoute(route:
|
|
39
|
+
public setRoute(route: TAnyRoute) {
|
|
40
40
|
this.route = route;
|
|
41
41
|
return this;
|
|
42
42
|
}
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
isURL
|
|
11
11
|
} from 'validator';
|
|
12
12
|
|
|
13
|
+
import normalizeUrl, { Options as NormalizeUrlOptions } from 'normalize-url';
|
|
14
|
+
|
|
13
15
|
// Core
|
|
14
16
|
import { InputError } from '@common/errors';
|
|
15
17
|
import FileToUpload from '@client/components/inputv3/file/FileToUpload';
|
|
@@ -157,16 +159,25 @@ export default class SchemaValidators {
|
|
|
157
159
|
|
|
158
160
|
}, opts)
|
|
159
161
|
|
|
160
|
-
public url = (opts: TValidator<string> & {
|
|
162
|
+
public url = (opts: TValidator<string> & {
|
|
163
|
+
normalize?: NormalizeUrlOptions
|
|
164
|
+
} = {}) =>
|
|
161
165
|
new Validator<string>('url', (inputVal, input, output, corriger?) => {
|
|
162
166
|
|
|
163
167
|
let val = this.string(opts).validate(inputVal, input, output, corriger);
|
|
164
168
|
|
|
169
|
+
// Check if URL
|
|
165
170
|
if (!isURL(val, {
|
|
166
171
|
// https://www.npmjs.com/package/validator
|
|
167
172
|
}))
|
|
168
173
|
throw new InputError(`Please provide a valid URL.`);
|
|
169
174
|
|
|
175
|
+
// Normalize
|
|
176
|
+
if (opts.normalize !== undefined)
|
|
177
|
+
val = normalizeUrl(val, opts.normalize);
|
|
178
|
+
|
|
179
|
+
console.log("@@@@@@@@@@@@@NORMALISZE URL", opts.normalize, val);
|
|
180
|
+
|
|
170
181
|
return val;
|
|
171
182
|
}, opts)
|
|
172
183
|
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import yargsParser from 'yargs-parser';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import
|
|
9
|
+
import type { Application } from '@server/app';
|
|
10
|
+
import Service from '@server/app/service';
|
|
10
11
|
import { NotFound } from '@common/errors';
|
|
11
12
|
|
|
12
13
|
/*----------------------------------
|
|
@@ -49,14 +50,20 @@ export default class CommandsManager extends Service<Config, Hooks, Application>
|
|
|
49
50
|
|
|
50
51
|
public commandsIndex: CommandsList = {}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
/*----------------------------------
|
|
54
|
+
- LIFECYCLE
|
|
55
|
+
----------------------------------*/
|
|
53
56
|
|
|
57
|
+
protected async start() {
|
|
54
58
|
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected async ready() {
|
|
55
62
|
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
protected async shutdown() {
|
|
66
|
+
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
/*----------------------------------
|
|
@@ -35,6 +35,7 @@ export type TEnvConfig = {
|
|
|
35
35
|
type AppIdentityConfig = {
|
|
36
36
|
|
|
37
37
|
name: string,
|
|
38
|
+
identifier: string,
|
|
38
39
|
description: string,
|
|
39
40
|
author: {
|
|
40
41
|
name: string,
|
|
@@ -63,6 +64,8 @@ export type AppConfig = {
|
|
|
63
64
|
identity: Config.Identity,
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
const debug = false;
|
|
68
|
+
|
|
66
69
|
/*----------------------------------
|
|
67
70
|
- LOADE
|
|
68
71
|
----------------------------------*/
|
|
@@ -76,7 +79,7 @@ export default class ConfigParser {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
private loadYaml( filepath: string ) {
|
|
79
|
-
console.info(`Loading config ${filepath}`);
|
|
82
|
+
debug && console.info(`Loading config ${filepath}`);
|
|
80
83
|
const rawConfig = fs.readFileSync(filepath, 'utf-8');
|
|
81
84
|
return yaml.parse(rawConfig);
|
|
82
85
|
}
|
|
@@ -96,6 +99,7 @@ export default class ConfigParser {
|
|
|
96
99
|
|
|
97
100
|
public identity() {
|
|
98
101
|
const identityFile = this.appDir + '/identity.yaml';
|
|
102
|
+
debug && console.info(`Loading identity ${identityFile}`);
|
|
99
103
|
return this.loadYaml( identityFile );
|
|
100
104
|
}
|
|
101
105
|
}
|