5htp-core 0.5.9-55 → 0.5.9-7
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/client/app/component.tsx +1 -0
- package/client/assets/css/components/button.less +1 -0
- package/client/assets/css/components/card.less +20 -0
- package/client/assets/css/components/input.less +0 -4
- package/client/assets/css/components/mantine.less +5 -1
- package/client/assets/css/components/other.less +1 -0
- package/client/assets/css/core.less +5 -3
- package/client/assets/css/text/text.less +0 -9
- package/client/assets/css/utils/layouts.less +5 -0
- package/client/assets/css/utils/sizing.less +2 -0
- package/client/components/Select.tsx +37 -34
- package/client/components/Table/index.tsx +7 -0
- package/client/components/index.ts +2 -2
- package/client/services/router/index.tsx +1 -1
- package/client/services/router/request/api.ts +0 -0
- package/common/router/index.ts +6 -1
- package/package.json +1 -1
- package/server/app/index.ts +8 -8
- package/server/app/service/index.ts +11 -4
- package/server/services/auth/index.ts +2 -8
- package/server/services/database/index.ts +3 -7
- package/server/services/disks/index.ts +3 -7
- package/server/services/email/transporter.ts +1 -1
- package/server/services/router/index.ts +13 -12
- package/server/services/router/service.ts +4 -17
- package/server/services/security/encrypt/aes/index.ts +1 -1
- package/types/icons.d.ts +1 -1
package/client/app/component.tsx
CHANGED
|
@@ -69,6 +69,7 @@ export default function App({ context }: {
|
|
|
69
69
|
SegmentedControl: { defaultProps: { size: 'md' } },
|
|
70
70
|
Menu: { defaultProps: { size: 'md' } },
|
|
71
71
|
MenuItem: { defaultProps: { size: 'md' } },
|
|
72
|
+
Autocomplete: { defaultProps: { size: 'md' } },
|
|
72
73
|
// Add any others you use...
|
|
73
74
|
},
|
|
74
75
|
}} withGlobalStyles withNormalizeCSS>
|
|
@@ -17,6 +17,17 @@
|
|
|
17
17
|
|
|
18
18
|
background-color: var(--cBg);
|
|
19
19
|
padding: @cardPadding;
|
|
20
|
+
box-shadow: 0 3px 2px fade(#000, 10%);
|
|
21
|
+
border: 1px solid fade(#000, 10%);
|
|
22
|
+
|
|
23
|
+
&.floating {
|
|
24
|
+
box-shadow: 0 10px 50px fade(black, 15%);
|
|
25
|
+
z-index: 10;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.minimal {
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
}
|
|
20
31
|
|
|
21
32
|
&.row {
|
|
22
33
|
padding: @cardPadding @cardPaddingLong;
|
|
@@ -48,6 +59,15 @@
|
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
a&,
|
|
63
|
+
&.clickable {
|
|
64
|
+
text-decoration: none; // Remove a underline
|
|
65
|
+
|
|
66
|
+
&:hover {
|
|
67
|
+
border-color: #aaa;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
&.col {
|
|
52
72
|
padding: @cardPadding @cardPaddingLong;
|
|
53
73
|
|
|
@@ -78,23 +78,25 @@
|
|
|
78
78
|
html {
|
|
79
79
|
font-size: @sTxtPage;
|
|
80
80
|
line-height: 1.25em;
|
|
81
|
-
font-weight: 400;
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
* {
|
|
85
84
|
box-sizing: border-box;
|
|
86
85
|
outline: none;
|
|
87
86
|
font-size: 1em;
|
|
87
|
+
font-weight: 500;
|
|
88
88
|
padding: 0;
|
|
89
89
|
margin: 0;
|
|
90
|
-
// Avoids flexbox childrens to overflw parent
|
|
91
|
-
min-width: 0;
|
|
92
90
|
|
|
93
91
|
&, &:hover, &:focus {
|
|
94
92
|
-webkit-tap-highlight-color: transparent;
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
p {
|
|
97
|
+
font-weight: 400;
|
|
98
|
+
}
|
|
99
|
+
|
|
98
100
|
body {
|
|
99
101
|
// Pas propre. A eviter (ex: perturbation smooth scroll
|
|
100
102
|
//overflow-x: hidden;
|
|
@@ -42,15 +42,6 @@ p, .p {
|
|
|
42
42
|
margin: 0; // Overwrite browser defaults
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.desc {
|
|
46
|
-
font-size: 0.8rem;
|
|
47
|
-
color: var(--cTxtDesc);
|
|
48
|
-
|
|
49
|
-
i {
|
|
50
|
-
height: 1.16rem;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
45
|
// Gestion des dépassements
|
|
55
46
|
//.bouton, // Empêche le label d'être affiché en mode icone only
|
|
56
47
|
.bouton > .label /* <Select /> */ {
|
|
@@ -8,21 +8,21 @@ import {
|
|
|
8
8
|
SelectProps,
|
|
9
9
|
MultiSelect as MantineMultiSelect,
|
|
10
10
|
ComboboxItem,
|
|
11
|
-
|
|
12
|
-
Menu,
|
|
13
|
-
Button
|
|
11
|
+
Menu
|
|
14
12
|
} from '@mantine/core';
|
|
15
13
|
import Input from '@client/components/Input';
|
|
16
14
|
|
|
17
15
|
// Core
|
|
18
16
|
import { useMantineInput, InputBaseProps } from '@client/components/utils';
|
|
17
|
+
import Button, { Props as ButtonProps } from '@client/components/Button';
|
|
18
|
+
import Popover, { Props as PopoverProps } from '@client/components/containers/Popover';
|
|
19
19
|
|
|
20
20
|
/*----------------------------------
|
|
21
21
|
- TYPES
|
|
22
22
|
----------------------------------*/
|
|
23
23
|
|
|
24
24
|
export type Props = SelectProps & InputBaseProps<ComboboxItem> & {
|
|
25
|
-
|
|
25
|
+
popoverProps?: PopoverProps
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type Choice = ComboboxItem;
|
|
@@ -37,8 +37,11 @@ const ensureChoice = (
|
|
|
37
37
|
if (typeof choice === 'object')
|
|
38
38
|
return choice;
|
|
39
39
|
|
|
40
|
+
// Ensure current is an array of choices
|
|
41
|
+
const allChoices = [...choices, ...current];
|
|
42
|
+
|
|
40
43
|
// Find the choice
|
|
41
|
-
const found =
|
|
44
|
+
const found = allChoices.find( c => c.value === choice );
|
|
42
45
|
if (found) return found;
|
|
43
46
|
|
|
44
47
|
// Create a new choice
|
|
@@ -60,11 +63,14 @@ export default (initProps: Props) => {
|
|
|
60
63
|
onChange, value: current,
|
|
61
64
|
required
|
|
62
65
|
}, {
|
|
63
|
-
multiple, choices: initChoices, enableSearch,
|
|
66
|
+
multiple, choices: initChoices, enableSearch, popoverProps,
|
|
64
67
|
...props
|
|
65
68
|
}] = useMantineInput<Props, string|number>(initProps);
|
|
66
69
|
|
|
67
|
-
const currentArray = Array.isArray(current)
|
|
70
|
+
const currentArray = (Array.isArray(current)
|
|
71
|
+
? current
|
|
72
|
+
: current ? [current] : []
|
|
73
|
+
).map(c => ensureChoice(c, [], []));
|
|
68
74
|
|
|
69
75
|
const choicesViaFunc = typeof initChoices === 'function';
|
|
70
76
|
if (choicesViaFunc)
|
|
@@ -146,33 +152,14 @@ export default (initProps: Props) => {
|
|
|
146
152
|
|
|
147
153
|
if (minimal) {
|
|
148
154
|
return (
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
closeOnItemClick={!multiple}>
|
|
152
|
-
<Menu.Target>
|
|
153
|
-
<Button variant="subtle"
|
|
154
|
-
leftSection={(
|
|
155
|
-
(current && multiple) ? (
|
|
156
|
-
<span class="badge bg info s">
|
|
157
|
-
{current.length}
|
|
158
|
-
</span>
|
|
159
|
-
) : null
|
|
160
|
-
)}
|
|
161
|
-
rightSection={<i src="angle-down" />}
|
|
162
|
-
onClick={() => setOpened((o) => !o)} >
|
|
163
|
-
|
|
164
|
-
{props.label || props.placeholder}
|
|
165
|
-
|
|
166
|
-
</Button>
|
|
167
|
-
</Menu.Target>
|
|
168
|
-
<Menu.Dropdown>
|
|
169
|
-
|
|
155
|
+
<Popover {...(popoverProps || {})} state={[opened, setOpened]} content={(
|
|
156
|
+
<div class="card col menu floating">
|
|
170
157
|
{enableSearch && <>
|
|
158
|
+
|
|
171
159
|
<Input title="Search" value={search.keywords}
|
|
172
160
|
wrapper={false} minimal icon="search"
|
|
173
161
|
onChange={v => setSearch(s => ({ ...s, keywords: v }))} />
|
|
174
162
|
|
|
175
|
-
<Menu.Divider />
|
|
176
163
|
</>}
|
|
177
164
|
|
|
178
165
|
{choices.map(choice => {
|
|
@@ -182,8 +169,9 @@ export default (initProps: Props) => {
|
|
|
182
169
|
: props.value === choice.value;
|
|
183
170
|
|
|
184
171
|
return (
|
|
185
|
-
<
|
|
186
|
-
|
|
172
|
+
<Button key={choice.value}
|
|
173
|
+
size="s"
|
|
174
|
+
suffix={isSelected ? <i src="check" /> : null}
|
|
187
175
|
onClick={() => onChange( multiple
|
|
188
176
|
? (isSelected
|
|
189
177
|
? current.filter(c => c.value !== choice.value)
|
|
@@ -195,11 +183,26 @@ export default (initProps: Props) => {
|
|
|
195
183
|
)
|
|
196
184
|
)}>
|
|
197
185
|
{choice.label}
|
|
198
|
-
</
|
|
186
|
+
</Button>
|
|
199
187
|
)
|
|
200
188
|
})}
|
|
201
|
-
</
|
|
202
|
-
|
|
189
|
+
</div>
|
|
190
|
+
)}>
|
|
191
|
+
<Button
|
|
192
|
+
prefix={(
|
|
193
|
+
(multiple && current?.length) ? (
|
|
194
|
+
<span class="badge bg info s">
|
|
195
|
+
{current.length}
|
|
196
|
+
</span>
|
|
197
|
+
) : icon ? <i src={icon} /> : null
|
|
198
|
+
)}
|
|
199
|
+
suffix={iconR ? <i src={iconR} /> : <i src="angle-down" />}
|
|
200
|
+
onClick={() => setOpened((o) => !o)}>
|
|
201
|
+
|
|
202
|
+
{props.label || props.placeholder}
|
|
203
|
+
|
|
204
|
+
</Button>
|
|
205
|
+
</Popover>
|
|
203
206
|
)
|
|
204
207
|
|
|
205
208
|
} else {
|
|
@@ -34,6 +34,7 @@ export type Props<TRow> = {
|
|
|
34
34
|
// Interactions
|
|
35
35
|
sort?: TSortOptions,
|
|
36
36
|
onSort?: (columnId: string | null, order: TSortOptions["order"]) => void,
|
|
37
|
+
onCellClick?: (row: TRow) => void,
|
|
37
38
|
|
|
38
39
|
selection?: [TRow[], React.SetStateAction<TRow[]>],
|
|
39
40
|
maxSelection?: number,
|
|
@@ -58,6 +59,7 @@ type TSortOptions = {
|
|
|
58
59
|
export default function Liste<TRow extends TDonneeInconnue>({
|
|
59
60
|
stickyHeader, onSort, sort: sorted,
|
|
60
61
|
data: rows, setData, empty,
|
|
62
|
+
onCellClick,
|
|
61
63
|
selection: selectionState, maxSelection,
|
|
62
64
|
columns, ...props
|
|
63
65
|
}: Props<TRow>) {
|
|
@@ -167,6 +169,11 @@ export default function Liste<TRow extends TDonneeInconnue>({
|
|
|
167
169
|
);
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
if (onCellClick) {
|
|
173
|
+
cellProps.onClick = () => onCellClick(row);
|
|
174
|
+
classe += ' clickable';
|
|
175
|
+
}
|
|
176
|
+
|
|
170
177
|
let render: ComponentChild;
|
|
171
178
|
if (Array.isArray(cell)) {
|
|
172
179
|
|
|
@@ -31,7 +31,7 @@ export {
|
|
|
31
31
|
UnstyledButton,
|
|
32
32
|
VisuallyHidden,
|
|
33
33
|
Paper,
|
|
34
|
-
|
|
34
|
+
Popover as PopoverMantine,
|
|
35
35
|
ActionIcon,
|
|
36
36
|
CloseButton,
|
|
37
37
|
Group,
|
|
@@ -106,7 +106,7 @@ export {
|
|
|
106
106
|
RangeSlider,
|
|
107
107
|
RingProgress,
|
|
108
108
|
SegmentedControl,
|
|
109
|
-
|
|
109
|
+
Select as SelectMantine,
|
|
110
110
|
SemiCircleProgress,
|
|
111
111
|
SimpleGrid,
|
|
112
112
|
Skeleton,
|
|
@@ -127,7 +127,7 @@ type THookName = 'page.change' | 'page.changed' | 'page.rendered'
|
|
|
127
127
|
|
|
128
128
|
type Config<TAdditionnalContext extends {} = {}> = {
|
|
129
129
|
preload: string[], // List of globs
|
|
130
|
-
context: (context:
|
|
130
|
+
context: (context: {}, router: ClientRouter) => TAdditionnalContext,
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/*----------------------------------
|
|
File without changes
|
package/common/router/index.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
- DEPENDANCES
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
|
+
// Npm
|
|
6
|
+
import zod from 'zod';
|
|
7
|
+
|
|
5
8
|
// types
|
|
6
9
|
import type {
|
|
7
10
|
default as ClientRouter,
|
|
@@ -42,6 +45,7 @@ export type TRoute<RouterContext extends TClientOrServerContextForPage = TClient
|
|
|
42
45
|
path: string,
|
|
43
46
|
|
|
44
47
|
// Execute
|
|
48
|
+
schema?: zod.ZodSchema,
|
|
45
49
|
controller: TRouteController<RouterContext>,
|
|
46
50
|
options: TRouteOptions
|
|
47
51
|
} & (
|
|
@@ -67,7 +71,8 @@ export type TErrorRoute<RouterContext extends TClientOrServerContextForPage = TC
|
|
|
67
71
|
export type TAnyRoute<RouterContext extends TClientOrServerContextForPage = TClientOrServerContextForPage> =
|
|
68
72
|
TRoute<RouterContext> | TErrorRoute<RouterContext>
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
// ClientRouterContext already includes server context
|
|
75
|
+
export type TClientOrServerContext = ClientRouterContext;// | ServerRouterContext;
|
|
71
76
|
|
|
72
77
|
export type TClientOrServerContextForPage = With<TClientOrServerContext, 'page'>
|
|
73
78
|
|
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.5.9-
|
|
4
|
+
"version": "0.5.9-7",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
package/server/app/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ import ServicesContainer, {
|
|
|
16
16
|
import type { ServerBug } from './container/console';
|
|
17
17
|
|
|
18
18
|
// Built-in
|
|
19
|
-
import type { default as Router, Request as ServerRequest } from '@server/services/router';
|
|
19
|
+
import type { default as Router, Request as ServerRequest, TRoute } from '@server/services/router';
|
|
20
20
|
|
|
21
21
|
export { default as Services } from './service/container';
|
|
22
22
|
export type { TEnvConfig as Environment } from './container/config';
|
|
@@ -55,7 +55,7 @@ export type ApplicationProperties = Prettify<keyof Application>;
|
|
|
55
55
|
----------------------------------*/
|
|
56
56
|
export abstract class Application<
|
|
57
57
|
TServicesContainer extends ServicesContainerClass = ServicesContainerClass
|
|
58
|
-
> extends ApplicationService<Config, Hooks,
|
|
58
|
+
> extends ApplicationService<Config, Hooks, Application> {
|
|
59
59
|
|
|
60
60
|
public app!: this;
|
|
61
61
|
public servicesContainer!: TServicesContainer;
|
|
@@ -113,7 +113,7 @@ export abstract class Application<
|
|
|
113
113
|
// We can't pass this in super so we assign here
|
|
114
114
|
this.parent = this;
|
|
115
115
|
this.app = this;
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/*----------------------------------
|
|
@@ -162,7 +162,7 @@ export abstract class Application<
|
|
|
162
162
|
const instance = service.start();
|
|
163
163
|
this[service.name] = instance.getServiceInstance();
|
|
164
164
|
} catch (error) {
|
|
165
|
-
console.error("Error while starting service", serviceId,
|
|
165
|
+
console.error("Error while starting service", serviceId, error);
|
|
166
166
|
throw error;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -187,7 +187,7 @@ export abstract class Application<
|
|
|
187
187
|
console.log('-' + '-'.repeat(level * 1), propKey + ': ' + service.constructor.name);
|
|
188
188
|
|
|
189
189
|
// Routes
|
|
190
|
-
const routes = service.__routes;
|
|
190
|
+
const routes = service.__routes as TRoute[];
|
|
191
191
|
if (routes) for (const route of routes) {
|
|
192
192
|
|
|
193
193
|
console.log('Attached service', service.constructor.name, 'to route', route.path);
|
|
@@ -196,9 +196,9 @@ export abstract class Application<
|
|
|
196
196
|
route.controller = (context: RouterContext) => {
|
|
197
197
|
|
|
198
198
|
// Filter data
|
|
199
|
-
const data = route.
|
|
200
|
-
? route.
|
|
201
|
-
:
|
|
199
|
+
const data = route.schema
|
|
200
|
+
? route.schema.parse( context.request.data )
|
|
201
|
+
: {};
|
|
202
202
|
|
|
203
203
|
// Run controller
|
|
204
204
|
return origController.bind( service )(
|
|
@@ -8,6 +8,8 @@ import type { Command } from "../commands";
|
|
|
8
8
|
import type { TServiceMetas } from './container';
|
|
9
9
|
import type { TControllerDefinition, TRoute } from '../../services/router';
|
|
10
10
|
|
|
11
|
+
export { default as schema } from 'zod';
|
|
12
|
+
|
|
11
13
|
/*----------------------------------
|
|
12
14
|
- TYPES: OPTIONS
|
|
13
15
|
----------------------------------*/
|
|
@@ -38,7 +40,7 @@ export type StartedServicesIndex = {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export type TServiceArgs<TService extends AnyService> = [
|
|
41
|
-
parent:
|
|
43
|
+
parent: AnyService | 'self',
|
|
42
44
|
getConfig: (instance: TService) => {},
|
|
43
45
|
app: TService['app'] | 'self'
|
|
44
46
|
]
|
|
@@ -71,6 +73,7 @@ export function Route(options: Omit<TControllerDefinition, 'controller'> = {}) {
|
|
|
71
73
|
method: 'POST',
|
|
72
74
|
path: '/api/' + options.path,
|
|
73
75
|
controller: originalMethod,
|
|
76
|
+
schema: options.schema,
|
|
74
77
|
options: {
|
|
75
78
|
priority: options.priority || 0
|
|
76
79
|
}
|
|
@@ -134,11 +137,15 @@ export default abstract class Service<
|
|
|
134
137
|
- SUBSERVICES
|
|
135
138
|
----------------------------------*/
|
|
136
139
|
|
|
137
|
-
|
|
140
|
+
// TODO:; babel plugin: transform Service references to app.use('Service')
|
|
141
|
+
public use<TService extends AnyService = AnyService>(
|
|
142
|
+
serviceId: string,
|
|
143
|
+
useOptions: { optional?: boolean } = {}
|
|
144
|
+
): TService {
|
|
138
145
|
|
|
139
146
|
const registeredService = this.app.registered[serviceId];
|
|
140
|
-
if (registeredService === undefined)
|
|
141
|
-
throw new Error(`Service ${registeredService} not
|
|
147
|
+
if (registeredService === undefined && useOptions.optional === false)
|
|
148
|
+
throw new Error(`Service ${registeredService} not registered.`);
|
|
142
149
|
|
|
143
150
|
return this.app[ registeredService.name ];
|
|
144
151
|
}
|
|
@@ -49,10 +49,6 @@ export type THooks = {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export type TServices = {
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
52
|
export type TBasicUser = {
|
|
57
53
|
type: string,
|
|
58
54
|
name: string,
|
|
@@ -73,13 +69,11 @@ export default abstract class AuthService<
|
|
|
73
69
|
TApplication extends Application,
|
|
74
70
|
TJwtSession extends TBasicJwtSession = TBasicJwtSession,
|
|
75
71
|
TRequest extends ServerRequest<Router> = ServerRequest<Router>,
|
|
76
|
-
> extends Service<TConfig, THooks, TApplication
|
|
72
|
+
> extends Service<TConfig, THooks, TApplication> {
|
|
77
73
|
|
|
78
|
-
public abstract login( ...args: any[] ): Promise<{ user: TUser, token: string }>;
|
|
74
|
+
//public abstract login( ...args: any[] ): Promise<{ user: TUser, token: string }>;
|
|
79
75
|
public abstract decodeSession( jwt: TJwtSession, req: THttpRequest ): Promise<TUser | null>;
|
|
80
76
|
|
|
81
|
-
protected abstract displaySessionName(session: TJwtSession): string;
|
|
82
|
-
|
|
83
77
|
// https://beeceptor.com/docs/concepts/authorization-header/#examples
|
|
84
78
|
public async decode( req: THttpRequest, withData: true ): Promise<TUser | null>;
|
|
85
79
|
public async decode( req: THttpRequest, withData?: false ): Promise<TJwtSession | null>;
|
|
@@ -10,7 +10,7 @@ const safeStringify = require('fast-safe-stringify'); // remplace les référenc
|
|
|
10
10
|
|
|
11
11
|
// Core: general
|
|
12
12
|
import { Application, Services } from '@server/app';
|
|
13
|
-
import Service, { AnyService, TRegisteredServicesIndex } from '@server/app/service';
|
|
13
|
+
import Service, { AnyService, TRegisteredServicesIndex, TServiceArgs } from '@server/app/service';
|
|
14
14
|
import { NotFound } from '@common/errors';
|
|
15
15
|
|
|
16
16
|
// Services
|
|
@@ -95,13 +95,9 @@ export default class SQL extends Service<Config, Hooks, Application> {
|
|
|
95
95
|
|
|
96
96
|
public database: Database;
|
|
97
97
|
|
|
98
|
-
public constructor(
|
|
99
|
-
parent: AnyService,
|
|
100
|
-
config: Config,
|
|
101
|
-
app: Application,
|
|
102
|
-
) {
|
|
98
|
+
public constructor( ...args: TServiceArgs<SQL>) {
|
|
103
99
|
|
|
104
|
-
super(
|
|
100
|
+
super(...args);
|
|
105
101
|
|
|
106
102
|
this.database = new Database(this, this.config);
|
|
107
103
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// Core
|
|
6
6
|
import type { Application } from '@server/app';
|
|
7
|
-
import Service, { AnyService, TRegisteredServicesIndex } from '@server/app/service';
|
|
7
|
+
import Service, { AnyService, TRegisteredServicesIndex, TServiceArgs } from '@server/app/service';
|
|
8
8
|
|
|
9
9
|
// Specific
|
|
10
10
|
import type Driver from './driver';
|
|
@@ -45,13 +45,9 @@ export default class DisksManager<
|
|
|
45
45
|
- LIFECYCLE
|
|
46
46
|
----------------------------------*/
|
|
47
47
|
|
|
48
|
-
public constructor(
|
|
49
|
-
parent: AnyService,
|
|
50
|
-
config: TConfig,
|
|
51
|
-
app: Application,
|
|
52
|
-
) {
|
|
48
|
+
public constructor( ...args: TServiceArgs<DisksManager>) {
|
|
53
49
|
|
|
54
|
-
super(
|
|
50
|
+
super(...args);
|
|
55
51
|
|
|
56
52
|
const drivers = this.config.drivers;
|
|
57
53
|
|
|
@@ -25,7 +25,7 @@ export type TBasicConfig = {
|
|
|
25
25
|
- CLASS
|
|
26
26
|
----------------------------------*/
|
|
27
27
|
export abstract class Transporter<TConfig extends TBasicConfig = TBasicConfig>
|
|
28
|
-
extends Service<TConfig, {}, Application
|
|
28
|
+
extends Service<TConfig, {}, Application> {
|
|
29
29
|
|
|
30
30
|
public abstract send( emails: TCompleteEmail[] ): Promise<void>;
|
|
31
31
|
}
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
import type express from 'express';
|
|
15
15
|
import type { Request, Response, NextFunction } from 'express';
|
|
16
16
|
import { v4 as uuid } from 'uuid';
|
|
17
|
+
import zod from 'zod';
|
|
17
18
|
import type { GlobImportedWithMetas } from 'babel-plugin-glob-import';
|
|
18
19
|
|
|
19
20
|
// Core
|
|
20
21
|
import type { Application } from '@server/app';
|
|
21
|
-
import Service, { AnyService } from '@server/app/service';
|
|
22
|
+
import Service, { AnyService, TServiceArgs } from '@server/app/service';
|
|
22
23
|
import type { TRegisteredServicesIndex } from '@server/app/service/container';
|
|
23
24
|
import context from '@server/context';
|
|
24
25
|
import type DisksManager from '@server/services/disks';
|
|
@@ -113,16 +114,15 @@ export type Hooks = {
|
|
|
113
114
|
|
|
114
115
|
export type TControllerDefinition = {
|
|
115
116
|
path?: string,
|
|
116
|
-
|
|
117
|
+
schema?: zod.ZodSchema,
|
|
117
118
|
controller: TServerController<ServerRouter>,
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/*----------------------------------
|
|
121
122
|
- CLASSE
|
|
122
123
|
----------------------------------*/
|
|
123
|
-
export default class ServerRouter
|
|
124
|
-
|
|
125
|
-
> extends Service<Config, Hooks, Application, TSubservices> implements BaseRouter {
|
|
124
|
+
export default class ServerRouter
|
|
125
|
+
extends Service<Config, Hooks, Application> implements BaseRouter {
|
|
126
126
|
|
|
127
127
|
public disks = this.use<DisksManager>('Core/Disks', { optional: true });
|
|
128
128
|
|
|
@@ -143,13 +143,9 @@ export default class ServerRouter<
|
|
|
143
143
|
- SERVICE
|
|
144
144
|
----------------------------------*/
|
|
145
145
|
|
|
146
|
-
public constructor(
|
|
147
|
-
parent: AnyService,
|
|
148
|
-
config: Config,
|
|
149
|
-
app: Application,
|
|
150
|
-
) {
|
|
146
|
+
public constructor( ...args: TServiceArgs<ServerRouter>) {
|
|
151
147
|
|
|
152
|
-
super(
|
|
148
|
+
super(...args);
|
|
153
149
|
|
|
154
150
|
this.http = new HTTP(this.config.http, this);
|
|
155
151
|
this.render = new DocumentRenderer(this);
|
|
@@ -454,8 +450,13 @@ export default class ServerRouter<
|
|
|
454
450
|
for (const serviceName in this.config.plugins) {
|
|
455
451
|
|
|
456
452
|
const routerService = this.config.plugins[serviceName];
|
|
457
|
-
|
|
453
|
+
if (!routerService)
|
|
454
|
+
throw new Error(`Could not access router service ${serviceName}. Maybe the referenced service is not started yet? Try to reduce its priority.`);
|
|
458
455
|
|
|
456
|
+
if (!routerService.requestService)
|
|
457
|
+
throw new Error(`Router service ${serviceName} is not implementing the requestService method from the RouterService interface.`);
|
|
458
|
+
|
|
459
|
+
const requestService = routerService.requestService( request );
|
|
459
460
|
if (requestService !== null)
|
|
460
461
|
contextServices[ serviceName ] = requestService;
|
|
461
462
|
|
|
@@ -4,35 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
// Core
|
|
6
6
|
import type { Application } from '@server/app';
|
|
7
|
-
import Service, { TRegisteredServicesIndex } from '@server/app/service';
|
|
7
|
+
import Service, { TRegisteredServicesIndex, TServiceArgs } from '@server/app/service';
|
|
8
8
|
|
|
9
9
|
// Specific
|
|
10
10
|
import type { default as Router } from '.';
|
|
11
11
|
import type ServerRequest from './request';
|
|
12
12
|
import type RequestService from './request/service';
|
|
13
13
|
|
|
14
|
-
export type Services = {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
/*----------------------------------
|
|
19
15
|
- SERVICE
|
|
20
16
|
----------------------------------*/
|
|
21
17
|
export default abstract class RouterService<
|
|
22
18
|
TConfig extends {} = {}
|
|
23
|
-
> extends Service<TConfig, {}, Application
|
|
24
|
-
|
|
25
|
-
public constructor(
|
|
26
|
-
// Parent is always a router in RouterService
|
|
27
|
-
// Warning: for now, it's possible that router is actually the app
|
|
28
|
-
// It's fixed with a not very clean way in Service.bindService
|
|
29
|
-
router: Router,
|
|
30
|
-
config: TConfig,
|
|
31
|
-
app: Application
|
|
32
|
-
) {
|
|
19
|
+
> extends Service<TConfig, {}, Application> {
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
public constructor( ...args: TServiceArgs<RouterService>) {
|
|
22
|
+
super(...args);
|
|
36
23
|
}
|
|
37
24
|
|
|
38
25
|
public abstract requestService( request: ServerRequest<Router> ): RequestService | null;
|
|
@@ -47,7 +47,7 @@ type TDecryptOptions = {
|
|
|
47
47
|
/*----------------------------------
|
|
48
48
|
- SERVICE
|
|
49
49
|
----------------------------------*/
|
|
50
|
-
export default class AES<TConfig extends Config = Config> extends Service<TConfig, Hooks, Application
|
|
50
|
+
export default class AES<TConfig extends Config = Config> extends Service<TConfig, Hooks, Application> {
|
|
51
51
|
|
|
52
52
|
public encrypt( keyName: keyof TConfig["keys"], data: any, options: TEncryptOptions = {
|
|
53
53
|
encoding: 'base64url'
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "
|
|
1
|
+
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"planet-ringed"|"brands/linkedin"|"rocket"|"user-circle"|"chart-bar"|"arrow-right"|"at"|"calendar-alt"|"paper-plane"|"crosshairs"|"plus-circle"|"comments-alt"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"search"|"lightbulb"|"magnet"|"key"|"user"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"times-circle"|"solid/crown"|"brands/discord"|"pen"|"plus"|"file"|"envelope"|"angle-up"|"angle-down"|"check-circle"|"magic"|"globe"|"industry"|"map-marker-alt"|"users"|"briefcase"|"solid/magic"|"angle-right"|"save"|"binoculars"|"info-circle"|"exclamation-circle"|"check"|"meh-rolling-eyes"|"trash"|"arrow-left"|"usd-circle"|"stream"|"home-alt"|"trophy"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"cog"|"power-off"|"bars"|"play"|"minus-circle"|"external-link"|"plane-departure"|"brands/whatsapp"|"wind"|"question-circle"|"arrow-to-bottom"|"clock"|"ellipsis-h"|"map-marker"|"language"|"calendar"|"fire"|"redo"|"building"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"unlink"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"
|