5htp-core 0.5.9-3 → 0.5.9-4

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.
@@ -24,6 +24,13 @@
24
24
  --number-input-height-md: @sizeComponent;
25
25
  }
26
26
 
27
+ .mantine-SegmentedControl-root {
28
+ --segmented-control-height-md: @sizeComponent;
29
+ --mantine-SegmentedControl-height: @sizeComponent;
30
+ }
31
+
32
+
33
+
27
34
 
28
35
 
29
36
  /*----------------------------------
@@ -58,6 +58,7 @@ export default (initProps: Props) => {
58
58
  let Component: typeof TextInput | typeof NumberInput | typeof Textarea;
59
59
  if (props.type === 'number') {
60
60
  Component = NumberInput;
61
+ props.min = props.min ?? 0;
61
62
  } else if (props.type === 'longtext' && typeof document !== 'undefined') {
62
63
  Component = Textarea;
63
64
  props.autosize = true;
@@ -102,8 +102,13 @@ export default (initProps: Props) => {
102
102
  React.useEffect(() => {
103
103
 
104
104
  if (choicesViaFunc && opened) {
105
+
106
+ const keywords = search.keywords === current?.label
107
+ ? undefined
108
+ : search.keywords;
109
+
105
110
  //setSearch(s => ({ ...s, loading: true }));
106
- initChoices(search.keywords).then((searchResults) => {
111
+ initChoices(keywords).then((searchResults) => {
107
112
  //setSearch(s => ({ ...s, loading: false }))
108
113
  setChoices(searchResults);
109
114
  })
@@ -113,7 +118,7 @@ export default (initProps: Props) => {
113
118
 
114
119
  }, [
115
120
  opened,
116
- //search.keywords,
121
+ search.keywords,
117
122
  // When initChoices is a function, React considers it's always different
118
123
  // It avoids the choices are fetched everytimle the parent component is re-rendered
119
124
  typeof initChoices === 'function' ? true : initChoices
@@ -130,6 +135,10 @@ export default (initProps: Props) => {
130
135
  props.onChange = (value: string) => onChange( valueToChoice(value) );
131
136
  }
132
137
 
138
+ if (props.placeholder === 'Where the candidate will work ?') {
139
+ console.log('----------', props, choices);
140
+ }
141
+
133
142
  /*----------------------------------
134
143
  - RENDER
135
144
  ----------------------------------*/
@@ -191,7 +191,6 @@ export default ({ service: clientRouter, loaderComponent }: TProps) => {
191
191
  // Reset scroll
192
192
  window.scrollTo(0, 0);
193
193
  // Should be called AFTER rendering the page (so after the state change)
194
- console.log("CHANGE PAGE", currentPage);
195
194
  currentPage?.updateClient();
196
195
  // Scroll to the selected content via url hash
197
196
  restoreScroll(currentPage);
@@ -21,7 +21,7 @@ import FileToUpload from '@client/components/File/FileToUpload';
21
21
  - TYPES
22
22
  ----------------------------------*/
23
23
 
24
- const debug = true;
24
+ const debug = false;
25
25
 
26
26
  export type Config = {
27
27
 
@@ -86,7 +86,7 @@ export default class ApiClient implements ApiClientService {
86
86
  else if (typeof ids === 'string')
87
87
  ids = [ids];
88
88
 
89
- console.log("[api] Reload data", ids, params, page.fetchers);
89
+ debug && console.log("[api] Reload data", ids, params, page.fetchers);
90
90
 
91
91
  for (const id of ids) {
92
92
 
@@ -97,7 +97,7 @@ export default class ApiClient implements ApiClientService {
97
97
  if (params !== undefined)
98
98
  fetcher.data = { ...(fetcher.data || {}), ...params };
99
99
 
100
- console.log("[api][reload]", id, fetcher.method, fetcher.path, fetcher.data);
100
+ debug && console.log("[api][reload]", id, fetcher.method, fetcher.path, fetcher.data);
101
101
 
102
102
  this.fetchAsync(fetcher.method, fetcher.path, fetcher.data).then((data) => {
103
103
 
@@ -227,7 +227,7 @@ export default class ApiClient implements ApiClientService {
227
227
 
228
228
  } else if (options.encoding === 'multipart') {
229
229
 
230
- console.log("[api] Multipart request", data);
230
+ debug && console.log("[api] Multipart request", data);
231
231
  // Browser will automatically choose the right headers
232
232
  config.body = toMultipart(data);
233
233
 
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-3",
4
+ "version": "0.5.9-4",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -48,7 +48,7 @@ export type Services = {
48
48
  /*----------------------------------
49
49
  - SERVICE
50
50
  ----------------------------------*/
51
- export default class CommandsManager extends Service<Config, Hooks, Application, Services> {
51
+ export default class CommandsManager extends Service<Config, Hooks, Application> {
52
52
 
53
53
  public priority = 2 as 2;
54
54
 
@@ -376,7 +376,7 @@ export default class Console {
376
376
  logs
377
377
  }
378
378
 
379
- await application.reportBug( bugReport );
379
+ await application.runHook('bug', bugReport);
380
380
  }
381
381
 
382
382
  public getChannel() {
@@ -2,8 +2,6 @@
2
2
  - DEPENDANCES
3
3
  ----------------------------------*/
4
4
 
5
- import './patch';
6
-
7
5
  // Npm
8
6
  import path from 'path';
9
7
 
@@ -99,7 +99,7 @@ export abstract class Application<
99
99
 
100
100
  // Application itself doesnt have configuration
101
101
  // Configuration must be handled by application services
102
- super(self, {}, () => ({}), self);
102
+ super(self, {}, self);
103
103
 
104
104
  // Handle unhandled crash
105
105
  this.on('error', (e, request) => this.container.handleBug(e, "An error occured in the application", request));
@@ -138,6 +138,9 @@ export abstract class Application<
138
138
 
139
139
  this.startServices();
140
140
 
141
+ console.log('----------------------------------');
142
+ console.log('- SERVICES');
143
+ console.log('----------------------------------');
141
144
  await this.ready();
142
145
  await this.runHook('ready');
143
146
 
@@ -150,71 +153,41 @@ export abstract class Application<
150
153
  - ERROR HANDLING
151
154
  ----------------------------------*/
152
155
 
153
- // Default error handler
154
- public async reportBug( bug: ServerBug ) {
155
-
156
- console.error( bug.error );
157
-
158
- }
159
-
160
156
  private startServices() {
161
-
162
- // Print services
163
- console.log('----------------------------------');
164
- console.log('- SERVICES');
165
- console.log('----------------------------------');
166
- const printService = (service, level: number = 0) => {
167
-
168
- console.log('-' + '-'.repeat(level * 4), service.name, '(' + service.priority + ')');
169
-
170
- if (service.subservices) for (const subservice of service.subservices)
171
- printService(subservice, level + 1);
172
- }
173
157
 
174
158
  // Satrt services
175
159
  for (const serviceId in this.registered) {
176
160
 
177
161
  const service = this.registered[serviceId];
178
- printService(service, 0);
179
162
  const instance = service.start();
180
163
  this[service.name] = instance.getServiceInstance();
181
- this[service.name].status = 'starting';
182
164
  }
183
165
  }
184
166
 
167
+ public register( service: AnyService ) {
168
+
169
+ service.ready();
170
+
171
+ }
172
+
185
173
  protected async ready() {
186
174
 
187
- const processService = (service: AnyService) => {
175
+ // Print services
176
+ const processService = (propKey: string, service: AnyService, level: number = 0) => {
188
177
 
189
178
  if (service.status !== 'starting')
190
179
  return;
191
180
 
192
181
  service.ready();
193
182
  service.status = 'running';
194
-
195
- // Subservices
196
- for (const serviceId in service.services) {
197
-
198
- const subservice = service.services[serviceId];
199
- if (!subservice) {
200
- console.error(`Subservice ${serviceId} has not been initialised correctly in ${service.constructor.name}`, service.services);
201
- continue;
202
- }
183
+ console.log('-' + '-'.repeat(level * 1), propKey + ': ' + service.constructor.name);
203
184
 
204
- processService(subservice);
205
- }
206
- }
207
-
208
- for (const serviceId in this.registered) {
209
-
210
- const registeredService = this.registered[serviceId];
211
- const service = this[registeredService.name];
212
-
213
- // TODO: move to router
214
- // Application.on('service.ready')
185
+ // Routes
215
186
  const routes = service.__routes;
216
187
  if (routes) for (const route of routes) {
217
188
 
189
+ console.log('Attached service', service.constructor.name, 'to route', route.path);
190
+
218
191
  const origController = route.controller;
219
192
  route.controller = (context: RouterContext) => {
220
193
 
@@ -232,8 +205,37 @@ export abstract class Application<
232
205
 
233
206
  this.Router.controllers[ route.path ] = route;
234
207
  }
208
+
209
+ // Subservices
210
+ for (const propKey in service) {
211
+
212
+ if (propKey === 'app')
213
+ continue;
214
+ const propValue = service[propKey];
215
+
216
+ // Check if service
217
+ const isService =
218
+ typeof propValue === 'object' &&
219
+ !(propValue instanceof Application) &&
220
+ propValue !== null &&
221
+ propValue.status !== undefined;
222
+ if (!isService)
223
+ continue;
224
+
225
+ processService(propKey, propValue, level + 1);
226
+ }
227
+ }
228
+
229
+ for (const serviceId in this.registered) {
230
+
231
+ const registeredService = this.registered[serviceId];
232
+ const service = this[registeredService.name];
233
+
234
+ // TODO: move to router
235
+ // Application.on('service.ready')
236
+
235
237
 
236
- processService(service);
238
+ processService(serviceId, service);
237
239
  }
238
240
  }
239
241
 
@@ -13,11 +13,7 @@ import type { TControllerDefinition, TRoute } from '../../services/router';
13
13
  ----------------------------------*/
14
14
 
15
15
  export type AnyService<TSubServices extends StartedServicesIndex = StartedServicesIndex> =
16
- Service<{}, {}, Application, TSubServices>
17
-
18
- type TServiceConfig = {
19
- priority?: number
20
- }
16
+ Service<{}, {}, Application>
21
17
 
22
18
  export type { TRegisteredServicesIndex, TRegisteredService } from './container';
23
19
 
@@ -41,9 +37,11 @@ export type StartedServicesIndex = {
41
37
  [serviceId: string]: AnyService
42
38
  }
43
39
 
44
- type TServiceUseOptions = {
45
- optional?: boolean
46
- }
40
+ export type TServiceArgs<TService extends AnyService> = [
41
+ parent: TService | 'self',
42
+ getConfig: (instance: TService) => {},
43
+ app: TService['app'] | 'self'
44
+ ]
47
45
 
48
46
  /*----------------------------------
49
47
  - CONFIG
@@ -51,7 +49,7 @@ type TServiceUseOptions = {
51
49
 
52
50
  const LogPrefix = '[service]';
53
51
 
54
- export function Route(options: TControllerDefinition = {}) {
52
+ export function Route(options: Omit<TControllerDefinition, 'controller'> = {}) {
55
53
  return function (
56
54
  target: any,
57
55
  propertyKey: string,
@@ -90,30 +88,24 @@ export function Route(options: TControllerDefinition = {}) {
90
88
  - CLASS
91
89
  ----------------------------------*/
92
90
  export default abstract class Service<
93
- TConfig extends TServiceConfig,
91
+ TConfig extends {},
94
92
  THooks extends THooksList,
95
- TApplication extends Application,
96
- TServicesIndex extends StartedServicesIndex = {}
93
+ TApplication extends Application
97
94
  > {
98
95
 
99
96
  public started?: Promise<void>;
100
- public status: 'stopped' | 'starting' | 'running' | 'paused' = 'stopped';
97
+ public status: 'stopped' | 'starting' | 'running' | 'paused' = 'starting';
101
98
 
102
99
  public commands?: Command[];
103
100
  public metas!: TServiceMetas;
104
101
  public bindings: string[] = []
105
102
 
106
103
  public app: TApplication;
104
+ public config: TConfig = {} as TConfig;
107
105
 
108
- public constructor(
109
- public parent: AnyService | 'self',
110
- public config: TConfig,
111
- // Make this argument appear as instanciated sercices index
112
- // But actually, Setup.use returns a registered service, not yet launched
113
- getServices: (instance: AnyService) => TServicesIndex,
114
- app: TApplication | 'self'
115
- ) {
106
+ public constructor(...[parent, getConfig, app]: TServiceArgs<AnyService>) {
116
107
 
108
+ this.parent = parent;
117
109
  if (this.parent === 'self')
118
110
  this.parent = this;
119
111
 
@@ -121,8 +113,8 @@ export default abstract class Service<
121
113
  ? this as unknown as TApplication
122
114
  : app
123
115
 
124
- if (typeof getServices === 'function')
125
- this.services = getServices(this);
116
+ if (typeof getConfig === 'function')
117
+ this.config = getConfig(this);
126
118
 
127
119
  }
128
120
 
@@ -130,8 +122,6 @@ export default abstract class Service<
130
122
  return this;
131
123
  }
132
124
 
133
- public services: TServicesIndex = {} as TServicesIndex;
134
-
135
125
  /*----------------------------------
136
126
  - LIFECYCLE
137
127
  ----------------------------------*/
@@ -37,12 +37,12 @@ export default class AuthenticationRouterService<
37
37
  - LIFECYCLE
38
38
  ----------------------------------*/
39
39
 
40
- public users;
40
+ public users: UsersService;
41
41
 
42
42
  public constructor(...args) {
43
43
  super(...args);
44
44
 
45
- this.users = this.services.users;
45
+ this.users = this.config.users;
46
46
  }
47
47
 
48
48
  protected async ready() {
@@ -51,7 +51,7 @@ export default class AuthenticationRouterService<
51
51
  this.parent.on('request', async (request: TRequest) => {
52
52
 
53
53
  // TODO: Typings. (context.user ?)
54
- const decoded = await this.services.users.decode( request.req, true);
54
+ const decoded = await this.users.decode( request.req, true);
55
55
 
56
56
  request.user = decoded || null;
57
57
  })
@@ -61,7 +61,7 @@ export default class AuthenticationRouterService<
61
61
 
62
62
  if (route.options.auth !== undefined)
63
63
  // TODO: How to pas the router type to router config ? Circular rfeerence ?
64
- this.services.users.check(request, route.options.auth);
64
+ this.users.check(request, route.options.auth);
65
65
  })
66
66
  }
67
67
 
@@ -59,20 +59,17 @@ type TCacheGetOnlyArgs = [
59
59
  export type Config = {
60
60
  debug: boolean,
61
61
  disk: string, // TODO: keyof disks
62
+ disks: DisksManager
62
63
  }
63
64
 
64
65
  export type Hooks = {
65
66
 
66
67
  }
67
68
 
68
- export type Services = {
69
- disks: DisksManager,
70
- }
71
-
72
69
  /*----------------------------------
73
70
  - SERVICE
74
71
  ----------------------------------*/
75
- export default class Cache extends Service<Config, Hooks, Application, Services> {
72
+ export default class Cache extends Service<Config, Hooks, Application> {
76
73
 
77
74
  public commands = registerCommands(this);
78
75
 
@@ -83,13 +80,12 @@ export default class Cache extends Service<Config, Hooks, Application, Services>
83
80
  public constructor(
84
81
  parent: AnyService,
85
82
  config: Config,
86
- services: Services,
87
83
  app: Application,
88
84
  ) {
89
85
 
90
- super(parent, config, services, app);
86
+ super(parent, config, app);
91
87
 
92
- this.disk = this.services.disks.get(config.disk)
88
+ this.disk = this.config.disks.get(config.disk)
93
89
  }
94
90
 
95
91
  /*----------------------------------
@@ -36,7 +36,7 @@ export type Services = {
36
36
  - CLASSE
37
37
  ----------------------------------*/
38
38
 
39
- export default class CronManager extends Service<Config, Hooks, Application, Services> {
39
+ export default class CronManager extends Service<Config, Hooks, Application> {
40
40
 
41
41
  public static taches: { [nom: string]: CronTask } = {}
42
42
  public static timer: NodeJS.Timeout;
@@ -91,20 +91,19 @@ const emptyOkPacket = {
91
91
 
92
92
  // TODO: build callable instance sithut instanciating the service
93
93
 
94
- export default class SQL extends Service<Config, Hooks, Application, Services> {
94
+ export default class SQL extends Service<Config, Hooks, Application> {
95
95
 
96
96
  public database: Database;
97
97
 
98
98
  public constructor(
99
99
  parent: AnyService,
100
100
  config: Config,
101
- drivers: () => TRegisteredServicesIndex,
102
101
  app: Application,
103
102
  ) {
104
103
 
105
- super(parent, config, drivers, app);
104
+ super(parent, config, app);
106
105
 
107
- this.database = new Database(this, config);
106
+ this.database = new Database(this, this.config);
108
107
  }
109
108
 
110
109
  public getServiceInstance() {
@@ -56,7 +56,7 @@ export type TReadFileOptions = {
56
56
  export default abstract class FsDriver<
57
57
  Config extends TDrivercnfig = TDrivercnfig,
58
58
  TBucketName = keyof Config["buckets"]
59
- > extends Service<Config, {}, Application, Services> {
59
+ > extends Service<Config, {}, Application> {
60
60
 
61
61
  public abstract mount(): Promise<void>;
62
62
 
@@ -17,6 +17,9 @@ export type { default as Driver } from './driver';
17
17
  type Config = {
18
18
  debug: boolean,
19
19
  default: string,//keyof MountpointList,
20
+ drivers: {
21
+ [driverId: string]: Driver
22
+ }
20
23
  }
21
24
 
22
25
  export type Hooks = {
@@ -34,12 +37,10 @@ export default class DisksManager<
34
37
  MountpointList extends Services = {},
35
38
  TConfig extends Config = Config,
36
39
  TApplication extends Application = Application
37
- > extends Service<TConfig, Hooks, TApplication, MountpointList> {
40
+ > extends Service<TConfig, Hooks, TApplication> {
38
41
 
39
42
  public default!: Driver;
40
43
 
41
- public mounted: MountpointList = this.services;
42
-
43
44
  /*----------------------------------
44
45
  - LIFECYCLE
45
46
  ----------------------------------*/
@@ -47,13 +48,12 @@ export default class DisksManager<
47
48
  public constructor(
48
49
  parent: AnyService,
49
50
  config: TConfig,
50
- services: () => TRegisteredServicesIndex,
51
51
  app: Application,
52
52
  ) {
53
53
 
54
- super(parent, config, services, app);
54
+ super(parent, config, app);
55
55
 
56
- const drivers = this.services;
56
+ const drivers = this.config.drivers;
57
57
 
58
58
  if (Object.keys( drivers ).length === 0)
59
59
  throw new Error("At least one disk driver should be mounted.");
@@ -78,7 +78,7 @@ export default class DisksManager<
78
78
 
79
79
  const disk = diskName == 'default' || diskName === undefined
80
80
  ? this.default
81
- : this.mounted[diskName];
81
+ : this.config.drivers[diskName];
82
82
 
83
83
  if (disk === undefined)
84
84
  throw new Error(`Disk "${diskName as string}" not found.`);
@@ -31,6 +31,9 @@ export type Config = {
31
31
  bugReport: {
32
32
  from: TPerson,
33
33
  to: TPerson
34
+ },
35
+ transporters: {
36
+ [transporterId: string]: Transporter
34
37
  }
35
38
  }
36
39
 
@@ -106,9 +109,9 @@ type TOptions = {
106
109
  /*----------------------------------
107
110
  - FONCTIONS
108
111
  ----------------------------------*/
109
- export default class Email extends Service<Config, Hooks, Application, Services> {
112
+ export default class Email extends Service<Config, Hooks, Application> {
110
113
 
111
- private transporters = this.services;
114
+ private transporters = this.config.transporters;
112
115
 
113
116
  /*----------------------------------
114
117
  - ACTIONS
@@ -26,18 +26,16 @@ import type FsDriver from '../disks/driver';
26
26
 
27
27
  export type Config = {
28
28
  debug?: boolean,
29
- disk?: string
29
+ disk?: string,
30
+
31
+ disks: DisksManager,
32
+ router?: RouterService
30
33
  }
31
34
 
32
35
  export type Hooks = {
33
36
 
34
37
  }
35
38
 
36
- export type Services = {
37
- disks: DisksManager,
38
- router?: RouterService
39
- }
40
-
41
39
  /*----------------------------------
42
40
  - TYPES
43
41
  ----------------------------------*/
@@ -60,14 +58,14 @@ const LogPrefix = `[services][fetch]`
60
58
  - SERVICE
61
59
  - Tools that helps to consume external resources (including apis, ..)
62
60
  -----------------------------------*/
63
- export default class FetchService extends Service<Config, Hooks, Application, Services> {
61
+ export default class FetchService extends Service<Config, Hooks, Application> {
64
62
 
65
63
  private disk?: FsDriver;
66
64
 
67
65
  public async ready() {
68
66
 
69
- if (this.services.disks)
70
- this.disk = this.services.disks.get( this.config.disk );
67
+ if (this.config.disks)
68
+ this.disk = this.config.disks.get( this.config.disk );
71
69
 
72
70
  }
73
71
 
@@ -97,10 +95,10 @@ export default class FetchService extends Service<Config, Hooks, Application, Se
97
95
  ) {
98
96
 
99
97
  // Parse url if router service is provided
100
- if (this.services.router === undefined)
98
+ if (this.config.router === undefined)
101
99
  throw new Error(`Please bind the Router service to the Fetch service in order to contact APIs.`);
102
100
 
103
- url = this.services.router.url(url);
101
+ url = this.config.router.url(url);
104
102
 
105
103
  // Send request
106
104
  const res = await got(url, {
@@ -34,7 +34,7 @@ export type Services = {
34
34
  - CLASSE
35
35
  ----------------------------------*/
36
36
 
37
- export default class ModelsManager extends Service<Config, Hooks, Application, Services> {
37
+ export default class ModelsManager extends Service<Config, Hooks, Application> {
38
38
 
39
39
  public client = new PrismaClient();
40
40
 
@@ -96,10 +96,10 @@ export type Config<
96
96
  request: ServerRequest<ServerRouter>,
97
97
  app: Application
98
98
  ) => TAdditionnalSsrData,
99
- }
100
99
 
101
- export type Services = {
102
- [routerServiceId: string]: RouterService
100
+ plugins: {
101
+ [routerServiceId: string]: RouterService
102
+ }
103
103
  }
104
104
 
105
105
  // Set it as a function, so when we instanciate the services, we can callthis.router to pass the router instance in roiuter services
@@ -129,7 +129,6 @@ export default class ServerRouter<
129
129
  // Services
130
130
  public http: HTTP;
131
131
  public render: DocumentRenderer<this>;
132
- protected routerServices: TSubservices = {} as TSubservices
133
132
 
134
133
  // Indexed
135
134
  public routes: TRoute[] = []; // API + pages front front
@@ -147,13 +146,12 @@ export default class ServerRouter<
147
146
  public constructor(
148
147
  parent: AnyService,
149
148
  config: Config,
150
- services: () => TSubservices,
151
149
  app: Application,
152
150
  ) {
153
151
 
154
- super(parent, config, services, app);
152
+ super(parent, config, app);
155
153
 
156
- this.http = new HTTP(config.http, this);
154
+ this.http = new HTTP(this.config.http, this);
157
155
  this.render = new DocumentRenderer(this);
158
156
  }
159
157
 
@@ -164,11 +162,8 @@ export default class ServerRouter<
164
162
  public async ready() {
165
163
 
166
164
  // Detect router services
167
- for (const serviceName in this.services) {
168
-
169
- const routerService = this.services[serviceName];
170
- if (routerService instanceof RouterService)
171
- this.routerServices[ serviceName ] = routerService;
165
+ for (const serviceName in this.config.plugins) {
166
+ this.app.register( this.config.plugins[serviceName] )
172
167
  }
173
168
 
174
169
  // Use require to avoid circular references
@@ -326,10 +321,6 @@ export default class ServerRouter<
326
321
 
327
322
  private async afterRegister() {
328
323
 
329
- // Generate typescript typings
330
- if (this.app.env.profile === 'dev')
331
- this.genTypings();
332
-
333
324
  // Ordonne par ordre de priorité
334
325
  this.config.debug && console.info("Loading routes ...");
335
326
  this.routes.sort((r1, r2) => {
@@ -393,21 +384,6 @@ export default class ServerRouter<
393
384
  this.config.debug && console.info(this.routes.length + " routes where registered.");
394
385
  }
395
386
 
396
- private genTypings() {
397
- /*fs.outputFileSync( path.join(this.app.path.typings, 'routes.d.ts'), `
398
- declare type Routes = {
399
- ${this.routes.map( route => `
400
- '${route.path}': {
401
- params: {
402
- ${route.keys.map( k => "'" + k + "': string").join(',\n')}
403
- }
404
- }
405
- `).join(',')}
406
- }
407
- }
408
- `);*/
409
- }
410
-
411
387
  /*----------------------------------
412
388
  - RESOLUTION
413
389
  ----------------------------------*/
@@ -475,10 +451,11 @@ declare type Routes = {
475
451
  public createContextServices( request: ServerRequest<this> ) {
476
452
 
477
453
  const contextServices: Partial<TRouterContextServices<this>> = {}
478
- for (const serviceName in this.routerServices) {
454
+ for (const serviceName in this.config.plugins) {
479
455
 
480
- const routerService = this.routerServices[serviceName];
456
+ const routerService = this.config.plugins[serviceName];
481
457
  const requestService = routerService.requestService( request );
458
+
482
459
  if (requestService !== null)
483
460
  contextServices[ serviceName ] = requestService;
484
461
 
@@ -28,11 +28,10 @@ export default abstract class RouterService<
28
28
  // It's fixed with a not very clean way in Service.bindService
29
29
  router: Router,
30
30
  config: TConfig,
31
- services: TRegisteredServicesIndex,
32
31
  app: Application
33
32
  ) {
34
33
 
35
- super(router, config, services, app);
34
+ super(router, config, app);
36
35
 
37
36
  }
38
37
 
@@ -26,30 +26,27 @@ export type Config<TUser extends {}> = {
26
26
  //server: ServerOptions["server"],
27
27
  //users: UsersManagementService<TUser>,
28
28
  port: number,
29
+
30
+ users: UsersManagementService<TUser, Application>,
31
+ router: Router
29
32
  }
30
33
 
31
34
  export type Hooks = {
32
35
 
33
36
  }
34
37
 
35
- export type Services<TUser extends {}> = {
36
- users: UsersManagementService<TUser, Application>,
37
- router: Router
38
- }
39
-
40
38
  /*----------------------------------
41
39
  - MANAGER
42
40
  ----------------------------------*/
43
41
  export default class WebSocketCommander<
44
42
  TUser extends {},
45
- TConfig extends Config<TUser>= Config<TUser>,
46
- TServices extends Services<TUser> = Services<TUser>
47
- > extends Service<TConfig, Hooks, Application, TServices> {
43
+ TConfig extends Config<TUser>= Config<TUser>
44
+ > extends Service<TConfig, Hooks, Application> {
48
45
 
49
46
  // Services
50
47
  public ws!: WebSocketServer;
51
- public users!: TServices["users"];
52
- public router!: Router;
48
+ public users!: TConfig["users"];
49
+ public router!: TConfig["router"];
53
50
 
54
51
  // Context
55
52
  public scopes: {[path: string]: SocketScope<TUser>} = {}
@@ -57,13 +54,12 @@ export default class WebSocketCommander<
57
54
  public constructor(
58
55
  parent: AnyService,
59
56
  config: TConfig,
60
- services: Services,
61
57
  app: TApplication,
62
58
  ) {
63
- super(parent, config, services, app);
59
+ super(parent, config, app);
64
60
 
65
- this.users = this.services.users;
66
- this.router = this.services.router;
61
+ this.users = this.config.users;
62
+ this.router = this.config.router;
67
63
 
68
64
  }
69
65
 
@@ -90,14 +90,12 @@ declare module '@cli/app' {
90
90
  setup: (...args: [
91
91
  // { user: app.setup('Core/User') }
92
92
  servicePath: string,
93
- serviceConfig?: {},
94
- serviceSubservices?: TServiceSubservices
93
+ serviceConfig?: {}
95
94
  ] | [
96
95
  // app.setup('User', 'Core/User')
97
96
  serviceName: string,
98
97
  servicePath: string,
99
- serviceConfig?: {},
100
- serviceSubservices?: TServiceSubservices
98
+ serviceConfig?: {}
101
99
  ]) => TServiceSetup;
102
100
  }
103
101
  const app: App;
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "solid/spinner-third"|"at"|"bell"|"times-circle"|"info-circle"|"check-circle"|"exclamation-circle"|"times"|"map-marker-alt"|"bullhorn"|"angle-down"|"search"|"check"|"arrow-left"|"arrow-right"|"eye"|"trash"|"meh-rolling-eyes"|"unlink"|"pen"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"link"|"file"|"plus"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"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 = "long-arrow-right"|"times"|"solid/spinner-third"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"planet-ringed"|"crosshairs"|"user-circle"|"brands/linkedin"|"plus-circle"|"comments-alt"|"arrow-right"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"key"|"user"|"at"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"times-circle"|"calendar-alt"|"paper-plane"|"search"|"lightbulb"|"magnet"|"solid/crown"|"brands/discord"|"pen"|"plus"|"file"|"angle-up"|"angle-down"|"envelope"|"binoculars"|"info-circle"|"check-circle"|"exclamation-circle"|"meh-rolling-eyes"|"check"|"trash"|"arrow-left"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"cog"|"power-off"|"bars"|"plane-departure"|"wind"|"play"|"minus-circle"|"external-link"|"question-circle"|"usd-circle"|"users"|"home-alt"|"trophy"|"arrow-to-bottom"|"map-marker-alt"|"clock"|"ellipsis-h"|"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"
@@ -1,15 +0,0 @@
1
- /*----------------------------------
2
- - DATES & TIMZEONE
3
- ----------------------------------*/
4
- process.env.TZ = 'Europe/Paris';
5
-
6
- // https://www.npmjs.com/package/javascript-time-ago#intl
7
- import IntlPolyfill from 'intl'
8
- const locales = ['en'];
9
- if (typeof Intl === 'object') {
10
- if (!Intl.DateTimeFormat || Intl.DateTimeFormat.supportedLocalesOf(locales).length !== locales.length) {
11
- Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat
12
- }
13
- } else {
14
- global.Intl = IntlPolyfill
15
- }