@nestify-js/shared 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 kasukabe tsumugi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,408 @@
1
+ # Nestify
2
+
3
+ [中文版本 README.zh.md](./README.zh.md)
4
+
5
+ > ⚠️ **Warning**: This is not an official release version. APIs may change in the future.
6
+
7
+ **Injecorator** is a portmanteau of "inject" and "decorator" - a dependency injection framework for Fastify that uses modern Stage 3 decorators instead of the legacy decorators used by NestJS.
8
+
9
+ This project was created because NestJS uses the old decorator syntax, but we wanted to leverage the new Stage 3 decorator specification for better type safety and modern JavaScript features.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add nestify-js
15
+ ```
16
+
17
+ ## API Documentation
18
+
19
+ Using of decorators looks basically like they are in NestJS, but with modern Stage 3 syntax.
20
+
21
+ > Note: It is recommended to set "strictPropertyInitialization": false in your tsconfig.json to avoid linting issues when using property injection.
22
+
23
+ ### HTTP Method Decorators
24
+
25
+ These decorators are used to define HTTP routes on controller methods:
26
+
27
+ ```typescript
28
+ import { Get, Post, Put, Patch, Delete, HttpMethod } from 'nestify-js';
29
+
30
+ @Controller('/api')
31
+ class UserController {
32
+ @Get('/users')
33
+ getUsers() {
34
+ return { users: [] };
35
+ }
36
+
37
+ @Post('/users')
38
+ createUser() {
39
+ return { message: 'User created' };
40
+ }
41
+
42
+ @Put('/users/:id')
43
+ updateUser() {
44
+ return { message: 'User updated' };
45
+ }
46
+
47
+ @Patch('/users/:id')
48
+ patchUser() {
49
+ return { message: 'User patched' };
50
+ }
51
+
52
+ @Delete('/users/:id')
53
+ deleteUser() {
54
+ return { message: 'User deleted' };
55
+ }
56
+
57
+ @(HttpMethod('OPTIONS')('/users'))
58
+ optionsUsers() {
59
+ return { methods: ['GET', 'POST'] };
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### Route Configuration
65
+
66
+ #### `@Controller(prefix?: string)`
67
+
68
+ Marks a class as a controller and optionally sets a route prefix:
69
+
70
+ ```typescript
71
+ @Controller('/api/v1')
72
+ class ApiController {
73
+ @Get('/health')
74
+ health() {
75
+ return { status: 'ok' };
76
+ }
77
+ }
78
+ // This creates route: GET /api/v1/health
79
+ ```
80
+
81
+ #### `@ApiSchema(schema)`
82
+
83
+ Sets OpenAPI/Swagger schema information for routes:
84
+
85
+ ```typescript
86
+ @Controller('/users')
87
+ class UserController {
88
+ @Get('/:id')
89
+ @ApiSchema({
90
+ summary: 'Get user by ID',
91
+ description: 'Retrieves a user by their unique identifier',
92
+ tags: ['users'],
93
+ })
94
+ getUser() {
95
+ return { user: {} };
96
+ }
97
+ }
98
+ ```
99
+
100
+ #### `@Opt(options)`
101
+
102
+ Sets additional Fastify route options:
103
+
104
+ ```typescript
105
+ @Controller('/files')
106
+ class FileController {
107
+ @Post('/upload')
108
+ @Opt({
109
+ bodyLimit: 1048576, // 1MB
110
+ attachValidation: true,
111
+ })
112
+ uploadFile() {
113
+ return { uploaded: true };
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Dependency Injection
119
+
120
+ #### `@Injectable()`
121
+
122
+ Marks a class as a service that can be injected:
123
+
124
+ ```typescript
125
+ @Injectable()
126
+ class UserService {
127
+ getUsers() {
128
+ return [{ id: 1, name: 'John' }];
129
+ }
130
+ }
131
+ ```
132
+
133
+ #### `@Inject(token)`
134
+
135
+ Injects dependencies into class properties:
136
+
137
+ ```typescript
138
+ @Injectable()
139
+ class UserController {
140
+ @Inject(UserService)
141
+ userService: UserService; // here might be linted by typescript, you can set "strictPropertyInitialization": false in tsconfig.json
142
+
143
+ @Inject('DATABASE_URL')
144
+ databaseUrl: string;
145
+
146
+ getUsers() {
147
+ return this.userService.getUsers();
148
+ }
149
+ }
150
+ ```
151
+
152
+ #### `@Module(options)`
153
+
154
+ Defines a module with providers, controllers, imports, and exports:
155
+
156
+ ```typescript
157
+ @Module({
158
+ imports: [DatabaseModule],
159
+ providers: [UserService],
160
+ controllers: [UserController],
161
+ exports: [UserService],
162
+ })
163
+ class UserModule {}
164
+ ```
165
+
166
+ ### Middleware System
167
+
168
+ #### Guards
169
+
170
+ Guards control access to routes:
171
+
172
+ ```typescript
173
+ @Guard()
174
+ class AuthGuard implements InjecoratorGuard {
175
+ canActivate(context: ExecutionContext): boolean {
176
+ const request = context.switchToHttp().getRequest();
177
+ return request.headers.authorization != null;
178
+ }
179
+ }
180
+
181
+ @Controller('/admin')
182
+ @UseGuards(AuthGuard)
183
+ class AdminController {
184
+ @Get('/dashboard')
185
+ getDashboard() {
186
+ return { data: 'sensitive' };
187
+ }
188
+ }
189
+ ```
190
+
191
+ #### Interceptors
192
+
193
+ Interceptors can modify request/response flow:
194
+
195
+ ```typescript
196
+ @Interceptor()
197
+ class LoggingInterceptor implements InjecoratorInterceptor {
198
+ intercept(context: ExecutionContext) {
199
+ const start = Date.now();
200
+ console.log('Request started');
201
+
202
+ return () => {
203
+ console.log(`Request completed in ${Date.now() - start}ms`);
204
+ };
205
+ }
206
+ }
207
+
208
+ @Controller('/api')
209
+ @UseInterceptors(LoggingInterceptor)
210
+ class ApiController {
211
+ @Get('/data')
212
+ getData() {
213
+ return { data: 'example' };
214
+ }
215
+ }
216
+ ```
217
+
218
+ #### Pipes
219
+
220
+ Pipes transform and validate input data:
221
+
222
+ ```typescript
223
+ @Pipe()
224
+ class ValidationPipe implements InjecoratorPipe {
225
+ transform(context: ExecutionContext, input: any[]) {
226
+ // Transform and validate input
227
+ return input;
228
+ }
229
+ }
230
+
231
+ @Controller('/users')
232
+ class UserController {
233
+ @Post('/')
234
+ @Body({ type: 'object', required: ['name', 'email'] })
235
+ createUser(@Body() body: any) {
236
+ return { user: body };
237
+ }
238
+
239
+ @Get('/')
240
+ @Query({ type: 'object' })
241
+ getUsers(@Query() query: any) {
242
+ return { users: [], query };
243
+ }
244
+
245
+ @Get('/:id')
246
+ @Params({ type: 'object', required: ['id'] })
247
+ getUser(@Params() params: any) {
248
+ return { user: { id: params.id } };
249
+ }
250
+
251
+ @Get('/ip')
252
+ getUserIP(@Ip() ip: string) {
253
+ return { ip };
254
+ }
255
+
256
+ @Post('/raw')
257
+ handleRaw(@Raw() raw: any) {
258
+ return { received: true };
259
+ }
260
+ }
261
+ ```
262
+
263
+ #### Filters
264
+
265
+ Filters handle exceptions:
266
+
267
+ ```typescript
268
+ @Filter(HttpException)
269
+ class HttpExceptionFilter implements InjecoratorFilter {
270
+ catch(exception: HttpException, context: ExecutionContext) {
271
+ const response = context.switchToHttp().getReply();
272
+ response.status(exception.status).send({
273
+ error: exception.message,
274
+ timestamp: new Date().toISOString(),
275
+ });
276
+ }
277
+ }
278
+
279
+ @Controller('/api')
280
+ @UseFilters(HttpExceptionFilter)
281
+ class ApiController {
282
+ @Get('/error')
283
+ throwError() {
284
+ throw new HttpException('Something went wrong', 400);
285
+ }
286
+ }
287
+ ```
288
+
289
+ ## Complete Usage Example
290
+
291
+ ```typescript
292
+ import fastify from 'fastify';
293
+ import {
294
+ Module,
295
+ Controller,
296
+ Injectable,
297
+ Inject,
298
+ Get,
299
+ Post,
300
+ Body,
301
+ Params,
302
+ UseGuards,
303
+ Guard,
304
+ apply,
305
+ } from 'nestify-js';
306
+
307
+ // Service
308
+ @Injectable()
309
+ class UserService {
310
+ private users = [
311
+ { id: 1, name: 'Alice' },
312
+ { id: 2, name: 'Bob' },
313
+ ];
314
+
315
+ getUsers() {
316
+ return this.users;
317
+ }
318
+
319
+ getUserById(id: number) {
320
+ return this.users.find((user) => user.id === id);
321
+ }
322
+
323
+ createUser(userData: { name: string }) {
324
+ const user = { id: Date.now(), ...userData };
325
+ this.users.push(user);
326
+ return user;
327
+ }
328
+ }
329
+
330
+ // Guard
331
+ @Guard()
332
+ class AuthGuard {
333
+ canActivate(context) {
334
+ // Simple auth check
335
+ const request = context.switchToHttp().getRequest();
336
+ return request.headers.authorization === 'Bearer valid-token';
337
+ }
338
+ }
339
+
340
+ // Controller
341
+ @Controller('/api/users')
342
+ class UserController {
343
+ @Inject(UserService)
344
+ userService: UserService;
345
+
346
+ @Get('/')
347
+ getUsers() {
348
+ return this.userService.getUsers();
349
+ }
350
+
351
+ @Get('/:id')
352
+ @Params({
353
+ type: 'object',
354
+ properties: { id: { type: 'number' } },
355
+ required: ['id'],
356
+ })
357
+ getUser(@Params() params: { id: number }) {
358
+ return this.userService.getUserById(params.id);
359
+ }
360
+
361
+ @Post('/')
362
+ @UseGuards(AuthGuard)
363
+ @Body({
364
+ type: 'object',
365
+ properties: { name: { type: 'string' } },
366
+ required: ['name'],
367
+ })
368
+ createUser(@Body() body: { name: string }) {
369
+ return this.userService.createUser(body);
370
+ }
371
+ }
372
+
373
+ // Module
374
+ @Module({
375
+ providers: [UserService, AuthGuard],
376
+ controllers: [UserController],
377
+ })
378
+ class AppModule {}
379
+
380
+ // Application setup
381
+ const app = fastify({ logger: true });
382
+
383
+ await apply(app, {
384
+ rootModule: AppModule,
385
+ });
386
+
387
+ await app.listen({ port: 3000 });
388
+ console.log('Server running on http://localhost:3000');
389
+ ```
390
+
391
+ ## Features
392
+
393
+ - ✅ Modern Stage 3 decorators
394
+ - ✅ Dependency injection with circular dependency support
395
+ - ✅ HTTP method decorators (GET, POST, PUT, PATCH, DELETE)
396
+ - ✅ Route parameters, query, and body validation
397
+ - ✅ Guards for authentication/authorization
398
+ - ✅ Interceptors for request/response transformation
399
+ - ✅ Pipes for data transformation and validation
400
+ - ✅ Exception filters
401
+ - ✅ Module system with imports/exports
402
+ - ✅ OpenAPI/Swagger schema support
403
+ - ✅ Built-in HTTP exceptions
404
+ - ✅ Execution context for middleware
405
+
406
+ ## License
407
+
408
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@nestify-js/shared");const t=Symbol(`APP_LOGGER`),n=Symbol(`APP_INTERCEPTOR`),r=Symbol(`APP_FILTER`),i=Symbol(`APP_GUARD`),a=Symbol(`APP_PIPE`),o=Function.prototype.toString,s=Array.isArray,c=Object.entries,l=Object.values,u=Object.defineProperty,d=Object.assign,f=Reflect.get,p=Reflect.set,m=Reflect.has,h=Reflect.construct,g=Reflect.ownKeys,_=Reflect.getPrototypeOf;function v(e,t,...n){try{let r=e.apply(t,n);return typeof r?.then==`function`?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}let y;(function(e){e.metadata=Symbol.metadata??Symbol.for(`Symbol.metadata`),e.none=Symbol(`none`),e.root=Symbol(`root`),e.module=Symbol(`module`),e.provider=Symbol(`provider`),e.controller=Symbol(`controller`),e.injection=Symbol(`injection`);let t;(function(e){e.root=Symbol(`route`),e.base=Symbol(`base`),e.opt=Symbol(`opt`),e.apiSchema=Symbol(`apiSchema`),e.args=Symbol(`args`)})(t||=e.route||={});let n;(function(e){e.root=Symbol(`interceptor`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(n||=e.interceptor||={});let r;(function(e){e.root=Symbol(`guard`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(r||=e.guard||={});let i;(function(e){e.root=Symbol(`filter`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(i||=e.filter||={});let a;(function(e){e.root=Symbol(`pipe`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(a||=e.pipe||={});let o;(function(e){e.root=Symbol(`custom`),e.method=Symbol(`method`),e.field=Symbol(`field`)})(o||=e.custom||={}),e.cron=Symbol(`cron`),e.file=Symbol(`file`),e.user=Symbol(`user`)})(y||={});let b=function(e){return e[e.CONTINUE=100]=`CONTINUE`,e[e.SWITCHING_PROTOCOLS=101]=`SWITCHING_PROTOCOLS`,e[e.PROCESSING=102]=`PROCESSING`,e[e.EARLY_HINTS=103]=`EARLY_HINTS`,e[e.OK=200]=`OK`,e[e.CREATED=201]=`CREATED`,e[e.ACCEPTED=202]=`ACCEPTED`,e[e.NON_AUTHORITATIVE_INFORMATION=203]=`NON_AUTHORITATIVE_INFORMATION`,e[e.NO_CONTENT=204]=`NO_CONTENT`,e[e.RESET_CONTENT=205]=`RESET_CONTENT`,e[e.PARTIAL_CONTENT=206]=`PARTIAL_CONTENT`,e[e.MULTI_STATUS=207]=`MULTI_STATUS`,e[e.MULTIPLE_CHOICES=300]=`MULTIPLE_CHOICES`,e[e.MOVED_PERMANENTLY=301]=`MOVED_PERMANENTLY`,e[e.MOVED_TEMPORARILY=302]=`MOVED_TEMPORARILY`,e[e.SEE_OTHER=303]=`SEE_OTHER`,e[e.NOT_MODIFIED=304]=`NOT_MODIFIED`,e[e.USE_PROXY=305]=`USE_PROXY`,e[e.TEMPORARY_REDIRECT=307]=`TEMPORARY_REDIRECT`,e[e.PERMANENT_REDIRECT=308]=`PERMANENT_REDIRECT`,e[e.BAD_REQUEST=400]=`BAD_REQUEST`,e[e.UNAUTHORIZED=401]=`UNAUTHORIZED`,e[e.PAYMENT_REQUIRED=402]=`PAYMENT_REQUIRED`,e[e.FORBIDDEN=403]=`FORBIDDEN`,e[e.NOT_FOUND=404]=`NOT_FOUND`,e[e.METHOD_NOT_ALLOWED=405]=`METHOD_NOT_ALLOWED`,e[e.NOT_ACCEPTABLE=406]=`NOT_ACCEPTABLE`,e[e.PROXY_AUTHENTICATION_REQUIRED=407]=`PROXY_AUTHENTICATION_REQUIRED`,e[e.REQUEST_TIMEOUT=408]=`REQUEST_TIMEOUT`,e[e.CONFLICT=409]=`CONFLICT`,e[e.GONE=410]=`GONE`,e[e.LENGTH_REQUIRED=411]=`LENGTH_REQUIRED`,e[e.PRECONDITION_FAILED=412]=`PRECONDITION_FAILED`,e[e.REQUEST_TOO_LONG=413]=`REQUEST_TOO_LONG`,e[e.REQUEST_URI_TOO_LONG=414]=`REQUEST_URI_TOO_LONG`,e[e.UNSUPPORTED_MEDIA_TYPE=415]=`UNSUPPORTED_MEDIA_TYPE`,e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]=`REQUESTED_RANGE_NOT_SATISFIABLE`,e[e.EXPECTATION_FAILED=417]=`EXPECTATION_FAILED`,e[e.IM_A_TEAPOT=418]=`IM_A_TEAPOT`,e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]=`INSUFFICIENT_SPACE_ON_RESOURCE`,e[e.METHOD_FAILURE=420]=`METHOD_FAILURE`,e[e.MISDIRECTED_REQUEST=421]=`MISDIRECTED_REQUEST`,e[e.UNPROCESSABLE_ENTITY=422]=`UNPROCESSABLE_ENTITY`,e[e.LOCKED=423]=`LOCKED`,e[e.FAILED_DEPENDENCY=424]=`FAILED_DEPENDENCY`,e[e.UPGRADE_REQUIRED=426]=`UPGRADE_REQUIRED`,e[e.PRECONDITION_REQUIRED=428]=`PRECONDITION_REQUIRED`,e[e.TOO_MANY_REQUESTS=429]=`TOO_MANY_REQUESTS`,e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]=`REQUEST_HEADER_FIELDS_TOO_LARGE`,e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]=`UNAVAILABLE_FOR_LEGAL_REASONS`,e[e.INTERNAL_SERVER_ERROR=500]=`INTERNAL_SERVER_ERROR`,e[e.NOT_IMPLEMENTED=501]=`NOT_IMPLEMENTED`,e[e.BAD_GATEWAY=502]=`BAD_GATEWAY`,e[e.SERVICE_UNAVAILABLE=503]=`SERVICE_UNAVAILABLE`,e[e.GATEWAY_TIMEOUT=504]=`GATEWAY_TIMEOUT`,e[e.HTTP_VERSION_NOT_SUPPORTED=505]=`HTTP_VERSION_NOT_SUPPORTED`,e[e.INSUFFICIENT_STORAGE=507]=`INSUFFICIENT_STORAGE`,e[e.NETWORK_AUTHENTICATION_REQUIRED=511]=`NETWORK_AUTHENTICATION_REQUIRED`,e}({});const x=(...e)=>e.length===0?[]:e.filter(Array.isArray).flat(),S=(...e)=>Object.assign({},...e.filter(e=>e&&typeof e==`object`));function C(t,n){if(t===n)return!0;for(let r=(0,e._getPrototypeOf)(t);r&&r!==Function.prototype;r=(0,e._getPrototypeOf)(r))if(r===n)return!0;return!1}exports.APP_FILTER=r,exports.APP_GUARD=i,exports.APP_INTERCEPTOR=n,exports.APP_LOGGER=t,exports.APP_PIPE=a,exports.HttpStatus=b,exports._assign=d,exports._construct=h,exports._define=u,exports._entries=c,exports._fnToString=o,exports._get=f,exports._getPrototypeOf=_,exports._has=m,exports._isArray=s,exports._ownKeys=g,exports._set=p,exports._values=l,exports.concatArr=x,exports.promiseTry=v,exports.subclassOf=C,Object.defineProperty(exports,"sym",{enumerable:!0,get:function(){return y}}),exports.toAssigned=S;
@@ -0,0 +1,321 @@
1
+ //#region src/consts.d.ts
2
+ declare const APP_LOGGER: unique symbol;
3
+ declare const APP_INTERCEPTOR: unique symbol;
4
+ declare const APP_FILTER: unique symbol;
5
+ declare const APP_GUARD: unique symbol;
6
+ declare const APP_PIPE: unique symbol;
7
+ //#endregion
8
+ //#region src/native.d.ts
9
+ declare const _fnToString: () => string;
10
+ declare const _isArray: (arg: any) => arg is any[];
11
+ declare const _entries: {
12
+ <T>(o: {
13
+ [s: string]: T;
14
+ } | ArrayLike<T>): [string, T][];
15
+ (o: {}): [string, any][];
16
+ };
17
+ declare const _values: {
18
+ <T>(o: {
19
+ [s: string]: T;
20
+ } | ArrayLike<T>): T[];
21
+ (o: {}): any[];
22
+ };
23
+ declare const _define: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
24
+ declare const _assign: {
25
+ <T extends {}, U>(target: T, source: U): T & U;
26
+ <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
27
+ <T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
28
+ (target: object, ...sources: any[]): any;
29
+ };
30
+ declare const _get: typeof Reflect.get;
31
+ declare const _set: typeof Reflect.set;
32
+ declare const _has: typeof Reflect.has;
33
+ declare const _construct: typeof Reflect.construct;
34
+ declare const _ownKeys: typeof Reflect.ownKeys;
35
+ declare const _getPrototypeOf: typeof Reflect.getPrototypeOf;
36
+ //#endregion
37
+ //#region src/promise-try.d.ts
38
+ declare function promiseTry<T>(fn: (...args: unknown[]) => T, thisArg?: unknown, ...args: unknown[]): Promise<T>;
39
+ //#endregion
40
+ //#region src/sym.d.ts
41
+ /**
42
+ * Property keys used to store metadata.
43
+ */
44
+ declare namespace sym {
45
+ /**
46
+ * Polyfill for stage2 proposal: Symbol.metadata.
47
+ * - obj[Symbol.metadata] stores metadata for decorators.
48
+ * @see https://github.com/tc39/proposal-decorator-metadata
49
+ */
50
+ const metadata: symbol;
51
+ const none: unique symbol;
52
+ const root: unique symbol;
53
+ /**
54
+ * Stores the `module` information.
55
+ */
56
+ const module: unique symbol;
57
+ /**
58
+ * Stores the `provider` information.
59
+ */
60
+ const provider: unique symbol;
61
+ /**
62
+ * Stores the `controller` information.
63
+ */
64
+ const controller: unique symbol;
65
+ /**
66
+ * Stores injection information for fields.
67
+ * - This is used to inject dependencies into fields of a class.
68
+ * - The value is an object with the dependency class and other metadata.
69
+ */
70
+ const injection: unique symbol;
71
+ namespace route {
72
+ /**
73
+ * Stores route metadata
74
+ */
75
+ const root: unique symbol;
76
+ /**
77
+ * Stores basic route options with interface `RouteBasic`
78
+ */
79
+ const base: unique symbol;
80
+ /**
81
+ * Stores route options of `fastify.route(opts)`
82
+ * - Priority: `opts.schema` < `Symbol(RouteApiSchema)` < `@Pipe({ schema })`
83
+ */
84
+ const opt: unique symbol;
85
+ /**
86
+ * Stores info schema like `summary`, `description`, etc. for swagger
87
+ * - Priority: `opts.schema` < `Symbol(RouteApiSchema)` < `@Pipe({ schema })`
88
+ */
89
+ const apiSchema: unique symbol;
90
+ /**
91
+ * Stores property paths of the handler argument `request: FastifyRequest`
92
+ * - if the handler is decorated by `@Args('body.name','body.age')`, then the handler will be called as `handler(request.body.name, request.body.age, reply)`
93
+ * - `reply` will always be the last argument
94
+ */
95
+ const args: unique symbol;
96
+ }
97
+ namespace interceptor {
98
+ /**
99
+ * Identify this class as an interceptor
100
+ */
101
+ const root: unique symbol;
102
+ /**
103
+ * Stores interceptors with controller level
104
+ */
105
+ const controller: unique symbol;
106
+ /**
107
+ * Stores interceptors with handler level
108
+ */
109
+ const handler: unique symbol;
110
+ }
111
+ namespace guard {
112
+ /**
113
+ * Identify this class as a guard
114
+ */
115
+ const root: unique symbol;
116
+ /**
117
+ * Stores guards with controller level
118
+ */
119
+ const controller: unique symbol;
120
+ /**
121
+ * Stores guards with handler level
122
+ */
123
+ const handler: unique symbol;
124
+ }
125
+ namespace filter {
126
+ /**
127
+ * Identify this class as a filter
128
+ */
129
+ const root: unique symbol;
130
+ /**
131
+ * Stores filters with controller level
132
+ */
133
+ const controller: unique symbol;
134
+ /**
135
+ * Stores filters with handler level
136
+ */
137
+ const handler: unique symbol;
138
+ }
139
+ namespace pipe {
140
+ /**
141
+ * Identify this class as a pipe
142
+ */
143
+ const root: unique symbol;
144
+ /**
145
+ * Stores pipes with controller level
146
+ */
147
+ const controller: unique symbol;
148
+ /**
149
+ * Stores pipes with handler level
150
+ */
151
+ const handler: unique symbol;
152
+ }
153
+ namespace custom {
154
+ /**
155
+ * Custom metadata stored in this field
156
+ */
157
+ const root: unique symbol;
158
+ /**
159
+ * Custom metadata stored in this field
160
+ */
161
+ const method: unique symbol;
162
+ /**
163
+ * Custom metadata stored in this field
164
+ */
165
+ const field: unique symbol;
166
+ }
167
+ const cron: unique symbol;
168
+ /**
169
+ * Stores file upload metadata for multipart/form-data
170
+ */
171
+ const file: unique symbol;
172
+ /**
173
+ * Stores authenticated user on FastifyRequest
174
+ * - Used by authentication guards to attach user info to request
175
+ */
176
+ const user: unique symbol;
177
+ }
178
+ //#endregion
179
+ //#region src/status.d.ts
180
+ /**
181
+ * Common HTTP status codes
182
+ */
183
+ declare const enum HttpStatus {
184
+ /** Continue */
185
+ CONTINUE = 100,
186
+ /** Switching Protocols */
187
+ SWITCHING_PROTOCOLS = 101,
188
+ /** Processing */
189
+ PROCESSING = 102,
190
+ /** Early Hints */
191
+ EARLY_HINTS = 103,
192
+ /** OK */
193
+ OK = 200,
194
+ /** Created */
195
+ CREATED = 201,
196
+ /** Accepted */
197
+ ACCEPTED = 202,
198
+ /** Non Authoritative Information */
199
+ NON_AUTHORITATIVE_INFORMATION = 203,
200
+ /** No Content */
201
+ NO_CONTENT = 204,
202
+ /** Reset Content */
203
+ RESET_CONTENT = 205,
204
+ /** Partial Content */
205
+ PARTIAL_CONTENT = 206,
206
+ /** Multi-Status */
207
+ MULTI_STATUS = 207,
208
+ /** Multiple Choices */
209
+ MULTIPLE_CHOICES = 300,
210
+ /** Moved Permanently */
211
+ MOVED_PERMANENTLY = 301,
212
+ /** Moved Temporarily */
213
+ MOVED_TEMPORARILY = 302,
214
+ /** See Other */
215
+ SEE_OTHER = 303,
216
+ /** Not Modified */
217
+ NOT_MODIFIED = 304,
218
+ /** Use Proxy */
219
+ USE_PROXY = 305,
220
+ /** Temporary Redirect */
221
+ TEMPORARY_REDIRECT = 307,
222
+ /** Permanent Redirect */
223
+ PERMANENT_REDIRECT = 308,
224
+ /** Bad Request */
225
+ BAD_REQUEST = 400,
226
+ /** Unauthorized */
227
+ UNAUTHORIZED = 401,
228
+ /** Payment Required */
229
+ PAYMENT_REQUIRED = 402,
230
+ /** Forbidden */
231
+ FORBIDDEN = 403,
232
+ /** Not Found */
233
+ NOT_FOUND = 404,
234
+ /** Method Not Allowed */
235
+ METHOD_NOT_ALLOWED = 405,
236
+ /** Not Acceptable */
237
+ NOT_ACCEPTABLE = 406,
238
+ /** Proxy Authentication Required */
239
+ PROXY_AUTHENTICATION_REQUIRED = 407,
240
+ /** Request Timeout */
241
+ REQUEST_TIMEOUT = 408,
242
+ /** Conflict */
243
+ CONFLICT = 409,
244
+ /** Gone */
245
+ GONE = 410,
246
+ /** Length Required */
247
+ LENGTH_REQUIRED = 411,
248
+ /** Precondition Failed */
249
+ PRECONDITION_FAILED = 412,
250
+ /** Request Entity Too Large */
251
+ REQUEST_TOO_LONG = 413,
252
+ /** Request-URI Too Long */
253
+ REQUEST_URI_TOO_LONG = 414,
254
+ /** Unsupported Media Type */
255
+ UNSUPPORTED_MEDIA_TYPE = 415,
256
+ /** Requested Range Not Satisfiable */
257
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
258
+ /** Expectation Failed */
259
+ EXPECTATION_FAILED = 417,
260
+ /** I'm a teapot */
261
+ IM_A_TEAPOT = 418,
262
+ /** Insufficient Space on Resource */
263
+ INSUFFICIENT_SPACE_ON_RESOURCE = 419,
264
+ /** Method Failure */
265
+ METHOD_FAILURE = 420,
266
+ /** Misdirected Request */
267
+ MISDIRECTED_REQUEST = 421,
268
+ /** Unprocessable Entity */
269
+ UNPROCESSABLE_ENTITY = 422,
270
+ /** Locked */
271
+ LOCKED = 423,
272
+ /** Failed Dependency */
273
+ FAILED_DEPENDENCY = 424,
274
+ /** Upgrade Required */
275
+ UPGRADE_REQUIRED = 426,
276
+ /** Precondition Required */
277
+ PRECONDITION_REQUIRED = 428,
278
+ /** Too Many Requests */
279
+ TOO_MANY_REQUESTS = 429,
280
+ /** Request Header Fields Too Large */
281
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
282
+ /** Unavailable For Legal Reasons */
283
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
284
+ /** Internal Server Error */
285
+ INTERNAL_SERVER_ERROR = 500,
286
+ /** Not Implemented */
287
+ NOT_IMPLEMENTED = 501,
288
+ /** Bad Gateway */
289
+ BAD_GATEWAY = 502,
290
+ /** Service Unavailable */
291
+ SERVICE_UNAVAILABLE = 503,
292
+ /** Gateway Timeout */
293
+ GATEWAY_TIMEOUT = 504,
294
+ /** HTTP Version Not Supported */
295
+ HTTP_VERSION_NOT_SUPPORTED = 505,
296
+ /** Insufficient Storage */
297
+ INSUFFICIENT_STORAGE = 507,
298
+ /** Network Authentication Required */
299
+ NETWORK_AUTHENTICATION_REQUIRED = 511
300
+ }
301
+ //#endregion
302
+ //#region src/types/primitive.d.ts
303
+ type Func = (...args: any[]) => any;
304
+ type Constructable<T = any> = new (...args: any[]) => T;
305
+ type Key = string | symbol;
306
+ type Satisfied = any;
307
+ type OrPromise<T = void> = T | Promise<T>;
308
+ //#endregion
309
+ //#region src/utils.d.ts
310
+ type ArrValue<T> = T extends readonly (infer U)[] ? U : never;
311
+ declare const concatArr: <T extends readonly unknown[]>(...args: (T | undefined)[]) => ArrValue<T>[];
312
+ declare const toAssigned: (...args: (object | symbol | undefined)[]) => any;
313
+ /**
314
+ * Like `instanceof`, but works with classes that are not instantiated.
315
+ * - Returns `true` if they are the same class.
316
+ * @param subClass The class to check
317
+ * @param superClass The potential parent class
318
+ */
319
+ declare function subclassOf(subClass: Constructable, superClass: Constructable): boolean;
320
+ //#endregion
321
+ export { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_LOGGER, APP_PIPE, type Constructable, type Func, HttpStatus, type Key, type OrPromise, type Satisfied, _assign, _construct, _define, _entries, _fnToString, _get, _getPrototypeOf, _has, _isArray, _ownKeys, _set, _values, concatArr, promiseTry, subclassOf, sym, toAssigned };
@@ -0,0 +1,321 @@
1
+ //#region src/consts.d.ts
2
+ declare const APP_LOGGER: unique symbol;
3
+ declare const APP_INTERCEPTOR: unique symbol;
4
+ declare const APP_FILTER: unique symbol;
5
+ declare const APP_GUARD: unique symbol;
6
+ declare const APP_PIPE: unique symbol;
7
+ //#endregion
8
+ //#region src/native.d.ts
9
+ declare const _fnToString: () => string;
10
+ declare const _isArray: (arg: any) => arg is any[];
11
+ declare const _entries: {
12
+ <T>(o: {
13
+ [s: string]: T;
14
+ } | ArrayLike<T>): [string, T][];
15
+ (o: {}): [string, any][];
16
+ };
17
+ declare const _values: {
18
+ <T>(o: {
19
+ [s: string]: T;
20
+ } | ArrayLike<T>): T[];
21
+ (o: {}): any[];
22
+ };
23
+ declare const _define: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
24
+ declare const _assign: {
25
+ <T extends {}, U>(target: T, source: U): T & U;
26
+ <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
27
+ <T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
28
+ (target: object, ...sources: any[]): any;
29
+ };
30
+ declare const _get: typeof Reflect.get;
31
+ declare const _set: typeof Reflect.set;
32
+ declare const _has: typeof Reflect.has;
33
+ declare const _construct: typeof Reflect.construct;
34
+ declare const _ownKeys: typeof Reflect.ownKeys;
35
+ declare const _getPrototypeOf: typeof Reflect.getPrototypeOf;
36
+ //#endregion
37
+ //#region src/promise-try.d.ts
38
+ declare function promiseTry<T>(fn: (...args: unknown[]) => T, thisArg?: unknown, ...args: unknown[]): Promise<T>;
39
+ //#endregion
40
+ //#region src/sym.d.ts
41
+ /**
42
+ * Property keys used to store metadata.
43
+ */
44
+ declare namespace sym {
45
+ /**
46
+ * Polyfill for stage2 proposal: Symbol.metadata.
47
+ * - obj[Symbol.metadata] stores metadata for decorators.
48
+ * @see https://github.com/tc39/proposal-decorator-metadata
49
+ */
50
+ const metadata: symbol;
51
+ const none: unique symbol;
52
+ const root: unique symbol;
53
+ /**
54
+ * Stores the `module` information.
55
+ */
56
+ const module: unique symbol;
57
+ /**
58
+ * Stores the `provider` information.
59
+ */
60
+ const provider: unique symbol;
61
+ /**
62
+ * Stores the `controller` information.
63
+ */
64
+ const controller: unique symbol;
65
+ /**
66
+ * Stores injection information for fields.
67
+ * - This is used to inject dependencies into fields of a class.
68
+ * - The value is an object with the dependency class and other metadata.
69
+ */
70
+ const injection: unique symbol;
71
+ namespace route {
72
+ /**
73
+ * Stores route metadata
74
+ */
75
+ const root: unique symbol;
76
+ /**
77
+ * Stores basic route options with interface `RouteBasic`
78
+ */
79
+ const base: unique symbol;
80
+ /**
81
+ * Stores route options of `fastify.route(opts)`
82
+ * - Priority: `opts.schema` < `Symbol(RouteApiSchema)` < `@Pipe({ schema })`
83
+ */
84
+ const opt: unique symbol;
85
+ /**
86
+ * Stores info schema like `summary`, `description`, etc. for swagger
87
+ * - Priority: `opts.schema` < `Symbol(RouteApiSchema)` < `@Pipe({ schema })`
88
+ */
89
+ const apiSchema: unique symbol;
90
+ /**
91
+ * Stores property paths of the handler argument `request: FastifyRequest`
92
+ * - if the handler is decorated by `@Args('body.name','body.age')`, then the handler will be called as `handler(request.body.name, request.body.age, reply)`
93
+ * - `reply` will always be the last argument
94
+ */
95
+ const args: unique symbol;
96
+ }
97
+ namespace interceptor {
98
+ /**
99
+ * Identify this class as an interceptor
100
+ */
101
+ const root: unique symbol;
102
+ /**
103
+ * Stores interceptors with controller level
104
+ */
105
+ const controller: unique symbol;
106
+ /**
107
+ * Stores interceptors with handler level
108
+ */
109
+ const handler: unique symbol;
110
+ }
111
+ namespace guard {
112
+ /**
113
+ * Identify this class as a guard
114
+ */
115
+ const root: unique symbol;
116
+ /**
117
+ * Stores guards with controller level
118
+ */
119
+ const controller: unique symbol;
120
+ /**
121
+ * Stores guards with handler level
122
+ */
123
+ const handler: unique symbol;
124
+ }
125
+ namespace filter {
126
+ /**
127
+ * Identify this class as a filter
128
+ */
129
+ const root: unique symbol;
130
+ /**
131
+ * Stores filters with controller level
132
+ */
133
+ const controller: unique symbol;
134
+ /**
135
+ * Stores filters with handler level
136
+ */
137
+ const handler: unique symbol;
138
+ }
139
+ namespace pipe {
140
+ /**
141
+ * Identify this class as a pipe
142
+ */
143
+ const root: unique symbol;
144
+ /**
145
+ * Stores pipes with controller level
146
+ */
147
+ const controller: unique symbol;
148
+ /**
149
+ * Stores pipes with handler level
150
+ */
151
+ const handler: unique symbol;
152
+ }
153
+ namespace custom {
154
+ /**
155
+ * Custom metadata stored in this field
156
+ */
157
+ const root: unique symbol;
158
+ /**
159
+ * Custom metadata stored in this field
160
+ */
161
+ const method: unique symbol;
162
+ /**
163
+ * Custom metadata stored in this field
164
+ */
165
+ const field: unique symbol;
166
+ }
167
+ const cron: unique symbol;
168
+ /**
169
+ * Stores file upload metadata for multipart/form-data
170
+ */
171
+ const file: unique symbol;
172
+ /**
173
+ * Stores authenticated user on FastifyRequest
174
+ * - Used by authentication guards to attach user info to request
175
+ */
176
+ const user: unique symbol;
177
+ }
178
+ //#endregion
179
+ //#region src/status.d.ts
180
+ /**
181
+ * Common HTTP status codes
182
+ */
183
+ declare const enum HttpStatus {
184
+ /** Continue */
185
+ CONTINUE = 100,
186
+ /** Switching Protocols */
187
+ SWITCHING_PROTOCOLS = 101,
188
+ /** Processing */
189
+ PROCESSING = 102,
190
+ /** Early Hints */
191
+ EARLY_HINTS = 103,
192
+ /** OK */
193
+ OK = 200,
194
+ /** Created */
195
+ CREATED = 201,
196
+ /** Accepted */
197
+ ACCEPTED = 202,
198
+ /** Non Authoritative Information */
199
+ NON_AUTHORITATIVE_INFORMATION = 203,
200
+ /** No Content */
201
+ NO_CONTENT = 204,
202
+ /** Reset Content */
203
+ RESET_CONTENT = 205,
204
+ /** Partial Content */
205
+ PARTIAL_CONTENT = 206,
206
+ /** Multi-Status */
207
+ MULTI_STATUS = 207,
208
+ /** Multiple Choices */
209
+ MULTIPLE_CHOICES = 300,
210
+ /** Moved Permanently */
211
+ MOVED_PERMANENTLY = 301,
212
+ /** Moved Temporarily */
213
+ MOVED_TEMPORARILY = 302,
214
+ /** See Other */
215
+ SEE_OTHER = 303,
216
+ /** Not Modified */
217
+ NOT_MODIFIED = 304,
218
+ /** Use Proxy */
219
+ USE_PROXY = 305,
220
+ /** Temporary Redirect */
221
+ TEMPORARY_REDIRECT = 307,
222
+ /** Permanent Redirect */
223
+ PERMANENT_REDIRECT = 308,
224
+ /** Bad Request */
225
+ BAD_REQUEST = 400,
226
+ /** Unauthorized */
227
+ UNAUTHORIZED = 401,
228
+ /** Payment Required */
229
+ PAYMENT_REQUIRED = 402,
230
+ /** Forbidden */
231
+ FORBIDDEN = 403,
232
+ /** Not Found */
233
+ NOT_FOUND = 404,
234
+ /** Method Not Allowed */
235
+ METHOD_NOT_ALLOWED = 405,
236
+ /** Not Acceptable */
237
+ NOT_ACCEPTABLE = 406,
238
+ /** Proxy Authentication Required */
239
+ PROXY_AUTHENTICATION_REQUIRED = 407,
240
+ /** Request Timeout */
241
+ REQUEST_TIMEOUT = 408,
242
+ /** Conflict */
243
+ CONFLICT = 409,
244
+ /** Gone */
245
+ GONE = 410,
246
+ /** Length Required */
247
+ LENGTH_REQUIRED = 411,
248
+ /** Precondition Failed */
249
+ PRECONDITION_FAILED = 412,
250
+ /** Request Entity Too Large */
251
+ REQUEST_TOO_LONG = 413,
252
+ /** Request-URI Too Long */
253
+ REQUEST_URI_TOO_LONG = 414,
254
+ /** Unsupported Media Type */
255
+ UNSUPPORTED_MEDIA_TYPE = 415,
256
+ /** Requested Range Not Satisfiable */
257
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
258
+ /** Expectation Failed */
259
+ EXPECTATION_FAILED = 417,
260
+ /** I'm a teapot */
261
+ IM_A_TEAPOT = 418,
262
+ /** Insufficient Space on Resource */
263
+ INSUFFICIENT_SPACE_ON_RESOURCE = 419,
264
+ /** Method Failure */
265
+ METHOD_FAILURE = 420,
266
+ /** Misdirected Request */
267
+ MISDIRECTED_REQUEST = 421,
268
+ /** Unprocessable Entity */
269
+ UNPROCESSABLE_ENTITY = 422,
270
+ /** Locked */
271
+ LOCKED = 423,
272
+ /** Failed Dependency */
273
+ FAILED_DEPENDENCY = 424,
274
+ /** Upgrade Required */
275
+ UPGRADE_REQUIRED = 426,
276
+ /** Precondition Required */
277
+ PRECONDITION_REQUIRED = 428,
278
+ /** Too Many Requests */
279
+ TOO_MANY_REQUESTS = 429,
280
+ /** Request Header Fields Too Large */
281
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
282
+ /** Unavailable For Legal Reasons */
283
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
284
+ /** Internal Server Error */
285
+ INTERNAL_SERVER_ERROR = 500,
286
+ /** Not Implemented */
287
+ NOT_IMPLEMENTED = 501,
288
+ /** Bad Gateway */
289
+ BAD_GATEWAY = 502,
290
+ /** Service Unavailable */
291
+ SERVICE_UNAVAILABLE = 503,
292
+ /** Gateway Timeout */
293
+ GATEWAY_TIMEOUT = 504,
294
+ /** HTTP Version Not Supported */
295
+ HTTP_VERSION_NOT_SUPPORTED = 505,
296
+ /** Insufficient Storage */
297
+ INSUFFICIENT_STORAGE = 507,
298
+ /** Network Authentication Required */
299
+ NETWORK_AUTHENTICATION_REQUIRED = 511
300
+ }
301
+ //#endregion
302
+ //#region src/types/primitive.d.ts
303
+ type Func = (...args: any[]) => any;
304
+ type Constructable<T = any> = new (...args: any[]) => T;
305
+ type Key = string | symbol;
306
+ type Satisfied = any;
307
+ type OrPromise<T = void> = T | Promise<T>;
308
+ //#endregion
309
+ //#region src/utils.d.ts
310
+ type ArrValue<T> = T extends readonly (infer U)[] ? U : never;
311
+ declare const concatArr: <T extends readonly unknown[]>(...args: (T | undefined)[]) => ArrValue<T>[];
312
+ declare const toAssigned: (...args: (object | symbol | undefined)[]) => any;
313
+ /**
314
+ * Like `instanceof`, but works with classes that are not instantiated.
315
+ * - Returns `true` if they are the same class.
316
+ * @param subClass The class to check
317
+ * @param superClass The potential parent class
318
+ */
319
+ declare function subclassOf(subClass: Constructable, superClass: Constructable): boolean;
320
+ //#endregion
321
+ export { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_LOGGER, APP_PIPE, type Constructable, type Func, HttpStatus, type Key, type OrPromise, type Satisfied, _assign, _construct, _define, _entries, _fnToString, _get, _getPrototypeOf, _has, _isArray, _ownKeys, _set, _values, concatArr, promiseTry, subclassOf, sym, toAssigned };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{_getPrototypeOf as e}from"@nestify-js/shared";const t=Symbol(`APP_LOGGER`),n=Symbol(`APP_INTERCEPTOR`),r=Symbol(`APP_FILTER`),i=Symbol(`APP_GUARD`),a=Symbol(`APP_PIPE`),o=Function.prototype.toString,s=Array.isArray,c=Object.entries,l=Object.values,u=Object.defineProperty,d=Object.assign,f=Reflect.get,p=Reflect.set,m=Reflect.has,h=Reflect.construct,g=Reflect.ownKeys,_=Reflect.getPrototypeOf;function v(e,t,...n){try{let r=e.apply(t,n);return typeof r?.then==`function`?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}let y;(function(e){e.metadata=Symbol.metadata??Symbol.for(`Symbol.metadata`),e.none=Symbol(`none`),e.root=Symbol(`root`),e.module=Symbol(`module`),e.provider=Symbol(`provider`),e.controller=Symbol(`controller`),e.injection=Symbol(`injection`);let t;(function(e){e.root=Symbol(`route`),e.base=Symbol(`base`),e.opt=Symbol(`opt`),e.apiSchema=Symbol(`apiSchema`),e.args=Symbol(`args`)})(t||=e.route||={});let n;(function(e){e.root=Symbol(`interceptor`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(n||=e.interceptor||={});let r;(function(e){e.root=Symbol(`guard`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(r||=e.guard||={});let i;(function(e){e.root=Symbol(`filter`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(i||=e.filter||={});let a;(function(e){e.root=Symbol(`pipe`),e.controller=Symbol(`controller`),e.handler=Symbol(`handler`)})(a||=e.pipe||={});let o;(function(e){e.root=Symbol(`custom`),e.method=Symbol(`method`),e.field=Symbol(`field`)})(o||=e.custom||={}),e.cron=Symbol(`cron`),e.file=Symbol(`file`),e.user=Symbol(`user`)})(y||={});let b=function(e){return e[e.CONTINUE=100]=`CONTINUE`,e[e.SWITCHING_PROTOCOLS=101]=`SWITCHING_PROTOCOLS`,e[e.PROCESSING=102]=`PROCESSING`,e[e.EARLY_HINTS=103]=`EARLY_HINTS`,e[e.OK=200]=`OK`,e[e.CREATED=201]=`CREATED`,e[e.ACCEPTED=202]=`ACCEPTED`,e[e.NON_AUTHORITATIVE_INFORMATION=203]=`NON_AUTHORITATIVE_INFORMATION`,e[e.NO_CONTENT=204]=`NO_CONTENT`,e[e.RESET_CONTENT=205]=`RESET_CONTENT`,e[e.PARTIAL_CONTENT=206]=`PARTIAL_CONTENT`,e[e.MULTI_STATUS=207]=`MULTI_STATUS`,e[e.MULTIPLE_CHOICES=300]=`MULTIPLE_CHOICES`,e[e.MOVED_PERMANENTLY=301]=`MOVED_PERMANENTLY`,e[e.MOVED_TEMPORARILY=302]=`MOVED_TEMPORARILY`,e[e.SEE_OTHER=303]=`SEE_OTHER`,e[e.NOT_MODIFIED=304]=`NOT_MODIFIED`,e[e.USE_PROXY=305]=`USE_PROXY`,e[e.TEMPORARY_REDIRECT=307]=`TEMPORARY_REDIRECT`,e[e.PERMANENT_REDIRECT=308]=`PERMANENT_REDIRECT`,e[e.BAD_REQUEST=400]=`BAD_REQUEST`,e[e.UNAUTHORIZED=401]=`UNAUTHORIZED`,e[e.PAYMENT_REQUIRED=402]=`PAYMENT_REQUIRED`,e[e.FORBIDDEN=403]=`FORBIDDEN`,e[e.NOT_FOUND=404]=`NOT_FOUND`,e[e.METHOD_NOT_ALLOWED=405]=`METHOD_NOT_ALLOWED`,e[e.NOT_ACCEPTABLE=406]=`NOT_ACCEPTABLE`,e[e.PROXY_AUTHENTICATION_REQUIRED=407]=`PROXY_AUTHENTICATION_REQUIRED`,e[e.REQUEST_TIMEOUT=408]=`REQUEST_TIMEOUT`,e[e.CONFLICT=409]=`CONFLICT`,e[e.GONE=410]=`GONE`,e[e.LENGTH_REQUIRED=411]=`LENGTH_REQUIRED`,e[e.PRECONDITION_FAILED=412]=`PRECONDITION_FAILED`,e[e.REQUEST_TOO_LONG=413]=`REQUEST_TOO_LONG`,e[e.REQUEST_URI_TOO_LONG=414]=`REQUEST_URI_TOO_LONG`,e[e.UNSUPPORTED_MEDIA_TYPE=415]=`UNSUPPORTED_MEDIA_TYPE`,e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]=`REQUESTED_RANGE_NOT_SATISFIABLE`,e[e.EXPECTATION_FAILED=417]=`EXPECTATION_FAILED`,e[e.IM_A_TEAPOT=418]=`IM_A_TEAPOT`,e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]=`INSUFFICIENT_SPACE_ON_RESOURCE`,e[e.METHOD_FAILURE=420]=`METHOD_FAILURE`,e[e.MISDIRECTED_REQUEST=421]=`MISDIRECTED_REQUEST`,e[e.UNPROCESSABLE_ENTITY=422]=`UNPROCESSABLE_ENTITY`,e[e.LOCKED=423]=`LOCKED`,e[e.FAILED_DEPENDENCY=424]=`FAILED_DEPENDENCY`,e[e.UPGRADE_REQUIRED=426]=`UPGRADE_REQUIRED`,e[e.PRECONDITION_REQUIRED=428]=`PRECONDITION_REQUIRED`,e[e.TOO_MANY_REQUESTS=429]=`TOO_MANY_REQUESTS`,e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]=`REQUEST_HEADER_FIELDS_TOO_LARGE`,e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]=`UNAVAILABLE_FOR_LEGAL_REASONS`,e[e.INTERNAL_SERVER_ERROR=500]=`INTERNAL_SERVER_ERROR`,e[e.NOT_IMPLEMENTED=501]=`NOT_IMPLEMENTED`,e[e.BAD_GATEWAY=502]=`BAD_GATEWAY`,e[e.SERVICE_UNAVAILABLE=503]=`SERVICE_UNAVAILABLE`,e[e.GATEWAY_TIMEOUT=504]=`GATEWAY_TIMEOUT`,e[e.HTTP_VERSION_NOT_SUPPORTED=505]=`HTTP_VERSION_NOT_SUPPORTED`,e[e.INSUFFICIENT_STORAGE=507]=`INSUFFICIENT_STORAGE`,e[e.NETWORK_AUTHENTICATION_REQUIRED=511]=`NETWORK_AUTHENTICATION_REQUIRED`,e}({});const x=(...e)=>e.length===0?[]:e.filter(Array.isArray).flat(),S=(...e)=>Object.assign({},...e.filter(e=>e&&typeof e==`object`));function C(t,n){if(t===n)return!0;for(let r=e(t);r&&r!==Function.prototype;r=e(r))if(r===n)return!0;return!1}export{r as APP_FILTER,i as APP_GUARD,n as APP_INTERCEPTOR,t as APP_LOGGER,a as APP_PIPE,b as HttpStatus,d as _assign,h as _construct,u as _define,c as _entries,o as _fnToString,f as _get,_ as _getPrototypeOf,m as _has,s as _isArray,g as _ownKeys,p as _set,l as _values,x as concatArr,v as promiseTry,C as subclassOf,y as sym,S as toAssigned};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@nestify-js/shared",
3
+ "version": "0.1.2",
4
+ "description": "Shared utilities and types for nestify-js packages",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "default": "./dist/index.cjs",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "utilities",
22
+ "shared",
23
+ "typescript",
24
+ "types"
25
+ ],
26
+ "author": {
27
+ "name": "Kasukabe Tsumugi",
28
+ "email": "futami16237@gmail.com"
29
+ },
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "@rollup/plugin-replace": "^6.0.3",
33
+ "@types/node": "^26.1.0",
34
+ "rollup-plugin-func-macro": "^1.2.3",
35
+ "tsdown": "^0.22.3",
36
+ "typescript": "^6.0.3"
37
+ }
38
+ }