tspace-spear 1.2.5 → 1.2.6-beta.2

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 (44) hide show
  1. package/README.md +300 -26
  2. package/dist/cli/app.d.ts +1 -0
  3. package/dist/cli/app.js +24 -0
  4. package/dist/cli/app.js.map +1 -0
  5. package/dist/cli/controller.d.ts +1 -0
  6. package/dist/cli/controller.js +158 -0
  7. package/dist/cli/controller.js.map +1 -0
  8. package/dist/cli/index.d.ts +2 -0
  9. package/dist/cli/index.js +138 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/lib/core/client/index.d.ts +82 -0
  12. package/dist/lib/core/client/index.js +142 -0
  13. package/dist/lib/core/client/index.js.map +1 -0
  14. package/dist/lib/core/compiler/generator.d.ts +18 -0
  15. package/dist/lib/core/compiler/generator.js +365 -0
  16. package/dist/lib/core/compiler/generator.js.map +1 -0
  17. package/dist/lib/core/compiler/index.d.ts +14 -0
  18. package/dist/lib/core/compiler/index.js +12 -0
  19. package/dist/lib/core/compiler/index.js.map +1 -0
  20. package/dist/lib/core/compiler/pre-routes.d.ts +61 -0
  21. package/dist/lib/core/compiler/pre-routes.js +18 -0
  22. package/dist/lib/core/compiler/pre-routes.js.map +1 -0
  23. package/dist/lib/core/compiler/types.d.ts +14 -0
  24. package/dist/lib/core/compiler/types.js +3 -0
  25. package/dist/lib/core/compiler/types.js.map +1 -0
  26. package/dist/lib/core/decorators/context.d.ts +50 -1
  27. package/dist/lib/core/decorators/context.js +87 -3
  28. package/dist/lib/core/decorators/context.js.map +1 -1
  29. package/dist/lib/core/decorators/swagger.d.ts +1 -1
  30. package/dist/lib/core/decorators/swagger.js +1 -1
  31. package/dist/lib/core/decorators/swagger.js.map +1 -1
  32. package/dist/lib/core/server/fast-router.js +11 -2
  33. package/dist/lib/core/server/fast-router.js.map +1 -1
  34. package/dist/lib/core/server/index.d.ts +16 -0
  35. package/dist/lib/core/server/index.js +118 -38
  36. package/dist/lib/core/server/index.js.map +1 -1
  37. package/dist/lib/core/server/parser-factory.d.ts +2 -2
  38. package/dist/lib/core/server/parser-factory.js +236 -4
  39. package/dist/lib/core/server/parser-factory.js.map +1 -1
  40. package/dist/lib/core/types/index.d.ts +13 -9
  41. package/dist/tests/e2e..test.d.ts +1 -0
  42. package/dist/tests/e2e..test.js +16 -0
  43. package/dist/tests/e2e..test.js.map +1 -0
  44. package/package.json +32 -4
@@ -1,27 +1,28 @@
1
1
  import http, { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "http";
2
2
  import WebSocket from "ws";
3
3
  import net from 'net';
4
- type TContext = {
4
+ type TContextBase = {
5
5
  req: TRequest;
6
6
  res: TResponse;
7
7
  headers: THeaders;
8
- query: TQuery;
9
8
  params: TParams;
10
- body: TBody;
11
- files: TFileUpload;
12
9
  cookies: TCookies;
13
10
  ip: TIp;
14
11
  ips: TIps;
12
+ body: TBody;
13
+ query: TQuery;
14
+ files: TFileUpload;
15
15
  };
16
+ type TContext<Override extends Partial<Pick<TContextBase, "body" | "query" | "files" | "params">> = {}> = Omit<TContextBase, keyof Override> & Override;
16
17
  type TIp = string | null;
17
18
  type TIps = string[];
18
19
  type THeaders<T = IncomingHttpHeaders> = {
19
20
  [K in keyof T]: T[K];
20
21
  };
21
22
  type TQuery<T = Record<string, string | undefined>> = T;
22
- type TParams<T = Record<string, string | undefined>> = T;
23
+ type TParams<T = Record<string, string | number | undefined>> = T;
23
24
  type TBody<T = Record<string, any>> = T;
24
- type TCookies<T = Record<string, any>> = T;
25
+ type TCookies<T = Record<string, any | undefined>> = T;
25
26
  type TFile = {
26
27
  size: number;
27
28
  sizes: {
@@ -38,7 +39,7 @@ type TFile = {
38
39
  write: (to: string) => Promise<void>;
39
40
  remove: () => Promise<void>;
40
41
  };
41
- type TFileUpload = Record<string, TFile[] | undefined>;
42
+ type TFileUpload<T = Record<string, TFile[] | undefined>> = T;
42
43
  type TNextFunction<T = any> = (err?: Error) => T | Promise<T>;
43
44
  type TRequest = IncomingMessage & {
44
45
  uWs: any;
@@ -209,6 +210,7 @@ type TApplication = {
209
210
  controllers?: (new () => any)[] | {
210
211
  folder: string;
211
212
  name?: RegExp;
213
+ preRouteTypes?: boolean;
212
214
  };
213
215
  middlewares?: TContextHandler[] | {
214
216
  folder: string;
@@ -242,6 +244,7 @@ type TSwaggerDoc = {
242
244
  method: string;
243
245
  params: string[];
244
246
  }[];
247
+ globalPrefix?: string;
245
248
  specs?: (TSwagger & {
246
249
  path: string;
247
250
  method: string;
@@ -315,12 +318,12 @@ type TWSHandler = {
315
318
  error: (ws: WebSocket & Partial<any>, error: Error) => void;
316
319
  };
317
320
  export declare namespace T {
321
+ type Context<O extends Partial<Pick<TContextBase, "body" | "query" | "files" | "params">> = {}> = TContext<O>;
318
322
  type Adapter = TAdapter;
319
323
  type AdapterServer = TAdapterServer;
320
324
  type Application = TApplication;
321
325
  type NextFunction = TNextFunction;
322
326
  type File = TFile;
323
- type Context = TContext;
324
327
  type Router = TRouter;
325
328
  type Route = TRoute;
326
329
  type Method = TMethod;
@@ -332,7 +335,8 @@ export declare namespace T {
332
335
  type MethodInput = TMethodInput;
333
336
  type Response = TResponse;
334
337
  type Request = TRequest;
335
- type FileUpload = TFileUpload;
338
+ type FileUpload<T = Record<string, TFile[] | undefined>> = T;
339
+ type FileInput = TFile;
336
340
  type Cookies<T = Record<string, any>> = TCookies<T>;
337
341
  type Params<T = Record<string, string>> = TParams<T>;
338
342
  type Query<T = Record<string, string>> = TQuery<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chai_1 = __importDefault(require("chai"));
7
+ const mocha_1 = require("mocha");
8
+ const chai_json_schema_1 = __importDefault(require("chai-json-schema"));
9
+ chai_1.default.use(chai_json_schema_1.default);
10
+ (0, mocha_1.describe)('Testing Driver', function () {
11
+ /* ##################################################### */
12
+ (0, mocha_1.it)(`Driver: Using driver in ['mysql','postgres' ,'mariadb','mssql','sqlite'] ?`, async function () {
13
+ });
14
+ /* ###################################################### */
15
+ });
16
+ //# sourceMappingURL=e2e..test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"e2e..test.js","sourceRoot":"","sources":["../../src/tests/e2e..test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAoC;AACpC,iCAAoC;AACpC,wEAA6C;AAE7C,cAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAA;AAExB,IAAA,gBAAQ,EAAC,gBAAgB,EAAE;IACzB,2DAA2D;IAC3D,IAAA,UAAE,EAAC,4EAA4E,EAC/E,KAAK;IACL,CAAC,CAAC,CAAA;IACF,4DAA4D;AAC9D,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "tspace-spear",
3
- "version": "1.2.5",
3
+ "version": "1.2.6-beta.2",
4
4
  "description": "tspace-spear is a lightweight, high-performance API framework for Node.js that leverages the native HTTP server and supports uWebSockets.js (C++) for maximum speed and efficiency.",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
+ "bin": {
11
+ "tspace-spear": "./dist/cli/index.js"
12
+ },
10
13
  "type": "commonjs",
11
14
  "repository": {
12
15
  "type": "git",
@@ -35,16 +38,28 @@
35
38
  "scripts": {
36
39
  "build": "tsc",
37
40
  "prepare": "npm run build",
38
- "release": "npm run build && npm publish",
41
+ "release": "sh ./release.sh",
39
42
  "beta": "npm run build && npm publish --tag beta",
40
43
  "bm:node": "npm run benchmark:node",
41
44
  "bm:bun": "npm run benchmark:bun",
42
45
  "benchmark:node": "npm run build && node benchmarks/tests/benchmark.node.js",
43
46
  "benchmark:bun": "npm run build && bun run benchmarks/tests/benchmark.bun.js",
44
- "test": "mocha dist/tests/**/0*.test.js",
45
47
  "load": "autocannon -c 100 -d 30 -p 10 localhost:5000",
48
+ "test": "ts-mocha ./__tests__/**/*.test.ts --reporter spec --no-timeouts --recursive --reporter mochawesome --reporter-options reportDir=__tests-report__,reportFilename=errors.html,reportTitle=Unit-test --exit",
46
49
  "docs": "npx docsify-cli serve docs"
47
50
  },
51
+ "exports": {
52
+ ".": {
53
+ "types": "./dist/lib/index.d.ts",
54
+ "import": "./dist/lib/index.js",
55
+ "require": "./dist/lib/index.js"
56
+ },
57
+ "./client": {
58
+ "types": "./dist/lib/core/client/index.d.ts",
59
+ "import": "./dist/lib/core/client/index.js",
60
+ "require": "./dist/lib/core/client/index.js"
61
+ }
62
+ },
48
63
  "engines": {
49
64
  "node": ">=14"
50
65
  },
@@ -52,9 +67,11 @@
52
67
  "busboy": "1.6.0",
53
68
  "fast-querystring": "1.1.2",
54
69
  "mime-types": "2.1.35",
70
+ "node-fetch": "2.7.0",
55
71
  "on-finished": "2.4.1",
56
72
  "reflect-metadata": "0.2.2",
57
73
  "swagger-ui-dist": "5.32.0",
74
+ "ts-morph": "28.0.0",
58
75
  "ws": "8.19.0",
59
76
  "xml2js": "0.6.2"
60
77
  },
@@ -63,22 +80,33 @@
63
80
  "@hono/node-server": "1.19.11",
64
81
  "@types/autocannon": "7.12.5",
65
82
  "@types/busboy": "1.5.4",
83
+ "@types/chai": "4.3.11",
84
+ "@types/chai-json-schema": "1.4.9",
66
85
  "@types/express": "4.17.21",
67
86
  "@types/mime-types": "2.1.4",
87
+ "@types/mocha": "10.0.6",
68
88
  "@types/node": "16.18.126",
89
+ "@types/node-fetch": "^2.6.13",
69
90
  "@types/on-finished": "2.3.4",
70
91
  "@types/swagger-ui-dist": "3.30.4",
71
92
  "@types/ws": "8.18.1",
72
93
  "@types/xml2js": "0.4.14",
73
94
  "0http": "4.4.0",
74
95
  "autocannon": "7.15.0",
96
+ "chai": "4.3.10",
97
+ "chai-json-schema": "1.5.1",
98
+ "class-transformer": "0.5.1",
99
+ "class-validator": "0.15.1",
75
100
  "docsify-cli": "4.4.4",
76
101
  "elysia": "1.4.28",
77
102
  "express": "4.19.2",
78
103
  "fastify": "4.28.1",
79
104
  "hono": "4.12.9",
105
+ "mocha": "10.2.0",
106
+ "mochawesome": "7.1.3",
107
+ "ts-mocha": "10.0.0",
80
108
  "ts-node": "10.9.2",
81
- "typescript": "5.9.3",
109
+ "typescript": "5.6.2",
82
110
  "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.63.0",
83
111
  "zod": "4.3.6"
84
112
  }