{"_id":"@2amtech/crudx","_rev":"3-8b0d42bfdcb21b41fa7a9e6bf38ee8ef","name":"@2amtech/crudx","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@2amtech/crudx","version":"1.0.0","keywords":["typescript","typeorm","nest","nestjs","rest","restful","api","crud","crud-generator","http","request","request-query","requestquery","get","query","query-string","querystring","query-builder","querybuilder"],"author":{"url":"https://2am.tech/","name":"Antonio Ramirez Cobos","email":"hola@2amigos.us"},"_id":"@2amtech/crudx@1.0.0","maintainers":[{"name":"2amtech","email":"accounts@2am.tech"}],"contributors":[{"name":"Jonatas Souza","email":"hola@2amigos.us"},{"name":"Aleksandar Panic","email":"hola@2amigos.us"}],"dist":{"shasum":"8efc378f0941dd15b05feab9747894835b0d919f","tarball":"https://registry.npmjs.org/@2amtech/crudx/-/crudx-1.0.0.tgz","fileCount":171,"integrity":"sha512-0ys+yAKn8YdPre+Wtd2YbG/Ixw3maBwX1PlUc8UgH1lUBj72k3zCZUksXZg33H1/6+4Nyx0tDhwLIN8fCOw80g==","signatures":[{"sig":"MEYCIQCALQkYMvxensBxFDZ5PexRRF9cz7e63HLhtnA2Udv3YQIhAI5t/AUMsWxSCagHQh8ZzsozqkCLHjYveGmmFdW6hTmZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":268858},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"afcec310db3e5047b8db3be90c2e04ee84e28f1c","typings":"./src/index.d.ts","_npmUser":{"name":"2amtech","email":"accounts@2am.tech"},"_npmVersion":"10.2.4","description":"NestJs CRUD for RESTful APIs - request query builder","directories":{},"_nodeVersion":"20.11.1","dependencies":{"rxjs":"^7.8.0","tslib":"^2.3.0","lodash":"^4.17.21","typeorm":"^0.3.17","@types/qs":"^6.9.7","deepmerge":"^4.3.1","@nestjs/common":"^10.1.3","@zmotivat0r/o0":"^1.0.2","@nestjs/typeorm":"^10.0.0","class-validator":"^0.14.0","class-transformer":"^0.5.1"},"_hasShrinkwrap":false,"devDependencies":{"supertest":"^6.3.4","@types/uuid":"^9.0.8"},"_npmOperationalInternal":{"tmp":"tmp/crudx_1.0.0_1722869856088_0.1961603441915667","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@2amtech/crudx","version":"1.0.1","keywords":["typescript","typeorm","nest","nestjs","rest","restful","api","crud","crud-generator","http","request","request-query","requestquery","get","query","query-string","querystring","query-builder","querybuilder"],"author":{"url":"https://2am.tech/","name":"Antonio Ramirez Cobos","email":"hola@2amigos.us"},"_id":"@2amtech/crudx@1.0.1","maintainers":[{"name":"2amtech","email":"accounts@2am.tech"}],"contributors":[{"name":"Jonatas Souza","email":"hola@2amigos.us"},{"name":"Aleksandar Panic","email":"hola@2amigos.us"}],"dist":{"shasum":"6eb822e649453ae6a3f2001c2e247fc6e8769ade","tarball":"https://registry.npmjs.org/@2amtech/crudx/-/crudx-1.0.1.tgz","fileCount":171,"integrity":"sha512-/ZZfgCk7DEebu6TOlDR98RvKn+HFMUO35eSiq5Kk37hKNVM5zExc679eQ55sGSPqzEma/T+ld9L1G2R2xYp3Vg==","signatures":[{"sig":"MEYCIQDu4epUOZ8qbNlHUbUDJFKUWehX6Tga3HOvwq+W2x1rzgIhAMECZ/XCP3o1ja8+Va9JzdGkkgzzDozNEg5hW6Wb+QbZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":267233},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"2bc6778c2a340fd57cd02c464fa66e3dac09dc2b","typings":"./src/index.d.ts","_npmUser":{"name":"2amtech","email":"accounts@2am.tech"},"_npmVersion":"10.2.4","description":"NestJs CRUD for RESTful APIs - request query builder","directories":{},"_nodeVersion":"20.11.1","dependencies":{"rxjs":"^7.8.0","tslib":"^2.3.0","lodash":"^4.17.21","typeorm":"^0.3.17","@types/qs":"^6.9.7","deepmerge":"^4.3.1","@nestjs/common":"^10.1.3","@zmotivat0r/o0":"^1.0.2","@nestjs/typeorm":"^10.0.0","class-validator":"^0.14.0","class-transformer":"^0.5.1"},"_hasShrinkwrap":false,"devDependencies":{"supertest":"^6.3.4","@types/uuid":"^9.0.8"},"_npmOperationalInternal":{"tmp":"tmp/crudx_1.0.1_1724323310591_0.13367042118971662","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@2amtech/crudx","version":"1.0.3","keywords":["typescript","typeorm","nest","nestjs","rest","restful","api","crud","crud-generator","http","request","request-query","requestquery","get","query","query-string","querystring","query-builder","querybuilder"],"author":{"url":"https://2am.tech/","name":"Antonio Ramirez Cobos","email":"hola@2amigos.us"},"_id":"@2amtech/crudx@1.0.3","maintainers":[{"name":"2amtech","email":"accounts@2am.tech"}],"contributors":[{"name":"Jonatas Souza","email":"hola@2amigos.us"},{"name":"Aleksandar Panic","email":"hola@2amigos.us"}],"homepage":"https://github.com/2amigos/nest-kit#readme","bugs":{"url":"https://github.com/2amigos/nest-kit/issues"},"dist":{"shasum":"1e40bc3e022e0dce3d5ac949aeb4467f14dd5ab3","tarball":"https://registry.npmjs.org/@2amtech/crudx/-/crudx-1.0.3.tgz","fileCount":171,"integrity":"sha512-4/vuAYHwtXSQNWBOFLCnxK0JACp8HB86U24S9D0dANU2mnazVsMpRfGE9uia+R3zBowT82KFBBJeuA5fZbmOTA==","signatures":[{"sig":"MEQCIGD3Bo+I9IZPooLzNKoPoYCfiQ0kZoDC8BgGKUQKLKc6AiBIFdd9xCQq12oirBtBsb+PDR8FBK1rtmGCSvmbJGkhAw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@2amtech%2fcrudx@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":268233},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"6820fecf04db38fc255e4199430e443211eaead4","typings":"./src/index.d.ts","_npmUser":{"name":"2amtech","email":"accounts@2am.tech"},"repository":{"url":"git+https://github.com/2amigos/nest-kit.git"},"_npmVersion":"10.8.2","description":"NestJs CRUD for RESTful APIs - request query builder","directories":{},"_nodeVersion":"18.20.5","dependencies":{"rxjs":"^7.8.0","tslib":"^2.3.0","lodash":"^4.17.21","typeorm":"^0.3.17","@types/qs":"^6.9.7","deepmerge":"^4.3.1","@nestjs/common":"^10.1.3","@zmotivat0r/o0":"^1.0.2","@nestjs/typeorm":"^10.0.0","class-validator":"^0.14.0","class-transformer":"^0.5.1"},"_hasShrinkwrap":false,"devDependencies":{"supertest":"^6.3.4","@types/uuid":"^9.0.8"},"_npmOperationalInternal":{"tmp":"tmp/crudx_1.0.3_1736308224243_0.6923213148799789","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@2amtech/crudx","author":{"name":"Antonio Ramirez Cobos","email":"hola@2amigos.us","url":"https://2am.tech/"},"repository":{"url":"git+https://github.com/2amigos/nest-kit.git"},"contributors":[{"name":"Jonatas Souza","email":"hola@2amigos.us"},{"name":"Aleksandar Panic","email":"hola@2amigos.us"}],"description":"NestJs CRUD for RESTful APIs - request query builder","version":"1.0.4","dependencies":{"tslib":"^2.3.0","@nestjs/common":"^10.1.3","@nestjs/typeorm":"^10.0.0","typeorm":"^0.3.17","rxjs":"^7.8.0","class-transformer":"^0.5.1","class-validator":"^0.14.0","deepmerge":"^4.3.1","lodash":"^4.17.21","@types/qs":"^6.9.7","@zmotivat0r/o0":"^1.0.2"},"devDependencies":{"supertest":"^6.3.4","@types/uuid":"^9.0.8"},"keywords":["typescript","typeorm","nest","nestjs","rest","restful","api","crud","crud-generator","http","request","request-query","requestquery","get","query","query-string","querystring","query-builder","querybuilder"],"type":"commonjs","main":"./src/index.js","typings":"./src/index.d.ts","types":"./src/index.d.ts","_id":"@2amtech/crudx@1.0.4","gitHead":"e18c5673ec1bbb5bc60dd1bbc53f080292cf7465","bugs":{"url":"https://github.com/2amigos/nest-kit/issues"},"homepage":"https://github.com/2amigos/nest-kit#readme","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-AS3kJ69V27QDsbflAKKNp1iBbRNDQmtd+J4bkZFwyczwkFn8PHmbiUr2CZUQ43midMMhHTBy6Tx4eghFhe17xw==","shasum":"f1bafe8bbf4c53fb13e6e3884beecc41349d5e74","tarball":"https://registry.npmjs.org/@2amtech/crudx/-/crudx-1.0.4.tgz","fileCount":171,"unpackedSize":268233,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@2amtech%2fcrudx@1.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDt80lyiU8owJ2Nsy8fkMqQVrqHZ058uS5UdQKJSKdFfQIgW/6EAhzZY3WCSFkLI4cqRLW9aZErTVZ7sepb5i7B3T8="}]},"_npmUser":{"name":"2amtech","email":"accounts@2am.tech"},"directories":{},"maintainers":[{"name":"2amtech","email":"accounts@2am.tech"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/crudx_1.0.4_1736311253424_0.023065695200761738"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-05T14:57:36.001Z","modified":"2025-01-08T04:40:54.010Z","1.0.0":"2024-08-05T14:57:36.336Z","1.0.1":"2024-08-22T10:41:50.906Z","1.0.3":"2025-01-08T03:50:24.416Z","1.0.4":"2025-01-08T04:40:53.627Z"},"bugs":{"url":"https://github.com/2amigos/nest-kit/issues"},"author":{"name":"Antonio Ramirez Cobos","email":"hola@2amigos.us","url":"https://2am.tech/"},"homepage":"https://github.com/2amigos/nest-kit#readme","keywords":["typescript","typeorm","nest","nestjs","rest","restful","api","crud","crud-generator","http","request","request-query","requestquery","get","query","query-string","querystring","query-builder","querybuilder"],"repository":{"url":"git+https://github.com/2amigos/nest-kit.git"},"description":"NestJs CRUD for RESTful APIs - request query builder","contributors":[{"name":"Jonatas Souza","email":"hola@2amigos.us"},{"name":"Aleksandar Panic","email":"hola@2amigos.us"}],"maintainers":[{"name":"2amtech","email":"accounts@2am.tech"}],"readme":"\n# @2amtech/Crudx\nThe @2amtech/Crudx is a refactor inspired by the impressive work of [nestjsx/crud](https://github.com/nestjsx/crud), consolidating its three packages into one cohesive solution. It simplifies the creation of CRUD (Create, Read, Update, Delete) endpoints for RESTful applications with remarkable ease within Nest.js.\n\nThis tool provides decorators specifically designed for endpoint generation, global configurations, request validation, and specialized services, all tailored to enhance the efficiency and usability of Crudx across various contexts.\n\nA comprehensive documentation offers a structured exploration of Crudx functionalities, meticulously divided into distinct sections. Each section is accompanied by illustrative samples and insightful comments, fostering a deeper understanding of how to effectively leverage Crudx in your projects.\n\n## Install\n\n```bash\n$ npm i @2amtech/crudx\n```\n\n## Basics\n\nBefore diving into Crudx features, it's essential to define a basic Nest.js module for CRUD operations. Let's use the User module as a sample:\n\nFirst, let's define an entity.\n\nCrudx supports TypeORM for building entities, so let's implement it:\n\n```typescript \nimport { \n  AfterLoad,\n  BaseEntity,\n  Entity, \n  PrimaryGeneratedColumn, \n  Column,\n  BeforeInsert,\n  BeforeUpdate,\n} from \"typeorm\";\nimport * as bcrypt from \"bcryptjs\";\n\n@Entity()\nexport class User extends BaseEntity {\n  @PrimaryGeneratedColumn(\"uuid\") \n  id: string;\n\n  @Column({ unique: true, length: 125 })\n  email: string;\n\n  @Column({ type: \"varchar\", length: 80 })\n  password: string; \n\n  private tempPassword?: string;\n\n  @AfterLoad()\n  private loadTempPassword(): void {\n    this.tempPassword = this.password;\n  }\n\n  @BeforeInsert()\n  private async hashPassword(): Promise<void> {\n    this.password = await bcrypt.hash(this.password, 10);\n  }\n\n  @BeforeUpdate()\n  private async encryptPassword(): Promise<void> {\n    if (this.tempPassword !== null && this.tempPassword !== this.password) {\n      try {\n        await this.hashPassword();\n\n        this.tempPassword = this.password;\n      } catch (error) {\n        if (error instanceof Error) {\n          throw new Error(\"Unable to encrypt password: \" + error.message);\n        }\n      }\n    }\n  }\n}\n```\n\nNext, let's create a service:\n\n```typescript\nimport {Injectable} from \"@nestjs/common\";\nimport { InjectRepository } from \"@nestjs/typeorm\";\nimport { TypeOrmCrudService } from \"@2amtech/crudx\";\nimport { Catch, Injectable } from \"@nestjs/common\";\nimport { EntityNotFoundError, QueryFailedError } from \"typeorm\";\n\n@Injectable()\n@Catch(QueryFailedError, EntityNotFoundError)\nexport class UserService extends TypeOrmCrudService<User> {\n  constructor(@InjectRepository(User) readonly repo) {\n    super(repo);\n  }\n}\n```\n\nWith the service in place, let's define our controller:\n\nNote that we're utilizing the `@Crud` decorator. When it’s defined for a controller, it automatically creates the basic CRUD routes:\n\n* get `/user`\n* get `/user/:id`\n* post `/user`\n* post `/user/bulk`\n* patch `/user/:id`\n* put `/user/:id`\n* delete `/user/:id`\n\nFor further details, you can refer to the [Controllers](./docs/controllers.md) section.\n\nIn our sample, we're specifying some options for our @CRUD decorator: `model` and `params`.\n\nThe `model` option is the only required one for the `@Crud()` decorator. Its type property defines a class as the request body type, enabling data validation. Though not covered in our basics, you can find all related information in the [request validation](./docs/validation.md) section. The provided `type` should be an `Entity`, `Model` or `DTO`.\n\nBy default, the generated routes will have a parameter named `:id`. This parameter is intended to represent the model's primary key. We're using the `params` options to instruct Crudx to define our param `:id` as a  `uuid` type, indicating that it should match the `id` field of the User entity.\n\n```typescript\nimport { Crud, CrudController } from \"@2amtech/crudx\";\nimport { Controller } from \"@nestjs/common\";\nimport { User } from \"./user.entity\";\nimport { UserService } from \"./user.service\";\n\n@Crud({\n  model: {\n    type: User,\n  },\n  params: {\n    id: {\n        field: \"id\",\n        type: \"uuid\",\n        primary: true,\n    }\n  }\n})\n@Controller(\"users\")\nexport class UserController implements CrudController<User> {\n  constructor(public service: UserService) {}\n}\n```\n\nWith the `entity`, `service`, and `controller` defined, all that's left is to export a module and import it into the application's main module:\n\n```typescript\nimport { Module } from \"@nestjs/common\";\nimport { TypeOrmModule } from \"@nestjs/typeorm\";\n\nimport { UserController } from \"./user.controller\";\nimport { User } from \"./user.entity\";\nimport { UserService } from \"./user.service\";\n\n@Module({\n  imports: [TypeOrmModule.forFeature([User])],\n  controllers: [UserController],\n  providers: [UserService],\n  exports: [UserService],\n})\nexport class UserModule {}\n```\n\n## IntelliSense\n\nDue to the CRUD controllers being composed by the logic of the `@Crud` decorator, IntelliSense will not be available on composed methods. To enable your code to properly access the controller's methods from the `this` keyword, you can add these lines to your class:\n\n```typescript\nimport { Crud, CrudController } from '@2amtech/crudx';\nimport { User } from './user.entity.ts';\n\n@Crud(User)\n@Controller('user')\nexport class UserController implements CrudController<User> {\n  constructor(public service: UserService) {}\n\n  get base(): CrudController<User> {\n    return this;\n  }\n}\n```\n\nWhile the examples provided above offer a simplistic demonstration, they effectively highlight the fundamental principles of utilizing Crudx. For more in-depth insights and comprehensive guidance, we encourage you to explore the dedicated sections outlined below, which deal with specific functionalities and advanced usage scenarios.\n\n## Further Reading\n\n* [Controllers](./docs/controllers.md)\n* [Nested Controllers](./docs/nested-controllers.md)\n* [Routes](./docs/routes.md)\n* [Queries and Fiters](./docs/query-filter.md)\n* [Request Validation](./docs/validation.md)\n* [Response Serialization](./docs/serialization.md)\n* [Actions and Access Management](./docs/actions-access-management.md)\n* [Request Authenticaten](./docs/authentication.md)\n* [Global Options](./docs/global-options.md)\n* [ORM](./docs/orm.md)\n* [Requests and Query Params](./docs/requests.md)\n* [Swagger - @2amtech/crudx-swagger](https://github.com/2amigs/nest-kit/packages/crudx-swagger/README.md)\n\nThank you for exploring our resources. Happy coding!\n\n<blockquote>\n    <a href=\"http://www.2am.tech\"><img src=\"http://www.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0.png\"></a><br>\n    <i>web development has never been so fun</i><br> \n    <a href=\"http://www.2am.tech\">www.2am.tech</a>\n</blockquote>","readmeFilename":"README.md"}