@bgord/bun 0.18.3 → 0.18.5
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/dist/correlation-id.vo.d.ts +1 -1
- package/dist/correlation-id.vo.d.ts.map +1 -1
- package/dist/file-draft.d.ts +17 -0
- package/dist/file-draft.d.ts.map +1 -0
- package/dist/file-draft.js +17 -0
- package/dist/file-draft.js.map +1 -0
- package/dist/http-logger.middleware.d.ts.map +1 -1
- package/dist/http-logger.middleware.js +1 -0
- package/dist/http-logger.middleware.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/jobs.service.d.ts +2 -0
- package/dist/jobs.service.d.ts.map +1 -1
- package/dist/jobs.service.js +7 -4
- package/dist/jobs.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/uuid.vo.d.ts +1 -1
- package/dist/uuid.vo.d.ts.map +1 -1
- package/dist/uuid.vo.js +1 -2
- package/dist/uuid.vo.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +1 -2
- package/src/file-draft.ts +23 -0
- package/src/http-logger.middleware.ts +1 -0
- package/src/index.ts +1 -2
- package/src/jobs.service.ts +7 -4
- package/src/uuid.vo.ts +1 -3
- package/dist/download-file.service.d.ts +0 -13
- package/dist/download-file.service.d.ts.map +0 -1
- package/dist/download-file.service.js +0 -11
- package/dist/download-file.service.js.map +0 -1
- package/dist/new-uuid.service.d.ts +0 -4
- package/dist/new-uuid.service.d.ts.map +0 -1
- package/dist/new-uuid.service.js +0 -6
- package/dist/new-uuid.service.js.map +0 -1
- package/src/download-file.service.ts +0 -15
- package/src/new-uuid.service.ts +0 -5
package/dist/uuid.vo.d.ts
CHANGED
package/dist/uuid.vo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.vo.d.ts","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"uuid.vo.d.ts","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,IAAI,WAAW,CAAC;AAE7B,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC"}
|
package/dist/uuid.vo.js
CHANGED
package/dist/uuid.vo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.vo.js","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,
|
|
1
|
+
{"version":3,"file":"uuid.vo.js","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -40,7 +40,6 @@ src/
|
|
|
40
40
|
├── correlation-storage.service.ts
|
|
41
41
|
├── decorators.service.ts
|
|
42
42
|
├── dispatching-event-store.ts
|
|
43
|
-
├── download-file.service.ts
|
|
44
43
|
├── encryption.service.ts
|
|
45
44
|
├── env-validator.service.ts
|
|
46
45
|
├── etag-extractor.middleware.ts
|
|
@@ -50,6 +49,7 @@ src/
|
|
|
50
49
|
├── event-store.ts
|
|
51
50
|
├── event-stream.vo.ts
|
|
52
51
|
├── event.types.ts
|
|
52
|
+
├── file-draft.ts
|
|
53
53
|
├── file-location.service.ts
|
|
54
54
|
├── file-uploader.middleware.ts
|
|
55
55
|
├── graceful-shutdown.service.ts
|
|
@@ -64,7 +64,6 @@ src/
|
|
|
64
64
|
├── logger.service.ts
|
|
65
65
|
├── mailer.service.ts
|
|
66
66
|
├── memory-consumption.service.ts
|
|
67
|
-
├── new-uuid.service.ts
|
|
68
67
|
├── node-env.vo.ts
|
|
69
68
|
├── open-graph.service.ts
|
|
70
69
|
├── path.vo.ts
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReadableStream } from "node:stream/web";
|
|
2
|
+
import type * as tools from "@bgord/tools";
|
|
3
|
+
|
|
4
|
+
export type DraftBody = BodyInit | NodeJS.ReadableStream | ReadableStream;
|
|
5
|
+
|
|
6
|
+
export abstract class FileDraft {
|
|
7
|
+
constructor(readonly config: { filename: string; mime: tools.Mime }) {}
|
|
8
|
+
|
|
9
|
+
getHeaders(): Headers {
|
|
10
|
+
return new Headers({
|
|
11
|
+
"Content-Type": this.config.mime.raw,
|
|
12
|
+
"Content-Disposition": `attachment; filename="${this.config.filename}"`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected abstract create(): DraftBody | Promise<DraftBody>;
|
|
17
|
+
|
|
18
|
+
async toResponse(): Promise<Response> {
|
|
19
|
+
const body = await this.create();
|
|
20
|
+
|
|
21
|
+
return new Response(body as BodyInit, { headers: this.getHeaders() });
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,6 @@ export * from "./correlation-id.vo";
|
|
|
15
15
|
export * from "./correlation-storage.service";
|
|
16
16
|
export * from "./decorators.service";
|
|
17
17
|
export * from "./dispatching-event-store";
|
|
18
|
-
export * from "./download-file.service";
|
|
19
18
|
export * from "./encryption.service";
|
|
20
19
|
export * from "./env-validator.service";
|
|
21
20
|
export * from "./etag-extractor.middleware";
|
|
@@ -24,6 +23,7 @@ export * from "./event-handler.service";
|
|
|
24
23
|
export * from "./event-logger.service";
|
|
25
24
|
export * from "./event-store";
|
|
26
25
|
export * from "./event-stream.vo";
|
|
26
|
+
export * from "./file-draft";
|
|
27
27
|
export * from "./file-location.service";
|
|
28
28
|
export * from "./file-uploader.middleware";
|
|
29
29
|
export * from "./graceful-shutdown.service";
|
|
@@ -38,7 +38,6 @@ export * from "./jobs.service";
|
|
|
38
38
|
export * from "./logger.service";
|
|
39
39
|
export * from "./mailer.service";
|
|
40
40
|
export * from "./memory-consumption.service";
|
|
41
|
-
export * from "./new-uuid.service";
|
|
42
41
|
export * from "./node-env.vo";
|
|
43
42
|
export * from "./open-graph.service";
|
|
44
43
|
export * from "./path.vo";
|
package/src/jobs.service.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Cron } from "croner";
|
|
|
4
4
|
import { CorrelationId } from "./correlation-id.vo";
|
|
5
5
|
import { CorrelationStorage } from "./correlation-storage.service";
|
|
6
6
|
import { Logger } from "./logger.service";
|
|
7
|
-
import { NewUUID } from "./new-uuid.service";
|
|
8
7
|
|
|
9
8
|
export type JobNameType = string;
|
|
10
9
|
|
|
@@ -21,7 +20,11 @@ export enum UTC_DAY_OF_THE_WEEK {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export class Jobs {
|
|
24
|
-
static SCHEDULES = {
|
|
23
|
+
static SCHEDULES = {
|
|
24
|
+
EVERY_MINUTE: "* * * * *",
|
|
25
|
+
EVERY_HOUR: "0 * * * *",
|
|
26
|
+
DAY_TIME: (day: UTC_DAY_OF_THE_WEEK, UTCHour: tools.Hour) => `0 ${UTCHour.get().raw} * * ${day}`,
|
|
27
|
+
};
|
|
25
28
|
|
|
26
29
|
static stopAll(jobs: MultipleJobsType) {
|
|
27
30
|
Object.values(jobs).forEach((job) => job.stop());
|
|
@@ -42,7 +45,7 @@ export class JobHandler {
|
|
|
42
45
|
constructor(private readonly logger: Logger) {}
|
|
43
46
|
|
|
44
47
|
handle(jobProcessor: JobProcessorType) {
|
|
45
|
-
const correlationId = CorrelationId.parse(
|
|
48
|
+
const correlationId = CorrelationId.parse(crypto.randomUUID());
|
|
46
49
|
|
|
47
50
|
// biome-ignore lint: lint/complexity/noUselessThisAlias
|
|
48
51
|
const that = this;
|
|
@@ -57,7 +60,7 @@ export class JobHandler {
|
|
|
57
60
|
correlationId,
|
|
58
61
|
});
|
|
59
62
|
|
|
60
|
-
await CorrelationStorage.run(
|
|
63
|
+
await CorrelationStorage.run(correlationId, jobProcessor.process);
|
|
61
64
|
|
|
62
65
|
that.logger.info({
|
|
63
66
|
message: `${jobProcessor.label} success`,
|
package/src/uuid.vo.ts
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PathLike } from "node:fs";
|
|
2
|
-
import * as tools from "@bgord/tools";
|
|
3
|
-
type DownloadFileConfigType = {
|
|
4
|
-
filename: PathLike;
|
|
5
|
-
mime: tools.Mime;
|
|
6
|
-
};
|
|
7
|
-
export declare class DownloadFile {
|
|
8
|
-
static attach(config: DownloadFileConfigType): {
|
|
9
|
-
headers: Headers;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=download-file.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-file.service.d.ts","sourceRoot":"","sources":["../src/download-file.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,KAAK,sBAAsB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAA;CAAE,CAAC;AAEvE,qBAAa,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB;;;CAQ7C"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export class DownloadFile {
|
|
2
|
-
static attach(config) {
|
|
3
|
-
return {
|
|
4
|
-
headers: new Headers({
|
|
5
|
-
"Content-Disposition": `attachment; filename="${config.filename}"`,
|
|
6
|
-
"Content-Type": config.mime.raw,
|
|
7
|
-
}),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=download-file.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-file.service.js","sourceRoot":"","sources":["../src/download-file.service.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,MAA8B;QAC1C,OAAO;YACL,OAAO,EAAE,IAAI,OAAO,CAAC;gBACnB,qBAAqB,EAAE,yBAAyB,MAAM,CAAC,QAAQ,GAAG;gBAClE,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;aAChC,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-uuid.service.d.ts","sourceRoot":"","sources":["../src/new-uuid.service.ts"],"names":[],"mappings":"AAAA,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ;CAGhB"}
|
package/dist/new-uuid.service.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-uuid.service.js","sourceRoot":"","sources":["../src/new-uuid.service.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IAClB,MAAM,CAAC,QAAQ;QACb,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PathLike } from "node:fs";
|
|
2
|
-
import * as tools from "@bgord/tools";
|
|
3
|
-
|
|
4
|
-
type DownloadFileConfigType = { filename: PathLike; mime: tools.Mime };
|
|
5
|
-
|
|
6
|
-
export class DownloadFile {
|
|
7
|
-
static attach(config: DownloadFileConfigType) {
|
|
8
|
-
return {
|
|
9
|
-
headers: new Headers({
|
|
10
|
-
"Content-Disposition": `attachment; filename="${config.filename}"`,
|
|
11
|
-
"Content-Type": config.mime.raw,
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
}
|