@nextrush/types 3.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ // src/http.ts
2
+ var HTTP_METHODS = [
3
+ "GET",
4
+ "POST",
5
+ "PUT",
6
+ "DELETE",
7
+ "PATCH",
8
+ "HEAD",
9
+ "OPTIONS"
10
+ ];
11
+ var HttpStatus = {
12
+ // 2xx Success
13
+ OK: 200,
14
+ CREATED: 201,
15
+ ACCEPTED: 202,
16
+ NO_CONTENT: 204,
17
+ // 3xx Redirection
18
+ MOVED_PERMANENTLY: 301,
19
+ FOUND: 302,
20
+ SEE_OTHER: 303,
21
+ NOT_MODIFIED: 304,
22
+ TEMPORARY_REDIRECT: 307,
23
+ PERMANENT_REDIRECT: 308,
24
+ // 4xx Client Errors
25
+ BAD_REQUEST: 400,
26
+ UNAUTHORIZED: 401,
27
+ PAYMENT_REQUIRED: 402,
28
+ FORBIDDEN: 403,
29
+ NOT_FOUND: 404,
30
+ METHOD_NOT_ALLOWED: 405,
31
+ NOT_ACCEPTABLE: 406,
32
+ PROXY_AUTH_REQUIRED: 407,
33
+ REQUEST_TIMEOUT: 408,
34
+ CONFLICT: 409,
35
+ GONE: 410,
36
+ LENGTH_REQUIRED: 411,
37
+ PRECONDITION_FAILED: 412,
38
+ PAYLOAD_TOO_LARGE: 413,
39
+ URI_TOO_LONG: 414,
40
+ UNSUPPORTED_MEDIA_TYPE: 415,
41
+ RANGE_NOT_SATISFIABLE: 416,
42
+ EXPECTATION_FAILED: 417,
43
+ IM_A_TEAPOT: 418,
44
+ UNPROCESSABLE_ENTITY: 422,
45
+ LOCKED: 423,
46
+ FAILED_DEPENDENCY: 424,
47
+ TOO_EARLY: 425,
48
+ UPGRADE_REQUIRED: 426,
49
+ PRECONDITION_REQUIRED: 428,
50
+ TOO_MANY_REQUESTS: 429,
51
+ REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
52
+ UNAVAILABLE_FOR_LEGAL_REASONS: 451,
53
+ // 5xx Server Errors
54
+ INTERNAL_SERVER_ERROR: 500,
55
+ NOT_IMPLEMENTED: 501,
56
+ BAD_GATEWAY: 502,
57
+ SERVICE_UNAVAILABLE: 503,
58
+ GATEWAY_TIMEOUT: 504,
59
+ HTTP_VERSION_NOT_SUPPORTED: 505,
60
+ VARIANT_ALSO_NEGOTIATES: 506,
61
+ INSUFFICIENT_STORAGE: 507,
62
+ LOOP_DETECTED: 508,
63
+ NOT_EXTENDED: 510,
64
+ NETWORK_AUTH_REQUIRED: 511
65
+ };
66
+ var ContentType = {
67
+ JSON: "application/json",
68
+ HTML: "text/html",
69
+ TEXT: "text/plain",
70
+ XML: "application/xml",
71
+ FORM: "application/x-www-form-urlencoded",
72
+ MULTIPART: "multipart/form-data",
73
+ OCTET_STREAM: "application/octet-stream"
74
+ };
75
+
76
+ export { ContentType, HTTP_METHODS, HttpStatus };
77
+ //# sourceMappingURL=index.js.map
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/http.ts"],"names":[],"mappings":";AAyCO,IAAM,YAAA,GAAe;AAAA,EAC1B,KAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAuBO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,EAAA,EAAI,GAAA;AAAA,EACJ,OAAA,EAAS,GAAA;AAAA,EACT,QAAA,EAAU,GAAA;AAAA,EACV,UAAA,EAAY,GAAA;AAAA;AAAA,EAGZ,iBAAA,EAAmB,GAAA;AAAA,EACnB,KAAA,EAAO,GAAA;AAAA,EACP,SAAA,EAAW,GAAA;AAAA,EACX,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB,GAAA;AAAA,EACpB,kBAAA,EAAoB,GAAA;AAAA;AAAA,EAGpB,WAAA,EAAa,GAAA;AAAA,EACb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,kBAAA;AAAA,EACN,IAAA,EAAM,WAAA;AAAA,EACN,IAAA,EAAM,YAAA;AAAA,EACN,GAAA,EAAK,iBAAA;AAAA,EACL,IAAA,EAAM,mCAAA;AAAA,EACN,SAAA,EAAW,qBAAA;AAAA,EACX,YAAA,EAAc;AAChB","file":"index.js","sourcesContent":["/**\n * @nextrush/types - HTTP Type Definitions\n *\n * Core HTTP types used across the NextRush framework.\n * These types provide a clean abstraction over HTTP primitives,\n * designed to work across multiple runtimes (Node.js, Bun, Deno, Edge).\n *\n * @packageDocumentation\n */\n\n// ============================================================================\n// HTTP Method Types\n// ============================================================================\n\n/**\n * Standard HTTP methods supported by NextRush\n */\nexport type HttpMethod =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'HEAD'\n | 'OPTIONS'\n | 'TRACE'\n | 'CONNECT';\n\n/**\n * Common HTTP methods for convenience\n */\nexport type CommonHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\n/**\n * HTTP methods as readonly tuple for iteration.\n *\n * Note: TRACE and CONNECT are intentionally excluded from this constant.\n * - TRACE enables Cross-Site Tracing (XST) attacks and is disabled by most servers.\n * - CONNECT is used for HTTP tunneling (proxies) and is not relevant to application routing.\n * Both remain in the `HttpMethod` type for completeness (e.g., custom proxy adapters).\n */\nexport const HTTP_METHODS = [\n 'GET',\n 'POST',\n 'PUT',\n 'DELETE',\n 'PATCH',\n 'HEAD',\n 'OPTIONS',\n] as const satisfies readonly HttpMethod[];\n\n// ============================================================================\n// HTTP Headers Types\n// ============================================================================\n\n/**\n * Incoming request headers (read-only)\n */\nexport type IncomingHeaders = Readonly<Record<string, string | string[] | undefined>>;\n\n/**\n * Outgoing response headers (writable)\n */\nexport type OutgoingHeaders = Record<string, string | number | string[]>;\n\n// ============================================================================\n// HTTP Status Codes\n// ============================================================================\n\n/**\n * HTTP status codes\n */\nexport const HttpStatus = {\n // 2xx Success\n OK: 200,\n CREATED: 201,\n ACCEPTED: 202,\n NO_CONTENT: 204,\n\n // 3xx Redirection\n MOVED_PERMANENTLY: 301,\n FOUND: 302,\n SEE_OTHER: 303,\n NOT_MODIFIED: 304,\n TEMPORARY_REDIRECT: 307,\n PERMANENT_REDIRECT: 308,\n\n // 4xx Client Errors\n BAD_REQUEST: 400,\n UNAUTHORIZED: 401,\n PAYMENT_REQUIRED: 402,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n METHOD_NOT_ALLOWED: 405,\n NOT_ACCEPTABLE: 406,\n PROXY_AUTH_REQUIRED: 407,\n REQUEST_TIMEOUT: 408,\n CONFLICT: 409,\n GONE: 410,\n LENGTH_REQUIRED: 411,\n PRECONDITION_FAILED: 412,\n PAYLOAD_TOO_LARGE: 413,\n URI_TOO_LONG: 414,\n UNSUPPORTED_MEDIA_TYPE: 415,\n RANGE_NOT_SATISFIABLE: 416,\n EXPECTATION_FAILED: 417,\n IM_A_TEAPOT: 418,\n UNPROCESSABLE_ENTITY: 422,\n LOCKED: 423,\n FAILED_DEPENDENCY: 424,\n TOO_EARLY: 425,\n UPGRADE_REQUIRED: 426,\n PRECONDITION_REQUIRED: 428,\n TOO_MANY_REQUESTS: 429,\n REQUEST_HEADER_FIELDS_TOO_LARGE: 431,\n UNAVAILABLE_FOR_LEGAL_REASONS: 451,\n\n // 5xx Server Errors\n INTERNAL_SERVER_ERROR: 500,\n NOT_IMPLEMENTED: 501,\n BAD_GATEWAY: 502,\n SERVICE_UNAVAILABLE: 503,\n GATEWAY_TIMEOUT: 504,\n HTTP_VERSION_NOT_SUPPORTED: 505,\n VARIANT_ALSO_NEGOTIATES: 506,\n INSUFFICIENT_STORAGE: 507,\n LOOP_DETECTED: 508,\n NOT_EXTENDED: 510,\n NETWORK_AUTH_REQUIRED: 511,\n} as const;\n\nexport type HttpStatusCode = (typeof HttpStatus)[keyof typeof HttpStatus];\n\n// ============================================================================\n// Request/Response Body Types\n// ============================================================================\n\n/**\n * Supported request body types after parsing\n */\nexport type ParsedBody =\n | string\n | Uint8Array\n | Record<string, unknown>\n | unknown[]\n | null\n | undefined;\n\n/**\n * Supported response body types\n *\n * @remarks\n * Uses structural stream interfaces to avoid coupling to any\n * specific runtime (Node.js, Bun, Deno, Edge).\n * Uint8Array and ArrayBuffer provide Web API compatibility.\n */\nexport type ResponseBody =\n | string\n | Uint8Array\n | ArrayBuffer\n | NodeStreamLike\n | WebStreamLike\n | Record<string, unknown>\n | unknown[]\n | null\n | undefined;\n\n// ============================================================================\n// Cross-Runtime Stream Types\n// ============================================================================\n\n/**\n * Structural interface for Node.js-compatible readable streams.\n * Matches Node.js `Readable` and `IncomingMessage` without importing `@types/node`.\n */\nexport interface NodeStreamLike {\n pipe(destination: unknown): unknown;\n}\n\n/**\n * Structural interface for Web API ReadableStreams.\n * Matches the global `ReadableStream<Uint8Array>` without requiring DOM lib types.\n */\nexport interface WebStreamLike {\n getReader(): unknown;\n readonly locked: boolean;\n}\n\n// ============================================================================\n// Raw HTTP Access Types\n// ============================================================================\n\n/**\n * Raw HTTP objects - generic to support multiple runtimes\n *\n * For Node.js: RawHttp<IncomingMessage, ServerResponse>\n * For Bun: RawHttp<Request, Response>\n * For Edge: RawHttp<Request, ResponseInit>\n *\n * @typeParam TReq - Raw request type for the runtime\n * @typeParam TRes - Raw response type for the runtime\n */\nexport interface RawHttp<TReq = unknown, TRes = unknown> {\n readonly req: TReq;\n readonly res: TRes;\n}\n\n// ============================================================================\n// Content Type Helpers\n// ============================================================================\n\n/**\n * Common content types\n */\nexport const ContentType = {\n JSON: 'application/json',\n HTML: 'text/html',\n TEXT: 'text/plain',\n XML: 'application/xml',\n FORM: 'application/x-www-form-urlencoded',\n MULTIPART: 'multipart/form-data',\n OCTET_STREAM: 'application/octet-stream',\n} as const;\n\nexport type ContentTypeValue = (typeof ContentType)[keyof typeof ContentType];\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nextrush/types",
3
+ "version": "3.0.0",
4
+ "description": "Shared TypeScript types for NextRush framework",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "keywords": [
19
+ "nextrush",
20
+ "types",
21
+ "typescript"
22
+ ],
23
+ "author": {
24
+ "name": "Tanzim Hossain",
25
+ "email": "tanzimhossain2@gmail.com",
26
+ "url": "https://github.com/0xTanzim"
27
+ },
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/0xTanzim/nextrush.git",
32
+ "directory": "packages/types"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/0xTanzim/nextrush/issues"
36
+ },
37
+ "homepage": "https://github.com/0xTanzim/nextrush#readme",
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^25.5.2",
46
+ "tsup": "^8.5.1",
47
+ "typescript": "^6.0.2"
48
+ },
49
+ "sideEffects": false,
50
+ "scripts": {
51
+ "build": "tsup",
52
+ "dev": "tsup --watch",
53
+ "typecheck": "tsc --noEmit",
54
+ "lint": "eslint src --ignore-pattern '**/__tests__/**'",
55
+ "lint:fix": "eslint src --fix",
56
+ "clean": "rm -rf dist .turbo"
57
+ }
58
+ }