@bgord/bun 0.18.4 → 0.18.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/bun",
3
- "version": "0.18.4",
3
+ "version": "0.18.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": "Bartosz Gordon",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@axiomhq/winston": "1.3.1",
39
- "@bgord/tools": "0.12.4",
39
+ "@bgord/tools": "0.12.5",
40
40
  "@hono/ua-blocker": "0.1.6",
41
41
  "better-auth": "1.3.3",
42
42
  "check-disk-space": "3.4.0",
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
@@ -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
+ }
@@ -58,6 +58,7 @@ export class HttpLogger {
58
58
 
59
59
  const httpRequestBeforeMetadata = {
60
60
  params: c.req.param(),
61
+ // @ts-expect-error
61
62
  headers: _.omit(Object.fromEntries(c.req.raw.clone().headers), HttpLogger.uninformativeHeaders),
62
63
  body,
63
64
  query: c.req.queries(),
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";
@@ -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,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
- }