@bgord/bun 0.1.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.
Files changed (141) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/api-key-shield.d.ts +16 -0
  4. package/dist/api-version.d.ts +8 -0
  5. package/dist/auth-shield.d.ts +32 -0
  6. package/dist/basic-auth-shield.d.ts +14 -0
  7. package/dist/bgord-bun.cjs +2 -0
  8. package/dist/bgord-bun.cjs.map +1 -0
  9. package/dist/bgord-bun.modern.js +2 -0
  10. package/dist/bgord-bun.modern.js.map +1 -0
  11. package/dist/bgord-bun.module.js +2 -0
  12. package/dist/bgord-bun.module.js.map +1 -0
  13. package/dist/bgord-bun.umd.js +2 -0
  14. package/dist/bgord-bun.umd.js.map +1 -0
  15. package/dist/build-info-repository.d.ts +8 -0
  16. package/dist/bun/api-key-shield.d.ts +16 -0
  17. package/dist/bun/api-version.d.ts +8 -0
  18. package/dist/bun/context.d.ts +12 -0
  19. package/dist/bun/etag-extractor.d.ts +17 -0
  20. package/dist/bun/graceful-shutdown.d.ts +6 -0
  21. package/dist/bun/healthcheck.d.ts +22 -0
  22. package/dist/bun/http-logger.d.ts +9 -0
  23. package/dist/bun/index.d.ts +9 -0
  24. package/dist/bun/rate-limit-shield.d.ts +11 -0
  25. package/dist/bun/time-zone-offset.d.ts +16 -0
  26. package/dist/cache-response.d.ts +15 -0
  27. package/dist/cache-static-files.d.ts +9 -0
  28. package/dist/cache.d.ts +1 -0
  29. package/dist/clock.d.ts +49 -0
  30. package/dist/context.d.ts +12 -0
  31. package/dist/credentials.d.ts +28 -0
  32. package/dist/dates.d.ts +37 -0
  33. package/dist/decorators.d.ts +8 -0
  34. package/dist/deep-merge.d.ts +7 -0
  35. package/dist/dll.d.ts +29 -0
  36. package/dist/download-file.d.ts +10 -0
  37. package/dist/email-censor.d.ts +4 -0
  38. package/dist/encryption.d.ts +20 -0
  39. package/dist/environment-validator.d.ts +23 -0
  40. package/dist/errors.d.ts +49 -0
  41. package/dist/etag-extractor.d.ts +17 -0
  42. package/dist/etag.d.ts +19 -0
  43. package/dist/event.d.ts +59 -0
  44. package/dist/express-essentials.d.ts +35 -0
  45. package/dist/feature-flag.d.ts +5 -0
  46. package/dist/file-location.d.ts +31 -0
  47. package/dist/file-uploader.d.ts +12 -0
  48. package/dist/file.d.ts +4 -0
  49. package/dist/filter.d.ts +17 -0
  50. package/dist/graceful-shutdown.d.ts +6 -0
  51. package/dist/gzip.d.ts +12 -0
  52. package/dist/handlebars.d.ts +10 -0
  53. package/dist/hcaptcha-shield.d.ts +24 -0
  54. package/dist/healthcheck.d.ts +20 -0
  55. package/dist/http-logger.d.ts +10 -0
  56. package/dist/i18n.d.ts +31 -0
  57. package/dist/image-compressor.d.ts +10 -0
  58. package/dist/image-converter.d.ts +11 -0
  59. package/dist/image-exif.d.ts +18 -0
  60. package/dist/image-resizer.d.ts +16 -0
  61. package/dist/index.d.ts +9 -0
  62. package/dist/jobs.d.ts +32 -0
  63. package/dist/leap-year-checker.d.ts +4 -0
  64. package/dist/logger.d.ts +53 -0
  65. package/dist/mailer.d.ts +16 -0
  66. package/dist/mean.d.ts +4 -0
  67. package/dist/memory-consumption.d.ts +4 -0
  68. package/dist/method-override.d.ts +4 -0
  69. package/dist/mime-types.d.ts +2 -0
  70. package/dist/mime.d.ts +10 -0
  71. package/dist/min-max-scaler.d.ts +36 -0
  72. package/dist/money.d.ts +24 -0
  73. package/dist/noop.d.ts +2 -0
  74. package/dist/open-graph.d.ts +91 -0
  75. package/dist/outlier-detector.d.ts +6 -0
  76. package/dist/package-version.d.ts +20 -0
  77. package/dist/pagination.d.ts +58 -0
  78. package/dist/percentage.d.ts +4 -0
  79. package/dist/policy.d.ts +11 -0
  80. package/dist/polyfills.d.ts +0 -0
  81. package/dist/population-standard-deviation.d.ts +4 -0
  82. package/dist/prerequisites/binary.d.ts +16 -0
  83. package/dist/prerequisites/bun.d.ts +13 -0
  84. package/dist/prerequisites/jobs.d.ts +13 -0
  85. package/dist/prerequisites/mailer.d.ts +13 -0
  86. package/dist/prerequisites/memory.d.ts +13 -0
  87. package/dist/prerequisites/node.d.ts +13 -0
  88. package/dist/prerequisites/outside-connectivity.d.ts +11 -0
  89. package/dist/prerequisites/path.d.ts +16 -0
  90. package/dist/prerequisites/port.d.ts +13 -0
  91. package/dist/prerequisites/ram.d.ts +13 -0
  92. package/dist/prerequisites/self.d.ts +11 -0
  93. package/dist/prerequisites/space.d.ts +13 -0
  94. package/dist/prerequisites/ssl-certificate-expiry.d.ts +13 -0
  95. package/dist/prerequisites/timezone-utc.d.ts +13 -0
  96. package/dist/prerequisites/translations.d.ts +14 -0
  97. package/dist/prerequisites.d.ts +44 -0
  98. package/dist/random.d.ts +8 -0
  99. package/dist/rate-limit-shield.d.ts +11 -0
  100. package/dist/rate-limiter.d.ts +18 -0
  101. package/dist/recaptcha-shield.d.ts +12 -0
  102. package/dist/redirector.d.ts +4 -0
  103. package/dist/reordering.d.ts +49 -0
  104. package/dist/request-id.d.ts +13 -0
  105. package/dist/response-body-in-locals.d.ts +4 -0
  106. package/dist/revision.d.ts +12 -0
  107. package/dist/rounding.d.ts +17 -0
  108. package/dist/schema.d.ts +189 -0
  109. package/dist/server-timing.d.ts +7 -0
  110. package/dist/simple-linear-regression.d.ts +18 -0
  111. package/dist/simulated-error.d.ts +4 -0
  112. package/dist/sitemap.d.ts +37 -0
  113. package/dist/size.d.ts +31 -0
  114. package/dist/sleep.d.ts +3 -0
  115. package/dist/slower.d.ts +8 -0
  116. package/dist/static-files.d.ts +14 -0
  117. package/dist/stepper.d.ts +23 -0
  118. package/dist/stopwatch.d.ts +14 -0
  119. package/dist/streak-calculator.d.ts +14 -0
  120. package/dist/sum.d.ts +3 -0
  121. package/dist/thousands-separator.d.ts +4 -0
  122. package/dist/time-zone-offset.d.ts +17 -0
  123. package/dist/time.d.ts +21 -0
  124. package/dist/timeout.d.ts +9 -0
  125. package/dist/ts-utils.d.ts +3 -0
  126. package/dist/uploaded-file-location.d.ts +10 -0
  127. package/dist/uptime.d.ts +9 -0
  128. package/dist/uuid.d.ts +3 -0
  129. package/dist/visually-unambiguous-characters-generator.d.ts +4 -0
  130. package/dist/z-score.d.ts +8 -0
  131. package/package.json +48 -0
  132. package/src/api-key-shield.ts +23 -0
  133. package/src/api-version.ts +19 -0
  134. package/src/context.ts +20 -0
  135. package/src/etag-extractor.ts +41 -0
  136. package/src/graceful-shutdown.ts +44 -0
  137. package/src/healthcheck.ts +58 -0
  138. package/src/http-logger.ts +123 -0
  139. package/src/index.ts +9 -0
  140. package/src/rate-limit-shield.ts +24 -0
  141. package/src/time-zone-offset.ts +44 -0
@@ -0,0 +1,49 @@
1
+ export type HourFormatter = (value: Hour["value"]) => string;
2
+ export declare const HourFormatters: Record<string, HourFormatter>;
3
+ export declare class Hour {
4
+ private readonly value;
5
+ private readonly formatter;
6
+ static readonly ZERO: Hour;
7
+ static readonly MAX: Hour;
8
+ constructor(candidate: number, formatter?: HourFormatter);
9
+ get(formatter?: HourFormatter): {
10
+ raw: number;
11
+ formatted: string;
12
+ };
13
+ equals(another: Hour): boolean;
14
+ isAfter(another: Hour): boolean;
15
+ isBefore(another: Hour): boolean;
16
+ static list(formatter?: HourFormatter): Hour[];
17
+ }
18
+ export declare class Minute {
19
+ private readonly value;
20
+ static readonly ZERO: Minute;
21
+ static readonly MAX: Minute;
22
+ constructor(candidate: number);
23
+ get(): {
24
+ raw: number;
25
+ formatted: string;
26
+ };
27
+ equals(another: Minute): boolean;
28
+ isAfter(another: Minute): boolean;
29
+ isBefore(another: Minute): boolean;
30
+ static list(): Minute[];
31
+ }
32
+ export type ClockFormatter = (hour: Hour, minute: Minute) => string;
33
+ export declare const ClockFormatters: Record<string, ClockFormatter>;
34
+ export declare class Clock {
35
+ private readonly hour;
36
+ private readonly minute;
37
+ private readonly formatter;
38
+ constructor(hour: Hour, minute: Minute, formatter?: ClockFormatter);
39
+ get(formatter?: ClockFormatter): {
40
+ raw: {
41
+ hour: number;
42
+ minute: number;
43
+ };
44
+ formatted: string;
45
+ };
46
+ equals(another: Clock): boolean;
47
+ isAfter(another: Clock): boolean;
48
+ isBefore(another: Clock): boolean;
49
+ }
@@ -0,0 +1,12 @@
1
+ import * as bg from "@bgord/node";
2
+ import { TimeZoneOffsetVariables } from "./time-zone-offset";
3
+ export declare type ContextVariables = {
4
+ context: bg.ContextType;
5
+ requestId: string;
6
+ } & TimeZoneOffsetVariables;
7
+ export declare class Context {
8
+ static attach: import("hono/types").MiddlewareHandler<{
9
+ Bindings: any;
10
+ Variables: any;
11
+ }, string, {}>;
12
+ }
@@ -0,0 +1,28 @@
1
+ import z from "zod";
2
+ export type IdType = string;
3
+ export type PasswordType = string;
4
+ type UsernameType = string;
5
+ type HashedPasswordType = string;
6
+ export declare class Username {
7
+ private readonly schema;
8
+ private readonly value;
9
+ constructor(value: UsernameType, schema?: z.ZodSchema);
10
+ read(): UsernameType;
11
+ }
12
+ export declare class Password {
13
+ private schema;
14
+ private value;
15
+ constructor(value: PasswordType, schema?: z.ZodSchema);
16
+ hash(): Promise<HashedPassword>;
17
+ read(): PasswordType;
18
+ }
19
+ export declare class HashedPassword {
20
+ private value;
21
+ private constructor();
22
+ static fromPassword(password: Password): Promise<HashedPassword>;
23
+ static fromHash(value: HashedPasswordType): Promise<HashedPassword>;
24
+ read(): HashedPasswordType;
25
+ matches(password: Password): Promise<boolean>;
26
+ matchesOrThrow(password: Password): Promise<true>;
27
+ }
28
+ export {};
@@ -0,0 +1,37 @@
1
+ import { format } from "date-fns";
2
+ import * as Schema from "./schema";
3
+ import { Falsy } from "./ts-utils";
4
+ export type FormattedDateType = string;
5
+ export type DateFormattersInputType = Parameters<typeof format>[0];
6
+ export declare class DateFormatters {
7
+ static datetime(date: DateFormattersInputType): FormattedDateType;
8
+ static date(date: DateFormattersInputType): FormattedDateType;
9
+ static monthDay(date: DateFormattersInputType): FormattedDateType;
10
+ static relative(date: DateFormattersInputType): string;
11
+ }
12
+ export type RelativeDateType = {
13
+ raw: Schema.TimestampType;
14
+ relative: string;
15
+ };
16
+ export declare class RelativeDate {
17
+ static truthy(timestampMs: Schema.TimestampType): RelativeDateType;
18
+ static falsy(timestampMs: Falsy<Schema.TimestampType>): RelativeDateType | null;
19
+ private static _format;
20
+ }
21
+ export declare enum DayOfTheWeekEnum {
22
+ Monday = 1,
23
+ Tuesday = 2,
24
+ Wednesday = 3,
25
+ Thursday = 4,
26
+ Friday = 5,
27
+ Saturday = 6,
28
+ Sunday = 0
29
+ }
30
+ type GetStartOfDayTsInTzConfigType = {
31
+ now: Schema.TimestampType;
32
+ timeZoneOffsetMs: Schema.TimeZoneOffsetValueType;
33
+ };
34
+ export declare class DateCalculator {
35
+ static getStartOfDayTsInTz(config: GetStartOfDayTsInTzConfigType): number;
36
+ }
37
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Logger } from "./logger";
2
+ export declare class Decorators {
3
+ private readonly logger;
4
+ private readonly rounding;
5
+ constructor(logger: Logger);
6
+ duration(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
7
+ inspector(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
8
+ }
@@ -0,0 +1,7 @@
1
+ type NonArrayObject = {
2
+ [key: string]: any;
3
+ } & {
4
+ length?: never;
5
+ };
6
+ export declare function deepMerge(a: NonArrayObject | undefined, b: NonArrayObject | undefined): Object;
7
+ export {};
package/dist/dll.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ export declare class Node<T> {
2
+ data: T;
3
+ prev: Node<T> | null;
4
+ next: Node<T> | null;
5
+ constructor(data: Node<T>["data"]);
6
+ forward(n: number): Node<T> | null;
7
+ backward(n: number): Node<T> | null;
8
+ }
9
+ export declare class DoublyLinkedList<T> {
10
+ static EMPTY_SIZE: number;
11
+ private size;
12
+ private head;
13
+ private tail;
14
+ getSize(): DoublyLinkedList<T>["size"];
15
+ isEmpty(): boolean;
16
+ getHead(): DoublyLinkedList<T>["head"];
17
+ getTail(): DoublyLinkedList<T>["tail"];
18
+ append(node: Node<T>): void;
19
+ prepend(node: Node<T>): void;
20
+ clear(): void;
21
+ remove(node: Node<T>): void;
22
+ insertAfter(node: Node<T>, target: Node<T>): void;
23
+ insertBefore(node: Node<T>, target: Node<T>): void;
24
+ find(callback: (node: Node<T>) => boolean): Node<T> | null;
25
+ reverse(): void;
26
+ toArray(): Node<T>[];
27
+ static fromArray<T>(array: T[]): DoublyLinkedList<T>;
28
+ [Symbol.iterator](): IterableIterator<Node<T>>;
29
+ }
@@ -0,0 +1,10 @@
1
+ import express from "express";
2
+ import fs from "node:fs";
3
+ import { Mime } from "./mime";
4
+ export type DownloadFileConfigType = {
5
+ filename: fs.PathLike;
6
+ mime: Mime;
7
+ };
8
+ export declare class DownloadFile {
9
+ static attach(response: express.Response, config: DownloadFileConfigType): void;
10
+ }
@@ -0,0 +1,4 @@
1
+ import * as Schema from "./schema";
2
+ export declare class EmailCensor {
3
+ static censor(email: Schema.EmailType): Schema.EmailType;
4
+ }
@@ -0,0 +1,20 @@
1
+ import * as crypto from "node:crypto";
2
+ import * as fs from "node:fs";
3
+ import * as Schema from "./schema";
4
+ export type EncryptionConfig = {
5
+ secret: Schema.EncryptionSecretType;
6
+ iv: Schema.EncryptionIVType;
7
+ };
8
+ export type EncryptionOperationConfig = {
9
+ input: fs.PathLike;
10
+ output: fs.PathLike;
11
+ };
12
+ export declare class Encryption {
13
+ private readonly config;
14
+ private readonly algorithm;
15
+ constructor(config: EncryptionConfig);
16
+ createEncrypt(): Promise<crypto.Cipher>;
17
+ createDecrypt(): Promise<crypto.Decipher>;
18
+ encrypt(config: EncryptionOperationConfig): Promise<void>;
19
+ decrypt(config: EncryptionOperationConfig): Promise<void>;
20
+ }
@@ -0,0 +1,23 @@
1
+ import * as z from "zod";
2
+ import { NodeEnvironment } from "./schema";
3
+ type NodeEnvironmentEnumType = z.infer<typeof NodeEnvironment>;
4
+ type AnyZodSchema = z.ZodSchema<any, any>;
5
+ type QuietType = boolean;
6
+ type QuitType = boolean;
7
+ type EnvironmentValidatorConfig = {
8
+ type: unknown;
9
+ schema: AnyZodSchema;
10
+ quiet?: QuietType;
11
+ quit?: QuitType;
12
+ };
13
+ export declare class EnvironmentValidator<SchemaType> {
14
+ type: NodeEnvironmentEnumType;
15
+ schema: z.Schema<SchemaType>;
16
+ quiet: QuietType;
17
+ quit: QuitType;
18
+ constructor(config: EnvironmentValidatorConfig);
19
+ load(): SchemaType & {
20
+ type: NodeEnvironmentEnumType;
21
+ };
22
+ }
23
+ export {};
@@ -0,0 +1,49 @@
1
+ import { MimeRawType } from "./mime";
2
+ import { TimestampType } from "./schema";
3
+ export declare enum AccessDeniedErrorReasonType {
4
+ hcaptcha = "hcaptcha",
5
+ /** @public */
6
+ csrf = "csrf",
7
+ "api-key" = "api-key",
8
+ recaptcha = "recaptcha",
9
+ auth = "auth",
10
+ /** @public */
11
+ "basic-auth" = "basic-auth"
12
+ }
13
+ export type AccessDeniedErrorConfigType = {
14
+ reason: AccessDeniedErrorReasonType;
15
+ };
16
+ export declare class AccessDeniedError extends Error {
17
+ reason: AccessDeniedErrorConfigType["reason"];
18
+ constructor(config: AccessDeniedErrorConfigType);
19
+ }
20
+ export declare class InvalidCredentialsError extends Error {
21
+ constructor();
22
+ }
23
+ export declare class FileNotFoundError extends Error {
24
+ constructor();
25
+ }
26
+ export declare class InvalidMimeError extends Error {
27
+ constructor();
28
+ }
29
+ export declare class NotAcceptedMimeError extends Error {
30
+ mime: MimeRawType;
31
+ constructor(mime: MimeRawType);
32
+ }
33
+ export declare class TooManyRequestsError extends Error {
34
+ remainingMs: number;
35
+ constructor(remainingMs: number);
36
+ }
37
+ export type RequestTimerErrorConfigType = {
38
+ ms: TimestampType;
39
+ };
40
+ export declare class RequestTimeoutError extends Error {
41
+ ms: RequestTimerErrorConfigType["ms"];
42
+ constructor(config: RequestTimerErrorConfigType);
43
+ }
44
+ export declare class InvalidRevisionError extends Error {
45
+ constructor();
46
+ }
47
+ export declare class RevisionMismatchError extends Error {
48
+ constructor();
49
+ }
@@ -0,0 +1,17 @@
1
+ import * as bg from "@bgord/node";
2
+ export declare type EtagVariables = {
3
+ ETag: bg.ETag | null;
4
+ WeakETag: bg.WeakETag | null;
5
+ };
6
+ export declare class ETagExtractor {
7
+ static attach: import("hono/types").MiddlewareHandler<{
8
+ Bindings: any;
9
+ Variables: EtagVariables;
10
+ }, string, {}>;
11
+ }
12
+ export declare class WeakETagExtractor {
13
+ static attach: import("hono/types").MiddlewareHandler<{
14
+ Bindings: any;
15
+ Variables: EtagVariables;
16
+ }, string, {}>;
17
+ }
package/dist/etag.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { RevisionType } from "./schema";
2
+ export type ETagValueType = string;
3
+ export declare class ETag {
4
+ readonly revision: RevisionType;
5
+ static HEADER_NAME: string;
6
+ static IF_MATCH_HEADER_NAME: string;
7
+ readonly value: ETagValueType;
8
+ private constructor();
9
+ static fromHeader(value?: ETagValueType): ETag | null;
10
+ }
11
+ export type WeakETagValueType = string;
12
+ export declare class WeakETag {
13
+ readonly revision: RevisionType;
14
+ static HEADER_NAME: string;
15
+ static IF_MATCH_HEADER_NAME: string;
16
+ readonly value: WeakETagValueType;
17
+ private constructor();
18
+ static fromHeader(value?: WeakETagValueType): WeakETag | null;
19
+ }
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { Logger } from "./logger";
3
+ export declare const Event: z.ZodObject<{
4
+ id: z.ZodDefault<z.ZodString>;
5
+ createdAt: z.ZodDate;
6
+ stream: z.ZodString;
7
+ name: z.ZodString;
8
+ version: z.ZodNumber;
9
+ payload: z.ZodEffects<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodAny>, Record<string, any>, Record<string, any>>, string, Record<string, any>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ id: string;
12
+ createdAt: Date;
13
+ stream: string;
14
+ name: string;
15
+ version: number;
16
+ payload: string;
17
+ }, {
18
+ createdAt: Date;
19
+ stream: string;
20
+ name: string;
21
+ version: number;
22
+ payload: Record<string, any>;
23
+ id?: string | undefined;
24
+ }>;
25
+ export declare const ParsedEvent: z.ZodObject<{
26
+ id: z.ZodDefault<z.ZodString>;
27
+ createdAt: z.ZodDate;
28
+ stream: z.ZodString;
29
+ name: z.ZodString;
30
+ version: z.ZodNumber;
31
+ payload: z.ZodRecord<z.ZodString, z.ZodAny>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ id: string;
34
+ createdAt: Date;
35
+ stream: string;
36
+ name: string;
37
+ version: number;
38
+ payload: Record<string, any>;
39
+ }, {
40
+ createdAt: Date;
41
+ stream: string;
42
+ name: string;
43
+ version: number;
44
+ payload: Record<string, any>;
45
+ id?: string | undefined;
46
+ }>;
47
+ export type EventType = z.infer<typeof Event>;
48
+ export type ParsedEventType = z.infer<typeof ParsedEvent>;
49
+ export declare class EventHandler {
50
+ private readonly logger;
51
+ constructor(logger: Logger);
52
+ handle<T extends Pick<EventType, "name">>(fn: (event: T) => Promise<void>): (event: T) => Promise<void>;
53
+ }
54
+ export declare class EventLogger {
55
+ private readonly logger;
56
+ constructor(logger: Logger);
57
+ private _handle;
58
+ handle: (type: string, _debugName: string, eventName: string | undefined, eventData: Record<string, any> | undefined) => void;
59
+ }
@@ -0,0 +1,35 @@
1
+ import "./polyfills";
2
+ import express from "express";
3
+ import bodyparser from "body-parser";
4
+ import helmet from "helmet";
5
+ import cors from "cors";
6
+ import { StaticFilesConfigType } from "./static-files";
7
+ import { Stopwatch } from "./stopwatch";
8
+ export type ExpressEssentialsConfig = Partial<{
9
+ helmet: Parameters<typeof helmet>[0];
10
+ json: bodyparser.OptionsJson;
11
+ urlencoded: bodyparser.OptionsUrlencoded;
12
+ cors: cors.CorsOptions;
13
+ staticFiles: StaticFilesConfigType;
14
+ }>;
15
+ declare global {
16
+ namespace Express {
17
+ interface Locals {
18
+ startup: Stopwatch;
19
+ }
20
+ }
21
+ }
22
+ export declare const DEFAULT_HELMET_CONFIG: {
23
+ contentSecurityPolicy: {
24
+ useDefaults: boolean;
25
+ directives: {
26
+ "script-src": string[];
27
+ "script-src-attr": null;
28
+ "style-src": string[];
29
+ "frame-src": string[];
30
+ "connect-src": string[];
31
+ "img-src": string[];
32
+ };
33
+ };
34
+ };
35
+ export declare function addExpressEssentials(app: express.Express, config?: ExpressEssentialsConfig): void;
@@ -0,0 +1,5 @@
1
+ import * as Schema from "./schema";
2
+ export declare class FeatureFlag {
3
+ static isEnabled(flag: Schema.FeatureFlagType): boolean;
4
+ static isDisabled(flag: Schema.FeatureFlagType): boolean;
5
+ }
@@ -0,0 +1,31 @@
1
+ import * as Schema from "./schema";
2
+ type FileLocationBasenameType = string;
3
+ type FileLocationExtensionType = string;
4
+ type FileLocationParentType = string;
5
+ export type FileLocationConfigType = {
6
+ parent: FileLocationParentType;
7
+ basename: FileLocationBasenameType;
8
+ extension: FileLocationExtensionType;
9
+ };
10
+ export declare class FileLocation {
11
+ readonly parent: Schema.PathType;
12
+ private basename;
13
+ private extension;
14
+ constructor(config: FileLocationConfigType);
15
+ getBasename(): FileLocationBasenameType;
16
+ getExtension(): FileLocationExtensionType;
17
+ getFilename(extension?: FileLocationExtensionType): Schema.PathType;
18
+ getPath(extension?: FileLocationExtensionType): Schema.PathType;
19
+ getGzippedPath(): Schema.PathType;
20
+ summary(): {
21
+ parent: string & import("zod").BRAND<"path">;
22
+ basename: string;
23
+ extension: string;
24
+ filename: string & import("zod").BRAND<"path">;
25
+ path: string & import("zod").BRAND<"path">;
26
+ gzipped: string & import("zod").BRAND<"path">;
27
+ };
28
+ setBasename(basename: FileLocationBasenameType): FileLocation;
29
+ delete(): Promise<void>;
30
+ }
31
+ export {};
@@ -0,0 +1,12 @@
1
+ import express from "express";
2
+ import files from "express-form-data";
3
+ type FileUploaderConfigType = files.FormDataOptions & {
4
+ mimeTypes: string[];
5
+ };
6
+ export declare class FileUploader {
7
+ static defaultConfig: FileUploaderConfigType;
8
+ static applyTo(app: express.Application, _config: FileUploaderConfigType): void;
9
+ static handle(_config?: FileUploaderConfigType): ((request: express.Request, _response: express.Response, next: express.NextFunction) => void)[];
10
+ private static validate;
11
+ }
12
+ export {};
package/dist/file.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import * as Schema from "./schema";
2
+ export declare class File {
3
+ static getSizeInBytes(path: Schema.PathType): Promise<Schema.SizeInBytesType>;
4
+ }
@@ -0,0 +1,17 @@
1
+ import * as z from "zod";
2
+ export type DefaultFilterSchemaType = z.ZodRawShape;
3
+ export type FilterValuesType = Record<string, unknown>;
4
+ export type FilterSchemaType<T extends DefaultFilterSchemaType> = z.ZodObject<T>;
5
+ export type FilterParseConfigType<T extends DefaultFilterSchemaType> = {
6
+ schema: FilterSchemaType<T>;
7
+ values: FilterValuesType;
8
+ };
9
+ export declare class Filter<T extends DefaultFilterSchemaType> {
10
+ private readonly schema;
11
+ constructor(schema: FilterSchemaType<T>);
12
+ parse(values: FilterValuesType): (z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]>[k]; } : never) | undefined;
13
+ default(): (z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]>[k]; } : never) | undefined;
14
+ static parse<T extends DefaultFilterSchemaType>(config: FilterParseConfigType<T>): (z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]>[k]; } : never) | undefined;
15
+ static default<T extends DefaultFilterSchemaType>(config: Omit<FilterParseConfigType<T>, "values">): (z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, { [k_1 in keyof z.baseObjectOutputType<T>]: undefined extends z.baseObjectOutputType<T>[k_1] ? never : k_1; }[keyof T]>[k]; } : never) | undefined;
16
+ private static _parse;
17
+ }
@@ -0,0 +1,6 @@
1
+ declare type ServerType = ReturnType<typeof Bun.serve>;
2
+ export declare class GracefulShutdown {
3
+ private static shutdown;
4
+ static applyTo(server: ServerType, callback?: () => any): void;
5
+ }
6
+ export {};
package/dist/gzip.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { PathLike } from "node:fs";
2
+ type GzipCompressConfigType = {
3
+ input: PathLike;
4
+ output: PathLike;
5
+ };
6
+ export declare class Gzip {
7
+ static createCompress(): import("zlib").Gzip;
8
+ static createDecompress(): import("zlib").Gunzip;
9
+ static compress(config: GzipCompressConfigType): Promise<void>;
10
+ static uncompress(config: GzipCompressConfigType): Promise<void>;
11
+ }
12
+ export {};
@@ -0,0 +1,10 @@
1
+ import express from "express";
2
+ import handlebars from "express-handlebars";
3
+ import * as Schema from "./schema";
4
+ export type HandlebarsConfigType = handlebars.ExpressHandlebars["config"] & {
5
+ path: Schema.PathType;
6
+ };
7
+ export declare class Handlebars {
8
+ static handlebarsDefaultConfig: HandlebarsConfigType;
9
+ static applyTo(app: express.Application, _config?: HandlebarsConfigType): void;
10
+ }
@@ -0,0 +1,24 @@
1
+ import express from "express";
2
+ import { z } from "zod";
3
+ import { HCaptchaSecretKey } from "./schema";
4
+ type HCaptchaSecretKeyType = z.infer<typeof HCaptchaSecretKey>;
5
+ type HCaptchaVerifierModeType = "local" | "production";
6
+ export type HCaptchaVerifierConfigType = {
7
+ secretKey: HCaptchaSecretKeyType;
8
+ mode: HCaptchaVerifierModeType;
9
+ };
10
+ export declare class HCaptchaShield {
11
+ private readonly secretKey;
12
+ private readonly mode;
13
+ private readonly LOCAL_HCAPTCHA_RESPONSE_PLACEHOLDER;
14
+ constructor(config: HCaptchaVerifierConfigType);
15
+ private _verify;
16
+ verify: (request: express.Request, _response: express.Response, next: express.NextFunction) => Promise<void>;
17
+ static helmetCspConfig: {
18
+ "script-src": string[];
19
+ "frame-src": string[];
20
+ "style-src": string[];
21
+ "connect-src": string[];
22
+ };
23
+ }
24
+ export {};
@@ -0,0 +1,20 @@
1
+ import * as bg from "@bgord/node";
2
+ export declare class Healthcheck {
3
+ static build: (prerequisites: bg.AbstractPrerequisite<bg.BasePrerequisiteConfig>[]) => [import("hono/types").H<any, any, {}, Promise<Response & import("hono/types").TypedResponse<{
4
+ ok: bg.PrerequisiteStatusEnum;
5
+ version: string & import("zod").BRAND<"build-version">;
6
+ details: {
7
+ label: string;
8
+ status: bg.PrerequisiteStatusEnum;
9
+ }[];
10
+ uptime: {
11
+ seconds: number;
12
+ formatted: string;
13
+ };
14
+ memory: {
15
+ bytes: any;
16
+ formatted: string;
17
+ };
18
+ durationMs: number;
19
+ }, 200 | 424, "json">>>];
20
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="handlebars" />
2
+ import * as bg from "@bgord/node";
3
+ export declare class HttpLogger {
4
+ private static simplify;
5
+ private static uninformativeHeaders;
6
+ static build: (logger: bg.Logger) => import("hono/types").MiddlewareHandler<{
7
+ Bindings: any;
8
+ Variables: any;
9
+ }, string, {}>;
10
+ }
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import express from "express";
2
+ import * as Schema from "./schema";
3
+ export type TranslationsKeyType = string;
4
+ export type TranslationsValueType = string;
5
+ export type TranslationsType = Record<TranslationsKeyType, TranslationsValueType>;
6
+ export type TranslationPlaceholderType = string;
7
+ export type TranslationPlaceholderValueType = string | number;
8
+ export type TranslationVariableType = Record<TranslationPlaceholderType, TranslationPlaceholderValueType>;
9
+ export type I18nConfigType = {
10
+ translationsPath?: Schema.PathType;
11
+ defaultLanguage?: Schema.LanguageType;
12
+ supportedLanguages: Record<string, Schema.LanguageType>;
13
+ };
14
+ declare global {
15
+ namespace Express {
16
+ interface Request {
17
+ language: Schema.LanguageType;
18
+ supportedLanguages: Schema.LanguageType[];
19
+ translationsPath: Schema.PathType;
20
+ }
21
+ }
22
+ }
23
+ export declare class I18n {
24
+ static LANGUAGE_COOKIE_NAME: string;
25
+ static DEFAULT_TRANSLATIONS_PATH: string & import("zod").BRAND<"path">;
26
+ static FALLBACK_LANGUAGE: string;
27
+ static applyTo(app: express.Application, config: I18nConfigType): void;
28
+ static getTranslations(language: Schema.LanguageType, translationsPath: Schema.PathType): Promise<TranslationsType>;
29
+ static useTranslations(translations: TranslationsType): (key: TranslationsKeyType, variables?: TranslationVariableType) => string;
30
+ static getTranslationPathForLanguage(language: Schema.LanguageType, translationsPath?: string & import("zod").BRAND<"path">): Schema.PathType;
31
+ }
@@ -0,0 +1,10 @@
1
+ import sharp from "sharp";
2
+ import * as Schema from "./schema";
3
+ export type ImageCompressorConfigType = {
4
+ input: Schema.PathType;
5
+ output: Schema.PathType;
6
+ quality?: Schema.ImageCompressionQualityType;
7
+ };
8
+ export declare class ImageCompressor {
9
+ static compress(config: ImageCompressorConfigType): Promise<sharp.OutputInfo>;
10
+ }
@@ -0,0 +1,11 @@
1
+ import sharp from "sharp";
2
+ import * as Schema from "./schema";
3
+ export type ImageConverterType = keyof sharp.FormatEnum;
4
+ export type ImageConverterConfigType = {
5
+ format: ImageConverterType;
6
+ input: Schema.PathType;
7
+ output: Schema.PathType;
8
+ };
9
+ export declare class ImageConverter {
10
+ static convert(config: ImageConverterConfigType): Promise<sharp.OutputInfo>;
11
+ }