burger-api 0.1.4 → 0.2.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/package.json CHANGED
@@ -1,83 +1,83 @@
1
- {
2
- "name": "burger-api",
3
- "version": "0.1.4",
4
- "author": "Isfhan Ahmed",
5
- "type": "module",
6
- "module": "dist/src/index.js",
7
- "types": "dist/src/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "scripts": {
12
- "typecheck": "tsc --noEmit",
13
- "build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
14
- "test": "bun test",
15
- "dev": "bun run examples/file-base-static-page-routing-app/index.ts"
16
- },
17
- "keywords": [
18
- "burger-api",
19
- "burger-api-framework",
20
- "bun",
21
- "bunjs",
22
- "bun-framework",
23
- "fast-backend",
24
- "javascript-backend",
25
- "high-performance",
26
- "esm",
27
- "typescript",
28
- "openapi",
29
- "swagger-ui",
30
- "declarative-routing",
31
- "api-framework",
32
- "modern-backend",
33
- "backend-framework",
34
- "server",
35
- "bun-native",
36
- "js-backend",
37
- "fast-api",
38
- "scalable-backend",
39
- "backend-development",
40
- "modern-api",
41
- "api-development",
42
- "backend-engine",
43
- "efficient",
44
- "minimalist-backend",
45
- "bun-powered",
46
- "open-source",
47
- "typescript-backend",
48
- "performance",
49
- "rapid-development",
50
- "web-framework",
51
- "api-server",
52
- "dynamic-routing",
53
- "backend-routing",
54
- "extensible",
55
- "modular",
56
- "declarative-api",
57
- "lightweight",
58
- "contemporary-backend",
59
- "fast-javascript",
60
- "bun-js-framework",
61
- "bun-backend"
62
- ],
63
- "license": "MIT",
64
- "repository": {
65
- "type": "git",
66
- "url": "git+https://github.com/isfhan/burger-api.git"
67
- },
68
- "bugs": {
69
- "url": "https://github.com/isfhan/burger-api/issues"
70
- },
71
- "homepage": "https://burger-api-docs.vercel.app",
72
- "dependencies": {
73
- "zod": "^3.24.2",
74
- "zod-to-json-schema": "^3.24.4"
75
- },
76
- "devDependencies": {
77
- "@types/bun": "latest",
78
- "tsc-alias": "^1.8.11"
79
- },
80
- "peerDependencies": {
81
- "typescript": "^5.7.3"
82
- }
1
+ {
2
+ "name": "burger-api",
3
+ "version": "0.2.0",
4
+ "author": "Isfhan Ahmed",
5
+ "type": "module",
6
+ "module": "dist/src/index.js",
7
+ "types": "dist/src/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "typecheck": "tsc --noEmit",
13
+ "build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
14
+ "test": "bun test",
15
+ "dev": "bun run examples/file-base-static-page-routing-app/index.ts"
16
+ },
17
+ "keywords": [
18
+ "burger-api",
19
+ "burger-api-framework",
20
+ "bun",
21
+ "bunjs",
22
+ "bun-framework",
23
+ "fast-backend",
24
+ "javascript-backend",
25
+ "high-performance",
26
+ "esm",
27
+ "typescript",
28
+ "openapi",
29
+ "swagger-ui",
30
+ "declarative-routing",
31
+ "api-framework",
32
+ "modern-backend",
33
+ "backend-framework",
34
+ "server",
35
+ "bun-native",
36
+ "js-backend",
37
+ "fast-api",
38
+ "scalable-backend",
39
+ "backend-development",
40
+ "modern-api",
41
+ "api-development",
42
+ "backend-engine",
43
+ "efficient",
44
+ "minimalist-backend",
45
+ "bun-powered",
46
+ "open-source",
47
+ "typescript-backend",
48
+ "performance",
49
+ "rapid-development",
50
+ "web-framework",
51
+ "api-server",
52
+ "dynamic-routing",
53
+ "backend-routing",
54
+ "extensible",
55
+ "modular",
56
+ "declarative-api",
57
+ "lightweight",
58
+ "contemporary-backend",
59
+ "fast-javascript",
60
+ "bun-js-framework",
61
+ "bun-backend"
62
+ ],
63
+ "license": "MIT",
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "git+https://github.com/isfhan/burger-api.git"
67
+ },
68
+ "bugs": {
69
+ "url": "https://github.com/isfhan/burger-api/issues"
70
+ },
71
+ "homepage": "https://burger-api-docs.vercel.app",
72
+ "dependencies": {
73
+ "zod": "^3.24.3",
74
+ "zod-to-json-schema": "^3.24.5"
75
+ },
76
+ "devDependencies": {
77
+ "@types/bun": "latest",
78
+ "tsc-alias": "^1.8.15"
79
+ },
80
+ "peerDependencies": {
81
+ "typescript": "^5.7.3"
82
+ }
83
83
  }
@@ -1,257 +0,0 @@
1
- import { z } from 'zod';
2
- export interface ServerOptions {
3
- /**
4
- * The title of the API. This is an optional property that can be used
5
- * to specify a custom title for the API documentation.
6
- */
7
- title?: string;
8
- /**
9
- * The description of the API. This is an optional property that can be used
10
- * to provide a brief overview of the API.
11
- */
12
- description?: string;
13
- /**
14
- * The directory path to load API routes from.
15
- * If not specified, no API routes are loaded.
16
- */
17
- apiDir?: string;
18
- /**
19
- * The directory path to load Page routes from.
20
- * If not specified, no Page routes are loaded.
21
- * Page routes are not yet supported, but will be supported in the future.
22
- */
23
- pageDir?: string;
24
- /**
25
- * Global middleware to be executed before each request.
26
- */
27
- globalMiddleware?: Middleware[];
28
- /**
29
- * The version of the API. This is an optional property that can be used
30
- * to specify the version of the API.
31
- */
32
- version?: string;
33
- /**
34
- * Enables or disables debug mode. This is an optional property
35
- * that, when set to true, can be used to output additional debugging
36
- * information to the console or logs to aid in development and troubleshooting.
37
- */
38
- debug?: boolean;
39
- }
40
- export interface BurgerRequest extends Request {
41
- /**
42
- * Provides helper to access query parameters as URLSearchParams.
43
- * This is a convenience property that allows you to access the query
44
- * parameters of the request as a URLSearchParams object, which provides
45
- * methods for working with the query parameters like `get(key)`,
46
- * `getAll(key)`, `has(key)`, `keys()`, `values()`, `entries()`, and more.
47
- */
48
- query: URLSearchParams;
49
- /**
50
- * Contains URL parameters extracted from the request path.
51
- * This property is only present if the request path matches a route
52
- * with dynamic parameters.
53
- *
54
- * For example, if the route is `/users/:id`, and the request path is
55
- * `/users/123`, then the `params` property will be `{ id: '123' }`.
56
- */
57
- params?: Record<string, string>;
58
- /**
59
- * Contains validated data for the request.
60
- * This is an optional property that will only be present if
61
- * a middleware has validated the request data and attached the
62
- * validated data to the request.
63
- *
64
- * Properties:
65
- * - `params`: Validated URL parameters.
66
- * - `query`: Validated query string parameters.
67
- * - `body`: Validated request body (if JSON).
68
- */
69
- validated?: {
70
- params?: unknown;
71
- query?: unknown;
72
- body?: unknown;
73
- };
74
- }
75
- export interface BurgerResponse {
76
- /**
77
- * Sets a header value.
78
- * @param name - The header name.
79
- * @param value - The header value.
80
- * @returns The current instance for chaining.
81
- */
82
- header(name: string, value: string): this;
83
- /**
84
- * Removes a header.
85
- * @param name - The header name to remove.
86
- * @returns The current instance for chaining.
87
- */
88
- removeHeader(name: string): this;
89
- /**
90
- * Sets the HTTP status code.
91
- * @param status - The status code.
92
- * @returns The current instance for chaining.
93
- */
94
- status(status: number): this;
95
- /**
96
- * Sets the response body.
97
- * @param body - The body content.
98
- * @returns The current instance for chaining.
99
- */
100
- body(body: BodyInit): this;
101
- /**
102
- * Builds and returns the final Response object using the current state.
103
- * This should be called only once when the response is finalized.
104
- * @returns The final Response object.
105
- */
106
- build(): Response;
107
- /**
108
- * Convenience method to send a JSON response.
109
- * Sets the "Content-Type" header and serializes the data to JSON.
110
- * @param data - The data to send.
111
- * @returns The final Response object.
112
- */
113
- json(data: unknown): Response;
114
- /**
115
- * Convenience method to send a plain text response.
116
- * Sets the "Content-Type" header and returns a text response.
117
- * @param data - The text to send.
118
- * @returns The final Response object.
119
- */
120
- text(data: string): Response;
121
- /**
122
- * Convenience method to send an HTML response.
123
- * Sets the "Content-Type" header and returns an HTML response.
124
- * @param data - The HTML string to send.
125
- * @returns The final Response object.
126
- */
127
- html(data: string): Response;
128
- /**
129
- * Convenience method to send a redirect response.
130
- * Sets the "Location" header and status code.
131
- * @param url - The URL to redirect to.
132
- * @param status - The HTTP status code (default 302).
133
- * @returns The current instance for chaining.
134
- */
135
- redirect(url: string, status?: number): this;
136
- /**
137
- * Convenience method to send a file response using Bun.file.
138
- * @param filePath - The file path to serve.
139
- * @returns The final Response object.
140
- */
141
- file(filePath: string): Response;
142
- /**
143
- * Returns a Response directly using the provided body and init settings.
144
- * This bypasses the mutable state.
145
- * @param body - The response body.
146
- * @param init - Optional ResponseInit settings.
147
- * @returns A new Response object.
148
- */
149
- original(body?: BodyInit | null, init?: ResponseInit): Response;
150
- }
151
- /**
152
- * Represents a next function in the request handling pipeline.
153
- * This function is used to call the next middleware in the chain.
154
- * It returns a Promise that resolves with a Response object.
155
- */
156
- export type BurgerNext = () => Promise<Response>;
157
- /**
158
- * Represents a request handler function.
159
- * Request handler functions receive a BurgerRequest and BurgerResponse as
160
- * arguments. They must return a Response object, which can be either a Promise
161
- * that resolves with a Response object or a Response object directly.
162
- *
163
- * @param request - The incoming BurgerRequest object.
164
- * @param response - The outgoing BurgerResponse object.
165
- * @returns A Response object or a Promise that resolves with a Response object.
166
- */
167
- export type RequestHandler = (request: BurgerRequest, response: BurgerResponse) => Promise<Response> | Response;
168
- /**
169
- * Represents a middleware function in the request handling pipeline.
170
- * Middleware functions have the ability to modify the request and response
171
- * objects, end the request-response cycle, or call the next middleware function
172
- * in the chain. They are executed in the order they are defined.
173
- *
174
- * @param request - The incoming BurgerRequest object.
175
- * @param response - The outgoing BurgerResponse object.
176
- * @param next - A function to call the next middleware in the chain.
177
- * @returns A Promise that resolves with the response.
178
- */
179
- export type Middleware = (request: BurgerRequest, response: BurgerResponse, next: BurgerNext) => Promise<Response>;
180
- export interface RouteDefinition {
181
- /**
182
- * The path of the route.
183
- */
184
- path: string;
185
- /**
186
- * An object containing the request handlers for each HTTP method.
187
- * The keys are the HTTP method names (e.g. "GET", "POST", etc.).
188
- * The values are the request handlers for that method.
189
- */
190
- handlers: {
191
- [method: string]: RequestHandler;
192
- };
193
- /**
194
- * An array of middleware functions to run before the request handler.
195
- * The middleware functions will be run in the order they are specified.
196
- */
197
- middleware?: Middleware[];
198
- /**
199
- * An optional route schema to validate the request data against.
200
- * This property is set by the user when defining a route.
201
- * The schema is used to validate the request data for each HTTP method.
202
- * The keys are the HTTP method names (in lowercase) and the values are
203
- * the Zod schema objects for that method.
204
- */
205
- schema?: RouteSchema;
206
- /**
207
- * Optional OpenAPI metadata to generate documentation for the route.
208
- * If provided, this property should define an object where each key
209
- * is an HTTP method name (in lowercase), and the value is an object
210
- * containing the OpenAPI metadata for that method.
211
- */
212
- openapi?: openapi;
213
- }
214
- /**
215
- * Define a type for the route schema.
216
- * For each HTTP method (in lowercase), you can optionally define:
217
- * - params: for URL parameters,
218
- * - query: for query string parameters,
219
- * - body: for the request body.
220
- */
221
- export type RouteSchema = {
222
- [method: string]: {
223
- params?: z.ZodTypeAny;
224
- query?: z.ZodTypeAny;
225
- body?: z.ZodTypeAny;
226
- };
227
- };
228
- /**
229
- * Optional OpenAPI metadata to generate documentation for the route.
230
- * Each key is an HTTP method name (in lowercase) and the value is an object
231
- * containing the OpenAPI metadata for that method.
232
- *
233
- * If the `openapi` property is not defined, the route will not be included in
234
- * the generated OpenAPI documentation.
235
- *
236
- * See the OpenAPI specification for the possible properties and their
237
- * descriptions.
238
- */
239
- export type openapi = {
240
- [method: string]: {
241
- summary?: string;
242
- description?: string;
243
- tags?: string[];
244
- operationId?: string;
245
- deprecated?: boolean;
246
- responses?: Record<string, any>;
247
- externalDocs?: {
248
- description?: string;
249
- url?: string;
250
- };
251
- };
252
- };
253
- export interface PageDefinition {
254
- path: string;
255
- handler: RequestHandler;
256
- middleware?: RequestHandler[];
257
- }
@@ -1 +0,0 @@
1
- import { z } from 'zod';