@bool-ts/core 1.9.12 → 1.9.17

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/README.md CHANGED
@@ -1 +1,157 @@
1
- # core
1
+ # BoolTS Core
2
+
3
+ BoolTS Core is a powerful TypeScript framework designed to provide essential building blocks for modern web applications. It offers a robust foundation with features like HTTP handling, data validation, and metadata reflection. This framework is built specifically for the Bun runtime environment.
4
+
5
+ ## Features
6
+
7
+ - **Bun Runtime**: Optimized for Bun's high-performance JavaScript runtime
8
+ - **HTTP Handling**: Built-in support for HTTP requests and responses
9
+ - **Data Validation**: Integration with Zod for type-safe data validation
10
+ - **Metadata Reflection**: Support for runtime type information and metadata
11
+ - **Decorators**: Rich set of decorators for extending functionality
12
+ - **DateTime Handling**: Comprehensive date and time utilities
13
+ - **Type Safety**: Full TypeScript support with strict type checking
14
+
15
+ ## Prerequisites
16
+
17
+ - [Bun](https://bun.sh/) (v1.0 or later)
18
+ - Node.js (for development purposes)
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ # Using bun
24
+ bun add @bool-ts/core
25
+ ```
26
+
27
+ ## Documentation
28
+
29
+ For detailed documentation, please visit [https://boolts.dev](https://boolts.dev)
30
+
31
+ ## Quick Start
32
+
33
+ Create a new project with the following structure:
34
+
35
+ ```typescript
36
+ // helloWorld.controller.ts
37
+ import { Controller, Get } from "@bool-ts/core";
38
+
39
+ @Controller()
40
+ export class HelloWorldController {
41
+ @Get()
42
+ sayHello() {
43
+ return "Hello, world!";
44
+ }
45
+ }
46
+ ```
47
+
48
+ ```typescript
49
+ // helloWorld.module.ts
50
+ import { Module } from "@bool-ts/core";
51
+ import { HelloWorldController } from "./helloWorld.controller";
52
+
53
+ @Module({
54
+ controllers: [HelloWorldController]
55
+ })
56
+ export class HelloWorldModule {}
57
+ ```
58
+
59
+ ```typescript
60
+ // index.ts
61
+ import { BoolFactory } from "@bool-ts/core";
62
+ import { HelloWorldModule } from "./helloWorld.module";
63
+
64
+ BoolFactory(HelloWorldModule, {
65
+ port: 3000
66
+ });
67
+ ```
68
+
69
+ Run your application:
70
+
71
+ ```bash
72
+ bun run index.ts
73
+ ```
74
+
75
+ Your server will start at http://localhost:3000 and the endpoint will be available at http://localhost:3000/
76
+
77
+ ## Core Components
78
+
79
+ ### HTTP Module
80
+
81
+ Handle HTTP requests and responses with built-in routing and middleware support, optimized for Bun's HTTP server.
82
+
83
+ ### Decorators
84
+
85
+ Extend your classes and methods with powerful decorators for:
86
+
87
+ - Route handling
88
+ - Parameter validation
89
+ - Dependency injection
90
+ - And more...
91
+
92
+ ### Validation
93
+
94
+ Leverage Zod for robust data validation:
95
+
96
+ ```typescript
97
+ import { z } from "zod";
98
+
99
+ const userSchema = z.object({
100
+ name: z.string(),
101
+ age: z.number().positive(),
102
+ email: z.string().email()
103
+ });
104
+ ```
105
+
106
+ ### DateTime Utilities
107
+
108
+ Comprehensive date and time handling through `@bool-ts/date-time`:
109
+
110
+ ```typescript
111
+ import { add as addTime, ETimeUnit } from "@bool-ts/date-time";
112
+
113
+ const targetDate = "2025-04-09";
114
+ const nextFiveDaysOfTargetDate = addTime(targetDate, 5, ETimeUnit.day);
115
+ ```
116
+
117
+ ## Project Structure
118
+
119
+ ```
120
+ src/
121
+ ├── decorators/ # Custom decorators
122
+ ├── entities/ # Core entities
123
+ ├── http/ # HTTP handling
124
+ ├── interfaces/ # Type definitions
125
+ ├── keys/ # Key constants
126
+ ├── producers/ # Object producers
127
+ └── ultils/ # Utility functions
128
+ ```
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ # Install dependencies
134
+ bun install
135
+
136
+ # Run tests
137
+ bun test
138
+
139
+ # Build the project
140
+ bun run build
141
+ ```
142
+
143
+ ## License
144
+
145
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
146
+
147
+ ## Contributing
148
+
149
+ Contributions are welcome! Please feel free to submit a Pull Request.
150
+
151
+ ## Author
152
+
153
+ MIT © [Trần Đức Tâm (Neo)](https://github.com/tamneo)
154
+
155
+ ## Support
156
+
157
+ For support, please open an issue in the [GitHub repository](https://github.com/BoolTS/core/issues).
package/package.json CHANGED
@@ -1,8 +1,20 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.9.12",
4
- "description": "",
5
- "main": "dist/index.js",
3
+ "version": "1.9.17",
4
+ "description": "Core package for BoolTS framework",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "./dist",
9
+ "./src"
10
+ ],
11
+ "keywords": [
12
+ "bool",
13
+ "typescript",
14
+ "ts",
15
+ "bun",
16
+ "framework"
17
+ ],
6
18
  "scripts": {
7
19
  "test": "bun --hot run __test/index.ts",
8
20
  "build": "tsc --emitDeclarationOnly && bun build --minify --sourcemap ./src/index.ts --outdir ./dist"
@@ -26,9 +38,9 @@
26
38
  "devDependencies": {
27
39
  "@types/bun": "latest",
28
40
  "@types/qs": "^6.9.18",
29
- "typescript": "^5.8.2"
41
+ "typescript": "^5.8.3"
30
42
  },
31
- "private": "false",
43
+ "private": false,
32
44
  "publishConfig": {
33
45
  "access": "public"
34
46
  }
package/.prettierrc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "semi": true,
3
- "tabWidth": 4,
4
- "printWidth": 100,
5
- "singleQuote": false,
6
- "singleAttributePerLine": false,
7
- "trailingComma": "none",
8
- "bracketSameLine": true,
9
- "bracketSpacing": true,
10
- "htmlWhitespaceSensitivity": "ignore"
11
- }
@@ -1 +0,0 @@
1
- export const mongodbKey = Symbol.for("mongo");
@@ -1,22 +0,0 @@
1
- import { Container } from "@dist";
2
- import { mongodbKey } from "_constants";
3
- import { FirstModule } from "firstModule";
4
- import { SecondModule } from "secondModule";
5
- import { TestRepository } from "./repository";
6
- import { TestService } from "./service";
7
-
8
- @Container<{
9
- mongodb: string;
10
- }>({
11
- config: {
12
- mongodb: "123"
13
- },
14
- loaders: {
15
- mongodb: ({ config }) => {
16
- return [mongodbKey, { hehe: "435345" }];
17
- }
18
- },
19
- modules: [FirstModule, SecondModule],
20
- dependencies: [TestService, TestRepository]
21
- })
22
- export class AppContainer {}
@@ -1,93 +0,0 @@
1
- import type { IService } from "./interfaces";
2
-
3
- import * as Zod from "zod";
4
-
5
- import {
6
- Controller,
7
- Delete,
8
- Get,
9
- Inject,
10
- Options,
11
- Param,
12
- Params,
13
- Patch,
14
- Post,
15
- Put,
16
- Query,
17
- RequestBody,
18
- RequestHeaders
19
- } from "@dist";
20
- import { TestService } from "./service";
21
-
22
- const postParamsSchema = Zod.object({
23
- id: Zod.string(),
24
- providerId: Zod.string().uuid()
25
- });
26
-
27
- const bodySchema = Zod.object({
28
- data: Zod.object({
29
- name: Zod.string(),
30
- age: Zod.number()
31
- })
32
- });
33
-
34
- const requestSchema = Zod.object({
35
- headers: Zod.object({
36
- authorization: Zod.string().min(10)
37
- }),
38
- body: bodySchema
39
- });
40
-
41
- const stringSchema = Zod.object({}).refine(async (val) => {
42
- const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
43
- await delay(10000);
44
-
45
- return val;
46
- });
47
-
48
- const headersSchema = Zod.object({
49
- "content-type": Zod.string()
50
- });
51
-
52
- @Controller("test")
53
- export class TestController {
54
- constructor(
55
- @Inject(Symbol.for("mongo")) private readonly testInject: any,
56
- @Inject(TestService) private readonly testService: IService
57
- ) {
58
- console.log("testInject", testInject);
59
- }
60
-
61
- @Get("abc/:id.xml")
62
- public get(@Param("id") id: string) {
63
- console.log("HEHE", id, typeof id);
64
- console.log("this.testService", this.testService.exec());
65
- }
66
-
67
- @Post("abc/:id/provider/:providerId.xml")
68
- public async post(
69
- @RequestHeaders(headersSchema)
70
- headers: Zod.infer<typeof headersSchema>,
71
- @Params()
72
- params: any,
73
- @Query()
74
- query: any,
75
- @RequestBody(bodySchema)
76
- body: Zod.infer<typeof bodySchema>
77
- ) {
78
- console.log("req.headers", params, body);
79
- console.log("===========================");
80
- }
81
-
82
- @Put()
83
- public put(req: any) {}
84
-
85
- @Patch("abc/:testId")
86
- public patch(req: Request) {}
87
-
88
- @Delete()
89
- public delete(req: Request) {}
90
-
91
- @Options()
92
- public options(req: Request) {}
93
- }
@@ -1,12 +0,0 @@
1
- import type { IGuard } from "@dist";
2
-
3
- import { Guard } from "@dist";
4
-
5
- @Guard()
6
- export class FirstGuard implements IGuard {
7
- enforce(): boolean | Promise<boolean> {
8
- console.log("Guard 01");
9
- console.log("===========================");
10
- return true;
11
- }
12
- }
@@ -1,16 +0,0 @@
1
- import type { IMiddleware } from "@dist";
2
-
3
- import { Middleware } from "@dist";
4
-
5
- @Middleware()
6
- export class FirstMiddleware implements IMiddleware {
7
- start() {
8
- console.log("Middleware 01 - Start");
9
- console.log("===========================");
10
- }
11
-
12
- end() {
13
- console.log("Middleware 01 - End");
14
- console.log("===========================");
15
- }
16
- }
@@ -1,23 +0,0 @@
1
- import { Module } from "@dist";
2
- import { TestController } from "./controller";
3
- import { TestRepository } from "./repository";
4
- import { TestService } from "./service";
5
- import { TestWebSocket } from "./webSocket";
6
-
7
- @Module<{
8
- mongodb: string;
9
- }>({
10
- config: {
11
- key: Symbol("firstModuleConfig"),
12
- value: {
13
- mongodb: "123"
14
- }
15
- },
16
- // middlewares: [FirstMiddleware, SecondMiddleware],
17
- // guards: [FirstGuard, SecondGuard],
18
- // interceptors: [CustomInterceptor],
19
- controllers: [TestController],
20
- dependencies: [TestService, TestRepository],
21
- webSockets: [TestWebSocket]
22
- })
23
- export class FirstModule {}
package/__test/index.ts DELETED
@@ -1,10 +0,0 @@
1
- import { BoolFactory } from "@dist";
2
- import { AppContainer } from "container";
3
-
4
- BoolFactory(AppContainer, {
5
- port: 3000,
6
- log: {
7
- methods: ["GET", "POST"]
8
- },
9
- debug: true
10
- });
@@ -1,16 +0,0 @@
1
- import type { IInterceptor } from "@dist";
2
-
3
- import { Interceptor } from "@dist";
4
-
5
- @Interceptor()
6
- export class CustomInterceptor implements IInterceptor {
7
- open() {
8
- console.log("Interceptor -- Open");
9
- console.log("===========================");
10
- }
11
-
12
- close() {
13
- console.log("Interceptor -- Close");
14
- console.log("===========================");
15
- }
16
- }
@@ -1,7 +0,0 @@
1
- export interface IRepository {
2
- exec(): void;
3
- }
4
-
5
- export interface IService {
6
- exec(): void;
7
- }
@@ -1,15 +0,0 @@
1
- import type { IRepository } from "./interfaces";
2
-
3
- import { Injectable } from "@dist";
4
-
5
- @Injectable()
6
- export class TestRepository implements IRepository {
7
- /**
8
- *
9
- */
10
- exec() {
11
- console.log("This is test repository.");
12
- }
13
- }
14
-
15
- export default TestRepository;
package/__test/router.ts DELETED
File without changes
@@ -1,10 +0,0 @@
1
- import { Guard, IGuard } from "@dist";
2
-
3
- @Guard()
4
- export class SecondGuard implements IGuard {
5
- enforce(): boolean | Promise<boolean> {
6
- console.log("Guard 02");
7
- console.log("===========================");
8
- return true;
9
- }
10
- }
@@ -1,15 +0,0 @@
1
- import type { IMiddleware } from "@dist";
2
- import { Middleware } from "@dist";
3
-
4
- @Middleware()
5
- export class SecondMiddleware implements IMiddleware {
6
- start() {
7
- console.log("Middleware 02 --- Start");
8
- console.log("===========================");
9
- }
10
-
11
- end() {
12
- console.log("Middleware 02 --- End");
13
- console.log("===========================");
14
- }
15
- }
@@ -1,29 +0,0 @@
1
- import { Module } from "@dist";
2
- import { TestController } from "./controller";
3
- import { FirstGuard } from "./firstGuard";
4
- import { FirstMiddleware } from "./firstMiddleware";
5
- import { CustomInterceptor } from "./interceptor";
6
- import { TestRepository } from "./repository";
7
- import { SecondGuard } from "./secondGuard";
8
- import { SecondMiddleware } from "./secondMiddleware";
9
- import { TestService } from "./service";
10
- import { TestWebSocket } from "./webSocket";
11
-
12
- @Module<{
13
- mongodb: string;
14
- }>({
15
- prefix: "/second-module",
16
- config: {
17
- key: Symbol.for("secondModuleConfig"),
18
- value: {
19
- mongodb: "123"
20
- }
21
- },
22
- middlewares: [FirstMiddleware, SecondMiddleware],
23
- guards: [FirstGuard, SecondGuard],
24
- interceptors: [CustomInterceptor],
25
- controllers: [TestController],
26
- dependencies: [TestService, TestRepository],
27
- webSockets: [TestWebSocket]
28
- })
29
- export class SecondModule {}
package/__test/service.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { IRepository, IService } from "./interfaces";
2
-
3
- import { Inject, Injectable } from "@dist";
4
- import { TestRepository } from "./repository";
5
-
6
- @Injectable()
7
- export class TestService implements IService {
8
- constructor(@Inject(TestRepository) private readonly testRepository: IRepository) {}
9
-
10
- /**
11
- *
12
- */
13
- exec() {
14
- console.log("This is test service.", this.testRepository);
15
- this.testRepository.exec();
16
- }
17
- }
@@ -1,113 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
- /* Projects */
5
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
- /* Language and Environment */
12
- "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
13
- "lib": [
14
- "ESNext",
15
- "DOM"
16
- ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
17
- // "jsx": "preserve", /* Specify what JSX code is generated. */
18
- "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
19
- "emitDecoratorMetadata": false /* Emit design-type metadata for decorated declarations in source files. */,
20
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
- "moduleDetection": "force" /* Control what method is used to detect module-format JS files. */,
27
- /* Modules */
28
- "module": "ESNext" /* Specify what module code is generated. */,
29
- // "rootDir": "./" /* Specify the root folder within your source files. */,
30
- "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
31
- "baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
32
- "paths": {
33
- "@src": ["../src"],
34
- "@dist": ["../dist"]
35
- } /* Specify a set of entries that re-map imports to additional lookup locations. */,
36
- "rootDirs": [
37
- "./",
38
- "@dist"
39
- ] /* Allow multiple folders to be treated as one when resolving modules. */,
40
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
41
- // "types": [
42
- // "reflect-metadata"
43
- // ] /* Specify type package names to be included without being referenced in a source file. */,
44
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
45
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
46
- // "allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
47
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
48
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
49
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
50
- // "resolveJsonModule": true, /* Enable importing .json files. */
51
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
52
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
53
- /* JavaScript Support */
54
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
55
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
56
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
57
- /* Emit */
58
- "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
59
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
60
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
61
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
62
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
63
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
64
- "outDir": "./dist" /* Specify an output folder for all emitted files. */,
65
- // "removeComments": true, /* Disable emitting comments. */
66
- // "noEmit": true /* Disable emitting files from a compilation. */,
67
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
68
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
69
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
70
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
71
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
72
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
73
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
74
- // "newLine": "crlf", /* Set the newline character for emitting files. */
75
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
76
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
77
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
78
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
79
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
80
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
81
- /* Interop Constraints */
82
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
83
- "verbatimModuleSyntax": true /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */,
84
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
85
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
86
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
87
- // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
88
- /* Type Checking */
89
- "strict": true /* Enable all strict type-checking options. */,
90
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
91
- "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
92
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
93
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
94
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
95
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
96
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
97
- "alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
98
- "noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
99
- // "noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
100
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
101
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
102
- "noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
103
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
104
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
105
- "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */,
106
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
107
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
108
- /* Completeness */
109
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
110
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
111
- },
112
- "include": ["./**/*.ts"]
113
- }
@@ -1,79 +0,0 @@
1
- import type { TWebSocketUpgradeData } from "@dist";
2
- import type { Server, ServerWebSocket } from "bun";
3
-
4
- import {
5
- WebSocket,
6
- WebSocketCloseCode,
7
- WebSocketCloseReason,
8
- WebSocketConnection,
9
- WebSocketEvent,
10
- WebSocketMessage,
11
- WebSocketServer
12
- } from "@dist";
13
-
14
- @WebSocket()
15
- export class TestWebSocket {
16
- @WebSocketEvent("open")
17
- onOpen(
18
- @WebSocketServer()
19
- server: Server,
20
- @WebSocketConnection()
21
- connection: ServerWebSocket<TWebSocketUpgradeData>
22
- ) {
23
- console.log("this.openHandler", server);
24
- }
25
-
26
- @WebSocketEvent("close")
27
- onClose(
28
- @WebSocketServer()
29
- server: Server,
30
- @WebSocketConnection()
31
- connection: ServerWebSocket<TWebSocketUpgradeData>,
32
- @WebSocketCloseCode()
33
- closeCode: number,
34
- @WebSocketCloseReason()
35
- closeReason: string
36
- ) {
37
- console.log("this.closeHandler", closeReason);
38
- }
39
-
40
- @WebSocketEvent("message")
41
- onMessage(
42
- @WebSocketServer()
43
- server: Server,
44
- @WebSocketConnection()
45
- connection: ServerWebSocket<TWebSocketUpgradeData>,
46
- @WebSocketMessage()
47
- message: string | Buffer
48
- ) {}
49
-
50
- @WebSocketEvent("ping")
51
- onPing(
52
- @WebSocketServer()
53
- server: Server,
54
- @WebSocketConnection()
55
- connection: ServerWebSocket<TWebSocketUpgradeData>,
56
- @WebSocketMessage()
57
- message: Buffer
58
- ) {}
59
-
60
- @WebSocketEvent("pong")
61
- onPong(
62
- @WebSocketServer()
63
- server: Server,
64
- @WebSocketConnection()
65
- connection: ServerWebSocket<TWebSocketUpgradeData>,
66
- @WebSocketMessage()
67
- message: Buffer
68
- ) {}
69
-
70
- @WebSocketEvent("drain")
71
- onDrain(
72
- @WebSocketServer()
73
- server: Server,
74
- @WebSocketConnection()
75
- connection: ServerWebSocket<TWebSocketUpgradeData>
76
- ) {
77
- console.log("this.drainHandler");
78
- }
79
- }
@@ -1,23 +0,0 @@
1
- const socket = new WebSocket("http://localhost:3000");
2
-
3
- // Connection opened
4
- socket.addEventListener("open", (event) => {
5
- socket.send("Hello Server!");
6
- });
7
-
8
- // Listen for messages
9
- socket.addEventListener("message", (event) => {
10
- console.log("Message from server ", event.data);
11
- });
12
-
13
- socket.addEventListener("open", () => {
14
- socket.send("Hello mother fucker");
15
- });
16
-
17
- socket.addEventListener("close", () => {
18
- socket.send("Hello mother fucker 1");
19
- });
20
-
21
- socket.addEventListener("error", () => {
22
- console.error("Hello mother fucker 2");
23
- });
package/jsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Enable latest features
4
- "lib": ["ESNext", "DOM"],
5
- "target": "ESNext",
6
- "module": "ESNext",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
-
11
- // Bundler mode
12
- "moduleResolution": "bundler",
13
- "allowImportingTsExtensions": true,
14
- "verbatimModuleSyntax": true,
15
- "noEmit": true,
16
-
17
- // Best practices
18
- "strict": true,
19
- "skipLibCheck": true,
20
- "noFallthroughCasesInSwitch": true,
21
-
22
- // Some stricter flags (disabled by default)
23
- "noUnusedLocals": false,
24
- "noUnusedParameters": false,
25
- "noPropertyAccessFromIndexSignature": false
26
- }
27
- }
package/test.http DELETED
@@ -1,31 +0,0 @@
1
- @baseUrl = localhost:3000
2
-
3
-
4
- ### Send test GET method
5
- GET http://{{baseUrl}}/test/abc/test-case.html
6
-
7
- ### Send test POST method
8
- POST http://{{baseUrl}}/test/abc/123/provider/1111.xml?options[page]=1&options[limit]=6&options[sort][metadata.latestReviewAt]=desc&options[sort][info.searchCount]=desc&options[sort][createdAt]=desc&populate[0]=__headquarters&populate[1]=__logoMedia HTTP/1.1
9
- content-type: application/json
10
-
11
- {
12
- "data": {
13
- "age": 2,
14
- "name": "sample",
15
- "time": "Wed, 21 Oct 2015 18:27:50 GMT"
16
- }
17
- }
18
-
19
- ### Send test PUT method
20
- PUT http://{{baseUrl}}/test
21
- Content-Type: "application/json"
22
-
23
- ### Send test PATCH method
24
- PATCH http://{{baseUrl}}/test/abc/23
25
- Content-Type: "application/json"
26
-
27
- ### Send test DELETE method
28
- DELETE http://{{baseUrl}}/test
29
-
30
- ### Send test OPTIONS method
31
- OPTIONS http://{{baseUrl}}/test
package/test.ts DELETED
File without changes
package/tsconfig.json DELETED
@@ -1,109 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
- /* Projects */
5
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
- /* Language and Environment */
12
- "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
13
- "lib": [
14
- "ESNext",
15
- "DOM"
16
- ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
17
- // "jsx": "preserve", /* Specify what JSX code is generated. */
18
- "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
19
- "emitDecoratorMetadata": false /* Emit design-type metadata for decorated declarations in source files. */,
20
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
- "moduleDetection": "force" /* Control what method is used to detect module-format JS files. */,
27
- /* Modules */
28
- "module": "ESNext" /* Specify what module code is generated. */,
29
- "rootDir": "./src" /* Specify the root folder within your source files. */,
30
- "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [
36
- // "reflect-metadata"
37
- // ] /* Specify type package names to be included without being referenced in a source file. */,
38
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
39
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
40
- // "allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
41
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
- // "resolveJsonModule": true, /* Enable importing .json files. */
45
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
46
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
47
- /* JavaScript Support */
48
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
49
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
50
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
51
- /* Emit */
52
- "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
53
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
- "outDir": "./dist" /* Specify an output folder for all emitted files. */,
59
- // "removeComments": true, /* Disable emitting comments. */
60
- // "noEmit": true /* Disable emitting files from a compilation. */,
61
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
62
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
63
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
64
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
65
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
66
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
67
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
68
- // "newLine": "crlf", /* Set the newline character for emitting files. */
69
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
70
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
71
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
72
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
73
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
74
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
75
- /* Interop Constraints */
76
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
77
- "verbatimModuleSyntax": true /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */,
78
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
79
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
80
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
81
- // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
82
- /* Type Checking */
83
- "strict": true /* Enable all strict type-checking options. */,
84
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
85
- "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
86
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
87
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
88
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
89
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
90
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
91
- "alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
92
- "noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
93
- // "noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
94
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
95
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
96
- "noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
97
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
98
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
99
- "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */,
100
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
101
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
102
- /* Completeness */
103
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
104
- "skipLibCheck": true /* Skip type checking all .d.ts files. */,
105
- "useDefineForClassFields": true
106
- },
107
- "include": ["./src/**/*.ts"],
108
- "exclude": ["./__test/**/*.ts"]
109
- }