5htp-core 0.1.2-3 → 0.2.0
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/changelog.md +5 -0
- package/doc/TODO.md +71 -0
- package/package.json +5 -4
- package/src/client/{App.tsx → app/component.tsx} +15 -8
- package/src/client/app/index.ts +128 -0
- package/src/client/app/service.ts +34 -0
- package/src/client/app.tsconfig.json +0 -4
- package/src/client/components/Card/index.tsx +1 -1
- package/src/client/components/Dialog/Manager.tsx +39 -12
- package/src/client/components/Form/index.tsx +1 -1
- package/src/client/components/button.tsx +2 -2
- package/src/client/components/containers/Popover/index.tsx +1 -1
- package/src/client/components/data/spintext/index.tsx +1 -1
- package/src/client/components/dropdown/index.tsx +1 -1
- package/src/client/components/index.ts +8 -0
- package/src/client/components/input/BaseV2/index.tsx +1 -1
- package/src/client/components/input/UploadImage/index.tsx +1 -1
- package/src/client/hooks/index.ts +5 -0
- package/src/client/hooks/useState/index.tsx +2 -2
- package/src/client/hooks.ts +22 -0
- package/src/client/index.ts +5 -0
- package/src/client/pages/_layout/landing/index.tsx +0 -2
- 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/bug.tsx +1 -1
- package/src/client/pages/useHeader.tsx +1 -1
- package/src/client/{context/captcha.ts → services/captcha/index.ts} +0 -0
- package/src/client/services/metrics/index.ts +37 -0
- package/src/client/{router → services/router/components}/Link.tsx +1 -1
- package/src/client/services/router/components/Page.tsx +59 -0
- package/src/client/{router/component.tsx → services/router/components/router.tsx} +43 -74
- package/src/client/services/router/index.tsx +448 -0
- package/src/client/services/router/request/api.ts +229 -0
- package/src/client/{router → services/router}/request/history.ts +0 -0
- package/src/client/services/router/request/index.ts +52 -0
- package/src/client/services/router/response/index.tsx +107 -0
- package/src/client/services/router/response/page.ts +95 -0
- package/src/client/{context/socket.ts → services/socket/index.ts} +2 -2
- package/src/client/utils/dom.ts +1 -1
- package/src/common/app/index.ts +9 -0
- package/src/common/data/chaines/index.ts +9 -6
- package/src/common/data/input/validate.ts +3 -166
- package/src/common/data/objets.ts +25 -0
- package/src/common/data/tableaux.ts +8 -0
- package/src/common/errors/index.ts +3 -1
- package/src/common/router/index.ts +67 -88
- package/src/common/router/layouts.ts +50 -0
- package/src/common/router/register.ts +62 -0
- package/src/common/router/request/api.ts +72 -0
- package/src/common/router/request/index.ts +31 -0
- package/src/common/router/{response.ts → response/index.ts} +9 -13
- package/src/common/router/response/page.ts +40 -56
- package/src/common/validation/index.ts +3 -0
- package/src/common/validation/schema.ts +184 -0
- package/src/common/validation/validator.ts +88 -0
- package/src/common/validation/validators.ts +313 -0
- package/src/server/app/config.ts +8 -10
- package/src/server/app/index.ts +81 -124
- package/src/server/app/service.ts +98 -0
- package/src/server/app.tsconfig.json +0 -8
- package/src/server/error/index.ts +13 -0
- package/src/server/index.ts +5 -0
- package/src/server/patch.ts +0 -6
- package/src/server/{data/Cache.ts → services/cache/index.ts} +79 -47
- package/src/server/services/console/bugReporter.ts +26 -16
- package/src/server/services/console/index.ts +50 -51
- package/src/server/services/cron/index.ts +12 -26
- package/src/server/services/database/bucket.ts +40 -0
- package/src/server/services/database/connection.ts +206 -75
- package/src/server/services/database/datatypes.ts +63 -40
- package/src/server/services/database/index.ts +295 -272
- package/src/server/services/database/metas.ts +246 -135
- package/src/server/services/database/stats.ts +151 -126
- package/src/server/services/email/index.ts +24 -54
- package/src/server/services/{router/request/services → metrics}/detect.ts +6 -10
- package/src/server/services/{router/request/services/tracking.ts → metrics/index.ts} +68 -45
- package/src/server/services/{http → router/http}/index.ts +19 -47
- package/src/server/services/{http → router/http}/multipart.ts +0 -0
- package/src/server/services/{http → router/http}/session.ts.old +0 -0
- package/src/server/services/router/index.ts +273 -203
- package/src/server/services/router/request/api.ts +73 -0
- package/src/server/services/router/request/index.ts +16 -95
- package/src/server/services/router/request/service.ts +21 -0
- package/src/server/services/router/response/index.ts +125 -64
- package/src/server/services/router/response/{filter → mask}/Filter.ts +0 -0
- package/src/server/services/router/response/{filter → mask}/index.ts +0 -2
- package/src/server/services/router/response/{filter → mask}/selecteurs.ts +0 -0
- package/src/server/services/router/response/page/document.tsx +194 -0
- package/src/server/services/router/response/page/index.tsx +157 -0
- package/src/server/{libs/pages → services/router/response/page}/schemaGenerator.ts +0 -0
- package/src/server/services/router/service.ts +48 -0
- package/src/server/services/schema/index.ts +47 -0
- package/src/server/services/schema/request.ts +55 -0
- package/src/server/services/schema/router.ts +33 -0
- package/src/server/services/socket/index.ts +38 -43
- package/src/server/services/socket/scope.ts +6 -4
- package/src/server/services/users/index.ts +203 -0
- package/src/server/services/{auth/base.ts → users/old.ts} +20 -111
- package/src/server/services/users/router/index.ts +72 -0
- package/src/server/services/users/router/request.ts +49 -0
- package/src/types/aliases.d.ts +43 -2
- package/templates/composant.tsx +1 -1
- package/templates/modal.tsx +1 -1
- package/templates/page.tsx +1 -1
- package/tsconfig.common.json +0 -4
- package/src/client/context/api.ts +0 -92
- package/src/client/context/index.ts +0 -246
- package/src/client/index.tsx +0 -129
- package/src/client/router/index.ts +0 -286
- package/src/client/router/request/index.ts +0 -106
- package/src/client/router/response/index.ts +0 -38
- package/src/client/router/route.ts +0 -75
- package/src/common/data/input/validators/basic.ts +0 -299
- package/src/common/data/input/validators/build.ts +0 -63
- package/src/common/router/request.ts +0 -83
- package/src/server/data/ApiClient.ts +0 -119
- package/src/server/data/input.ts +0 -41
- package/src/server/libs/pages/document.static.tsx +0 -41
- package/src/server/libs/pages/document.tsx +0 -203
- package/src/server/libs/pages/render.tsx +0 -90
- package/src/server/routes/auth.ts +0 -151
- package/src/server/services/redis/index.ts +0 -71
- package/src/server/services/router/request/services/auth.ts +0 -177
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { v4 as uuid } from 'uuid';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import
|
|
10
|
-
import type
|
|
9
|
+
import { SqlError } from '@server/error';
|
|
10
|
+
import type Console from '.';
|
|
11
11
|
|
|
12
12
|
// Types
|
|
13
13
|
import type ServerRequest from '@server/services/router/request';
|
|
@@ -72,8 +72,6 @@ export type ApplicationBug = {
|
|
|
72
72
|
stacktrace: string
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const config = app.config.console;
|
|
76
|
-
|
|
77
75
|
/*----------------------------------
|
|
78
76
|
- CONFIG
|
|
79
77
|
----------------------------------*/
|
|
@@ -110,7 +108,8 @@ export default class BugReporter {
|
|
|
110
108
|
private sentBugs: {[bugId: string]: number} = {};
|
|
111
109
|
|
|
112
110
|
public constructor(
|
|
113
|
-
private console: Console
|
|
111
|
+
private console: Console,
|
|
112
|
+
public app = console.app,
|
|
114
113
|
) {
|
|
115
114
|
|
|
116
115
|
}
|
|
@@ -133,7 +132,16 @@ export default class BugReporter {
|
|
|
133
132
|
|
|
134
133
|
public async server( error: Error, request?: ServerRequest ) {
|
|
135
134
|
|
|
136
|
-
//
|
|
135
|
+
// Print the error so it's accessible via logs
|
|
136
|
+
if (error instanceof SqlError) {
|
|
137
|
+
let printedQuery: string;
|
|
138
|
+
try {
|
|
139
|
+
printedQuery = this.console.printSql( error.query );
|
|
140
|
+
} catch (error) {
|
|
141
|
+
printedQuery = 'Failed to print query:' + (error || 'unknown error');
|
|
142
|
+
}
|
|
143
|
+
console.error(`Error caused by this query:`, printedQuery);
|
|
144
|
+
}
|
|
137
145
|
console.error(LogPrefix, `Sending bug report for the following error:`, error);
|
|
138
146
|
|
|
139
147
|
// Prevent duplicates
|
|
@@ -172,6 +180,7 @@ export default class BugReporter {
|
|
|
172
180
|
|
|
173
181
|
await this.sendToTransporters(bugReport);
|
|
174
182
|
|
|
183
|
+
// TODO: Move on App side
|
|
175
184
|
/*if (app.isLoaded('sql'))
|
|
176
185
|
// Memorize
|
|
177
186
|
$.sql.insert('BugServer', {
|
|
@@ -192,7 +201,7 @@ export default class BugReporter {
|
|
|
192
201
|
error.message = "A bug report has been sent to my personal mailbox. Sorry for the inconvenience.";
|
|
193
202
|
}
|
|
194
203
|
|
|
195
|
-
public async
|
|
204
|
+
public async application( report: AppBugInfos ) {
|
|
196
205
|
|
|
197
206
|
// Prevent duplicates
|
|
198
207
|
if (!this.shouldSendReport(report.side, report.user, report.action, report.message))
|
|
@@ -224,17 +233,12 @@ export default class BugReporter {
|
|
|
224
233
|
stacktrace: report.stacktrace,
|
|
225
234
|
}
|
|
226
235
|
|
|
227
|
-
await this.sendToTransporters(bugReport);
|
|
228
|
-
|
|
229
|
-
/* // Send notification
|
|
230
|
-
$.email.send({
|
|
231
|
-
to: app.identity.author.email,
|
|
232
|
-
subject: "Bug app: " + report.message,
|
|
233
|
-
html: report
|
|
234
|
-
});
|
|
235
236
|
|
|
237
|
+
// TODO:
|
|
236
238
|
// Memorize
|
|
237
|
-
|
|
239
|
+
//$.sql.insert('BugApp', );
|
|
240
|
+
|
|
241
|
+
await this.sendToTransporters(bugReport);
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
private async sendToTransporters( bugReport: Bug, error?: Error ) {
|
|
@@ -245,6 +249,12 @@ export default class BugReporter {
|
|
|
245
249
|
return false;
|
|
246
250
|
}
|
|
247
251
|
|
|
252
|
+
// Don't send if we're in local (avoid to use credits: ex: email, sms)
|
|
253
|
+
if (this.app.env.name === 'local'){
|
|
254
|
+
console.warn(LogPrefix, `Error report sending aborted since we're local.`);
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
|
|
248
258
|
// Send report to trabporters
|
|
249
259
|
await Promise.all(
|
|
250
260
|
this.transporters.map( transport => {
|
|
@@ -8,20 +8,21 @@ import { format as formatSql } from 'sql-formatter';
|
|
|
8
8
|
import highlight from 'cli-highlight';
|
|
9
9
|
|
|
10
10
|
// Core libs
|
|
11
|
-
import
|
|
12
|
-
import logToHTML from './html';
|
|
11
|
+
import Application, { Service, TPriority } from '@server/app';
|
|
13
12
|
import context from '@server/context';
|
|
13
|
+
import type ServerRequest from '@server/services/router/request';
|
|
14
|
+
|
|
15
|
+
// Specific
|
|
16
|
+
import logToHTML from './html';
|
|
14
17
|
import BugReporter from "./bugReporter";
|
|
15
18
|
|
|
16
19
|
/*----------------------------------
|
|
17
20
|
- SERVICE CONFIG
|
|
18
21
|
----------------------------------*/
|
|
19
22
|
|
|
20
|
-
export type TReportTransport = keyof typeof $
|
|
21
|
-
|
|
22
23
|
type TLogProfile = 'silly' | 'info' | 'warn' | 'error'
|
|
23
24
|
|
|
24
|
-
export type
|
|
25
|
+
export type Config = {
|
|
25
26
|
dev: {
|
|
26
27
|
level: TLogProfile,
|
|
27
28
|
},
|
|
@@ -30,15 +31,8 @@ export type ConsoleConfig = {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
interface EmailTransporters { }
|
|
36
|
-
namespace Config {
|
|
37
|
-
interface Services {
|
|
38
|
-
console: ConsoleConfig
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
34
|
+
export type Hooks = {
|
|
35
|
+
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
/*----------------------------------
|
|
@@ -110,7 +104,10 @@ const logFields = [
|
|
|
110
104
|
/*----------------------------------
|
|
111
105
|
- LOGGER
|
|
112
106
|
----------------------------------*/
|
|
113
|
-
export class Console {
|
|
107
|
+
export default class Console extends Service<Config, Hooks, Application> {
|
|
108
|
+
|
|
109
|
+
// Load before all
|
|
110
|
+
public priority: TPriority = 2;
|
|
114
111
|
|
|
115
112
|
// Services
|
|
116
113
|
public logger!: Logger;
|
|
@@ -122,36 +119,50 @@ export class Console {
|
|
|
122
119
|
public requests: TRequestLogs[] = [];
|
|
123
120
|
public sqlQueries: TQueryLogs[] = [];
|
|
124
121
|
|
|
122
|
+
// Adapters
|
|
123
|
+
public log = console.log;
|
|
124
|
+
public warn = console.warn;
|
|
125
|
+
public info = console.info;
|
|
126
|
+
public error = console.error;
|
|
127
|
+
|
|
125
128
|
/*----------------------------------
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
public
|
|
129
|
+
- INSTANCE
|
|
130
|
+
----------------------------------*/
|
|
131
|
+
public async register() {
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public async start() {
|
|
136
|
+
|
|
137
|
+
const envConfig = this.config[ this.app.env.profile ];
|
|
131
138
|
|
|
132
139
|
this.logger = new Logger({
|
|
133
140
|
overwriteConsole: true,
|
|
134
|
-
//type: app.env.profile === 'dev' ? 'pretty' : 'hidden',
|
|
141
|
+
//type: this.app.env.profile === 'dev' ? 'pretty' : 'hidden',
|
|
135
142
|
requestId: (): string => {
|
|
136
143
|
const { channelType, channelId } = this.getChannel();
|
|
137
144
|
return channelId === undefined ? channelType : channelType + ':' + channelId;
|
|
138
145
|
},
|
|
139
146
|
displayRequestId: false,
|
|
147
|
+
prettyInspectOptions: {
|
|
148
|
+
depth: 2
|
|
149
|
+
}
|
|
140
150
|
});
|
|
141
151
|
|
|
142
152
|
this.logger.attachTransport({
|
|
143
|
-
silly: this.
|
|
144
|
-
debug: this.
|
|
145
|
-
trace: this.
|
|
146
|
-
info: this.
|
|
147
|
-
warn: this.
|
|
148
|
-
error: this.
|
|
149
|
-
fatal: this.
|
|
153
|
+
silly: this.logEntry.bind(this),
|
|
154
|
+
debug: this.logEntry.bind(this),
|
|
155
|
+
trace: this.logEntry.bind(this),
|
|
156
|
+
info: this.logEntry.bind(this),
|
|
157
|
+
warn: this.logEntry.bind(this),
|
|
158
|
+
error: this.logEntry.bind(this),
|
|
159
|
+
fatal: this.logEntry.bind(this),
|
|
150
160
|
}, envConfig.level);
|
|
151
161
|
|
|
152
162
|
setInterval(() => this.clean(), 60000);
|
|
153
163
|
|
|
154
|
-
|
|
164
|
+
// Send email report
|
|
165
|
+
this.app.on('error', (error: Error, request?: ServerRequest) => this.bugReport.server(error, request));
|
|
155
166
|
}
|
|
156
167
|
|
|
157
168
|
private clean() {
|
|
@@ -169,7 +180,7 @@ export class Console {
|
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
182
|
|
|
172
|
-
private
|
|
183
|
+
private logEntry(entry: ILogObject) {
|
|
173
184
|
|
|
174
185
|
const [channelType, channelId] = entry.requestId?.split(':') || ['master'];
|
|
175
186
|
if (entry.requestId === 'admin')
|
|
@@ -184,10 +195,10 @@ export class Console {
|
|
|
184
195
|
// remove webpack path
|
|
185
196
|
if (miniLog.filePath !== undefined) {
|
|
186
197
|
|
|
187
|
-
const appPrefix = '/webpack:/' + app.pkg.name + '/src/';
|
|
198
|
+
const appPrefix = '/webpack:/' + this.app.pkg.name + '/src/';
|
|
188
199
|
const appPrefixIndex = miniLog.filePath.indexOf(appPrefix);
|
|
189
200
|
|
|
190
|
-
const corePrefix = '/webpack:/' + app.pkg.name + '/node_modules/5htp-core/src/';
|
|
201
|
+
const corePrefix = '/webpack:/' + this.app.pkg.name + '/node_modules/5htp-core/src/';
|
|
191
202
|
const corePrefixIndex = miniLog.filePath.indexOf(corePrefix);
|
|
192
203
|
|
|
193
204
|
if (appPrefixIndex !== -1)
|
|
@@ -216,8 +227,8 @@ export class Console {
|
|
|
216
227
|
- READ
|
|
217
228
|
----------------------------------*/
|
|
218
229
|
|
|
219
|
-
public getClients() {
|
|
220
|
-
return
|
|
230
|
+
/*public getClients() {
|
|
231
|
+
return sql`
|
|
221
232
|
SELECT * FROM logs.Clients
|
|
222
233
|
ORDER BY activity DESC
|
|
223
234
|
LIMIT 100
|
|
@@ -228,7 +239,7 @@ export class Console {
|
|
|
228
239
|
return (
|
|
229
240
|
this.clients.find(c => c.id === clientId)
|
|
230
241
|
||
|
|
231
|
-
await
|
|
242
|
+
await sql`
|
|
232
243
|
SELECT * FROM logs.Clients
|
|
233
244
|
WHERE id = ${clientId}
|
|
234
245
|
`.first()
|
|
@@ -236,7 +247,7 @@ export class Console {
|
|
|
236
247
|
}
|
|
237
248
|
|
|
238
249
|
public getRequests(clientId?: string) {
|
|
239
|
-
return
|
|
250
|
+
return sql`
|
|
240
251
|
SELECT * FROM logs.Requests
|
|
241
252
|
ORDER BY date DESC
|
|
242
253
|
LIMIT 100
|
|
@@ -247,7 +258,7 @@ export class Console {
|
|
|
247
258
|
return (
|
|
248
259
|
this.requests.find(r => r.id === requestId)
|
|
249
260
|
||
|
|
250
|
-
await
|
|
261
|
+
await sql`
|
|
251
262
|
SELECT * FROM logs.Requests
|
|
252
263
|
WHERE id = ${requestId}
|
|
253
264
|
`.first()
|
|
@@ -260,13 +271,13 @@ export class Console {
|
|
|
260
271
|
if (channelId !== undefined)
|
|
261
272
|
filters.channelId = channelId;
|
|
262
273
|
|
|
263
|
-
return
|
|
274
|
+
return sql`
|
|
264
275
|
SELECT * FROM logs.Queries
|
|
265
276
|
WHERE :${filters}
|
|
266
277
|
ORDER BY date DESC
|
|
267
278
|
LIMIT 100
|
|
268
279
|
`.all();
|
|
269
|
-
}
|
|
280
|
+
}*/
|
|
270
281
|
|
|
271
282
|
public async getLogs( channelType: ChannelInfos["channelType"], channelId?: string ) {
|
|
272
283
|
|
|
@@ -283,7 +294,7 @@ export class Console {
|
|
|
283
294
|
|
|
284
295
|
public printHtml(logs: TLog[], full: boolean = false): string {
|
|
285
296
|
|
|
286
|
-
let html = logs.map(
|
|
297
|
+
let html = logs.map( logEntry => logToHTML( logEntry, this )).join('\n');
|
|
287
298
|
|
|
288
299
|
if (full) {
|
|
289
300
|
const consoleCss = `background: #000; padding: 20px; font-family: 'Fira Mono', 'monospace', 'Monaco'; font-size: 12px; line-height: 20px;`
|
|
@@ -298,16 +309,4 @@ export class Console {
|
|
|
298
309
|
{ language: 'sql', ignoreIllegals: true }
|
|
299
310
|
)
|
|
300
311
|
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/*----------------------------------
|
|
304
|
-
- REGISTER SERVICE
|
|
305
|
-
----------------------------------*/
|
|
306
|
-
app.register('console', Console);
|
|
307
|
-
declare global {
|
|
308
|
-
namespace Core {
|
|
309
|
-
interface Services {
|
|
310
|
-
console: Console;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
312
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
5
|
// Core
|
|
6
|
+
import Application, { Service } from '@server/app';
|
|
6
7
|
import { NotFound } from '@common/errors';
|
|
7
|
-
import app from '@server/app';
|
|
8
8
|
import context from '@server/context';
|
|
9
9
|
|
|
10
10
|
/*----------------------------------
|
|
@@ -19,25 +19,19 @@ export { default as CronTask } from './CronTask';
|
|
|
19
19
|
- SERVICE CONFIG
|
|
20
20
|
----------------------------------*/
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type Config = {
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
namespace Config {
|
|
29
|
-
interface Services {
|
|
30
|
-
cron: CronServiceConfig
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
26
|
+
export type Hooks = {
|
|
27
|
+
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
/*----------------------------------
|
|
37
31
|
- CLASSE
|
|
38
32
|
----------------------------------*/
|
|
39
33
|
|
|
40
|
-
export class CronManager {
|
|
34
|
+
export default class CronManager extends Service<Config, Hooks, Application> {
|
|
41
35
|
|
|
42
36
|
public static taches: { [nom: string]: CronTask } = {}
|
|
43
37
|
public static timer: NodeJS.Timeout;
|
|
@@ -45,11 +39,15 @@ export class CronManager {
|
|
|
45
39
|
/*----------------------------------
|
|
46
40
|
- HOOKS
|
|
47
41
|
----------------------------------*/
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
|
|
43
|
+
public async register() {
|
|
44
|
+
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
public async
|
|
47
|
+
public async start() {
|
|
48
|
+
|
|
49
|
+
this.app.on('cleanup', () => this.cleanup());
|
|
50
|
+
|
|
53
51
|
clearInterval(CronManager.timer);
|
|
54
52
|
CronManager.timer = setInterval(() => {
|
|
55
53
|
|
|
@@ -116,16 +114,4 @@ export class CronManager {
|
|
|
116
114
|
throw new Error(`L'instance de la tâche cron ${name} n'a pas été trouvée`);
|
|
117
115
|
return cron;
|
|
118
116
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/*----------------------------------
|
|
122
|
-
- REGISTER SERVICE
|
|
123
|
-
----------------------------------*/
|
|
124
|
-
app.register('cron', CronManager);
|
|
125
|
-
declare global {
|
|
126
|
-
namespace Core {
|
|
127
|
-
interface Services {
|
|
128
|
-
cron: CronManager;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
117
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
// Core
|
|
6
|
+
import { TQueryOptions } from './connection';
|
|
7
|
+
|
|
8
|
+
/*----------------------------------
|
|
9
|
+
- TYPES
|
|
10
|
+
----------------------------------*/
|
|
11
|
+
|
|
12
|
+
const LogPrefix = '[database][bucket]';
|
|
13
|
+
|
|
14
|
+
/*----------------------------------
|
|
15
|
+
- CLASS
|
|
16
|
+
----------------------------------*/
|
|
17
|
+
export default class Queriesbucket {
|
|
18
|
+
|
|
19
|
+
public queries: Set<string>;
|
|
20
|
+
|
|
21
|
+
public constructor(
|
|
22
|
+
private queryOptions: TQueryOptions<'bucket'> = {},
|
|
23
|
+
queriesList: string[] = [],
|
|
24
|
+
) {
|
|
25
|
+
this.queries = new Set<string>(queriesList);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public add( query: string ) {
|
|
29
|
+
this.queries.add(query);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public delete( query: string ) {
|
|
34
|
+
this.queries.delete(query);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public run() {
|
|
38
|
+
this.queryOptions.log && console.log(LogPrefix, `Run queries bucket`, ...this.queries);
|
|
39
|
+
}
|
|
40
|
+
}
|