Gathering detailed insights and metrics for @resk/core
Gathering detailed insights and metrics for @resk/core
npm install @resk/core
Typescript
Module System
Node Version
NPM Version
Love this project? Help keep it running β sponsor us today! π
Total Downloads
291
Last Day
1
Last Week
9
Last Month
26
Last Year
291
Latest Version
1.3.4
Package Id
@resk/core@1.3.4
Unpacked Size
717.66 kB
Size
112.08 kB
File Count
465
NPM Version
10.9.2
Node Version
20.11.0
Publised On
06 Feb 2025
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
125%
9
Compared to previous week
Last month
85.7%
26
Compared to previous month
Last year
0%
291
Compared to previous year
ResKit is an innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, ResKit enhances code clarity, modularity, and maintainability, making it the ideal choice for modern application development.
To begin using ResKit, follow these steps:
Make sure you have the following installed on your machine:
To set up ResKit, you'll need to install the necessary packages. Run the following command:
1npm install @resk reflect-metadata 2# or 3yarn add @resk reflect-metadata
Also, install the necessary TypeScript dev dependencies:
1npm install --save-dev typescript @types/node # or yarn add -D typescript @types/node
Create a tsconfig.json
file in your project root with the following configuration:
1{ 2 "compilerOptions": { 3 "esModuleInterop": true, 4 "forceConsistentCasingInFileNames": true, 5 "target": "es6", // Use ES6 or higher 6 "module": "commonjs", // Use commonjs module system 7 "experimentalDecorators": true, // Enable experimental support for decorators 8 "emitDecoratorMetadata": true, // Enable emitting design:type metadata 9 "strict": true, // Enable all strict type checking options 10 "skipLibCheck": true // Skip type checking of declaration files 11 }, 12 "include": ["src/**/*"], 13 "exclude": ["node_modules"] 14}
reflect-metadata
In your entry file (usually index.ts
or app.ts
), ensure that you import reflect-metadata
at the very top of the file. This is required to enable metadata reflection for decorators.
1import "reflect-metadata";
@ResourceMetadata
decorator to define any logical entity (models, components, etc.).@Field
decorator, specifying field types and options.Once you have installed the necessary packages and set up TypeScript, you can start defining resources and fields using ResKit decorators.
1import "reflect-metadata"; 2import { ResourceMetadata, Field } from "@resk"; 3 4@ResourceMetadata() 5class User { 6 @Field({ type: "string" }) 7 name: string; 8 9 @Field({ type: "number" }) 10 age: number; 11 12 @Field({ type: "email" }) 13 email: string; 14}
1@Field({ type: 'dropdown', options: ['Admin', 'User', 'Guest'] }) 2role: string; 3 4@Field({ type: 'selectResource', resourceName: 'Product' }) 5favoriteProduct: string;
You can easily create and register new decorators to extend the functionality of your resources.
1function CustomField(options: { customProp: string }) { 2 return function (target: any, propertyKey: string) { 3 // Custom decorator logic 4 Reflect.defineMetadata("customProp", options.customProp, target, propertyKey); 5 }; 6}
ResKit is designed for flexibility. You can add your own custom field types or extend existing ones with full TypeScript support.
You can easily extend the field types available in ResKit by creating custom decorators. To extend field types and register custom options (e.g., a rating
field), use TypeScript's declaration merging.
1function ExtendedField(type: string, options: any) { 2 return function (target: any, propertyKey: string) { 3 Reflect.defineMetadata('design:type', type, target, propertyKey); 4 Reflect.defineMetadata('field:options', options, target, propertyKey); 5 }; 6} 7 8// Define a new field type for a color picker 9@ExtendedField('colorPicker', { defaultColor: '#000000' }) 10color: string;
You can create new resources and leverage the existing decorators for rich resource definitions.
1@ResourceMetadata() 2class Product { 3 @Field({ type: "string" }) 4 productName: string; 5 6 @Field({ type: "number" }) 7 price: number; 8 9 @Field({ type: "string", options: { enum: ["In Stock", "Out of Stock"] } }) 10 availability: string; 11}
You can also create custom decorators that implement advanced logic, such as validation or transformation.
1function IsPositive(target: any, propertyKey: string) { 2 const value = target[propertyKey]; 3 if (value < 0) { 4 throw new Error(`${propertyKey} must be a positive number.`); 5 } 6} 7 8@ResourceMetadata() 9class Order { 10 @Field({ type: 'number' }) 11 @IsPositive 12 totalAmount: number; 13 14 @Field({ type: 'string' }) 15 customerName: string; 16}
Hereβs how you can use the newly defined field types in a resource:
1@ResourceMetadata() 2class EnhancedUser { 3 @Field({ type: "string" }) 4 name: string; 5 6 @ExtendedField("colorPicker", { defaultColor: "#FF0000" }) 7 favoriteColor: string; 8}
ResKit can be extended with plugins and custom modules. Define new decorators, extend resource behavior, and add complex validation logic as needed.
1import { ResourceMetadata, Field, customDecorator } from '@resk'; 2 3function LogField() { 4 return customDecorator((target, key) => { 5 console.log(`Field '${key}' has been initialized.`); 6 }); 7} 8 9@ResourceMetadata 10class Product { 11 @LogField() 12 @Field({ type: "number" }) 13 price: number; 14}
We welcome contributions to ResKit! If you'd like to submit a feature request, report a bug, or contribute code, please follow these steps:
git checkout -b feature/YourFeature
).git commit -m 'Add some feature'
).git push origin feature/YourFeature
).ResKit is licensed under the MIT License.
Thanks to the open-source community for contributions and inspiration.
For support or inquiries:
No vulnerabilities found.
No security vulnerabilities found.