5htp-core 0.1.2 → 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/assets/css/medias.less +14 -0
- package/src/client/components/Card/index.tsx +2 -2
- 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 +9 -27
- 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 +59 -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 +28 -52
- package/src/server/services/{router/request/services → metrics}/detect.ts +8 -10
- package/src/server/services/{router/request/services/tracking.ts → metrics/index.ts} +68 -45
- package/src/server/services/{http → router/http}/index.ts +28 -70
- 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 -97
- 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} +28 -112
- 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,30 +8,31 @@ 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
|
-
|
|
23
|
+
type TLogProfile = 'silly' | 'info' | 'warn' | 'error'
|
|
21
24
|
|
|
22
|
-
export type
|
|
23
|
-
|
|
25
|
+
export type Config = {
|
|
26
|
+
dev: {
|
|
27
|
+
level: TLogProfile,
|
|
28
|
+
},
|
|
29
|
+
prod: {
|
|
30
|
+
level: TLogProfile
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
interface EmailTransporters { }
|
|
29
|
-
namespace Config {
|
|
30
|
-
interface Services {
|
|
31
|
-
console: ConsoleConfig
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
34
|
+
export type Hooks = {
|
|
35
|
+
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/*----------------------------------
|
|
@@ -103,7 +104,10 @@ const logFields = [
|
|
|
103
104
|
/*----------------------------------
|
|
104
105
|
- LOGGER
|
|
105
106
|
----------------------------------*/
|
|
106
|
-
export class Console {
|
|
107
|
+
export default class Console extends Service<Config, Hooks, Application> {
|
|
108
|
+
|
|
109
|
+
// Load before all
|
|
110
|
+
public priority: TPriority = 2;
|
|
107
111
|
|
|
108
112
|
// Services
|
|
109
113
|
public logger!: Logger;
|
|
@@ -115,34 +119,50 @@ export class Console {
|
|
|
115
119
|
public requests: TRequestLogs[] = [];
|
|
116
120
|
public sqlQueries: TQueryLogs[] = [];
|
|
117
121
|
|
|
122
|
+
// Adapters
|
|
123
|
+
public log = console.log;
|
|
124
|
+
public warn = console.warn;
|
|
125
|
+
public info = console.info;
|
|
126
|
+
public error = console.error;
|
|
127
|
+
|
|
118
128
|
/*----------------------------------
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
public
|
|
129
|
+
- INSTANCE
|
|
130
|
+
----------------------------------*/
|
|
131
|
+
public async register() {
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public async start() {
|
|
136
|
+
|
|
137
|
+
const envConfig = this.config[ this.app.env.profile ];
|
|
122
138
|
|
|
123
139
|
this.logger = new Logger({
|
|
124
140
|
overwriteConsole: true,
|
|
125
|
-
//type: app.env.profile === 'dev' ? 'pretty' : 'hidden',
|
|
141
|
+
//type: this.app.env.profile === 'dev' ? 'pretty' : 'hidden',
|
|
126
142
|
requestId: (): string => {
|
|
127
143
|
const { channelType, channelId } = this.getChannel();
|
|
128
144
|
return channelId === undefined ? channelType : channelType + ':' + channelId;
|
|
129
145
|
},
|
|
130
146
|
displayRequestId: false,
|
|
147
|
+
prettyInspectOptions: {
|
|
148
|
+
depth: 2
|
|
149
|
+
}
|
|
131
150
|
});
|
|
132
151
|
|
|
133
152
|
this.logger.attachTransport({
|
|
134
|
-
silly: this.
|
|
135
|
-
debug: this.
|
|
136
|
-
trace: this.
|
|
137
|
-
info: this.
|
|
138
|
-
warn: this.
|
|
139
|
-
error: this.
|
|
140
|
-
fatal: this.
|
|
141
|
-
},
|
|
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),
|
|
160
|
+
}, envConfig.level);
|
|
142
161
|
|
|
143
162
|
setInterval(() => this.clean(), 60000);
|
|
144
163
|
|
|
145
|
-
|
|
164
|
+
// Send email report
|
|
165
|
+
this.app.on('error', (error: Error, request?: ServerRequest) => this.bugReport.server(error, request));
|
|
146
166
|
}
|
|
147
167
|
|
|
148
168
|
private clean() {
|
|
@@ -160,7 +180,7 @@ export class Console {
|
|
|
160
180
|
}
|
|
161
181
|
}
|
|
162
182
|
|
|
163
|
-
private
|
|
183
|
+
private logEntry(entry: ILogObject) {
|
|
164
184
|
|
|
165
185
|
const [channelType, channelId] = entry.requestId?.split(':') || ['master'];
|
|
166
186
|
if (entry.requestId === 'admin')
|
|
@@ -175,10 +195,10 @@ export class Console {
|
|
|
175
195
|
// remove webpack path
|
|
176
196
|
if (miniLog.filePath !== undefined) {
|
|
177
197
|
|
|
178
|
-
const appPrefix = '/webpack:/' + app.pkg.name + '/src/';
|
|
198
|
+
const appPrefix = '/webpack:/' + this.app.pkg.name + '/src/';
|
|
179
199
|
const appPrefixIndex = miniLog.filePath.indexOf(appPrefix);
|
|
180
200
|
|
|
181
|
-
const corePrefix = '/webpack:/' + app.pkg.name + '/node_modules/5htp-core/src/';
|
|
201
|
+
const corePrefix = '/webpack:/' + this.app.pkg.name + '/node_modules/5htp-core/src/';
|
|
182
202
|
const corePrefixIndex = miniLog.filePath.indexOf(corePrefix);
|
|
183
203
|
|
|
184
204
|
if (appPrefixIndex !== -1)
|
|
@@ -207,8 +227,8 @@ export class Console {
|
|
|
207
227
|
- READ
|
|
208
228
|
----------------------------------*/
|
|
209
229
|
|
|
210
|
-
public getClients() {
|
|
211
|
-
return
|
|
230
|
+
/*public getClients() {
|
|
231
|
+
return sql`
|
|
212
232
|
SELECT * FROM logs.Clients
|
|
213
233
|
ORDER BY activity DESC
|
|
214
234
|
LIMIT 100
|
|
@@ -219,7 +239,7 @@ export class Console {
|
|
|
219
239
|
return (
|
|
220
240
|
this.clients.find(c => c.id === clientId)
|
|
221
241
|
||
|
|
222
|
-
await
|
|
242
|
+
await sql`
|
|
223
243
|
SELECT * FROM logs.Clients
|
|
224
244
|
WHERE id = ${clientId}
|
|
225
245
|
`.first()
|
|
@@ -227,7 +247,7 @@ export class Console {
|
|
|
227
247
|
}
|
|
228
248
|
|
|
229
249
|
public getRequests(clientId?: string) {
|
|
230
|
-
return
|
|
250
|
+
return sql`
|
|
231
251
|
SELECT * FROM logs.Requests
|
|
232
252
|
ORDER BY date DESC
|
|
233
253
|
LIMIT 100
|
|
@@ -238,7 +258,7 @@ export class Console {
|
|
|
238
258
|
return (
|
|
239
259
|
this.requests.find(r => r.id === requestId)
|
|
240
260
|
||
|
|
241
|
-
await
|
|
261
|
+
await sql`
|
|
242
262
|
SELECT * FROM logs.Requests
|
|
243
263
|
WHERE id = ${requestId}
|
|
244
264
|
`.first()
|
|
@@ -251,13 +271,13 @@ export class Console {
|
|
|
251
271
|
if (channelId !== undefined)
|
|
252
272
|
filters.channelId = channelId;
|
|
253
273
|
|
|
254
|
-
return
|
|
274
|
+
return sql`
|
|
255
275
|
SELECT * FROM logs.Queries
|
|
256
276
|
WHERE :${filters}
|
|
257
277
|
ORDER BY date DESC
|
|
258
278
|
LIMIT 100
|
|
259
279
|
`.all();
|
|
260
|
-
}
|
|
280
|
+
}*/
|
|
261
281
|
|
|
262
282
|
public async getLogs( channelType: ChannelInfos["channelType"], channelId?: string ) {
|
|
263
283
|
|
|
@@ -274,7 +294,7 @@ export class Console {
|
|
|
274
294
|
|
|
275
295
|
public printHtml(logs: TLog[], full: boolean = false): string {
|
|
276
296
|
|
|
277
|
-
let html = logs.map(
|
|
297
|
+
let html = logs.map( logEntry => logToHTML( logEntry, this )).join('\n');
|
|
278
298
|
|
|
279
299
|
if (full) {
|
|
280
300
|
const consoleCss = `background: #000; padding: 20px; font-family: 'Fira Mono', 'monospace', 'Monaco'; font-size: 12px; line-height: 20px;`
|
|
@@ -289,16 +309,4 @@ export class Console {
|
|
|
289
309
|
{ language: 'sql', ignoreIllegals: true }
|
|
290
310
|
)
|
|
291
311
|
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/*----------------------------------
|
|
295
|
-
- REGISTER SERVICE
|
|
296
|
-
----------------------------------*/
|
|
297
|
-
app.register('console', Console);
|
|
298
|
-
declare global {
|
|
299
|
-
namespace Core {
|
|
300
|
-
interface Services {
|
|
301
|
-
console: Console;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
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
|
+
}
|