{"_id":"@achtjs/common","_rev":"3-3c6b89180dbcf6cc1411de1fce909c79","name":"@achtjs/common","dist-tags":{"latest":"0.2.0"},"versions":{"1.0.0":{"name":"@achtjs/common","version":"1.0.0","description":"achtJS Common Module","main":"lib/index.js","types":"lib/index.d.ts","author":{"name":"Pedro Harbs","email":"harbspj@gmail.com"},"license":"MIT","keywords":["nodejs","rest","api","http"],"repository":{"type":"git","url":"git+https://github.com/achtjs/common.git"},"bugs":{"url":"https://github.com/achtjs/common/issues"},"homepage":"https://github.com/achtjs/common#readme","scripts":{"build":"tsc"},"devDependencies":{"@achtjs/router":"^0.1.1","@achtjs/ts-config":"^0.1.0","@types/node":"^14.14.40","reflect-metadata":"^0.1.13","ts-node":"^8.8.2","typescript":"^4.1.2"},"gitHead":"8c2b64208f2107a18e0f79e0834c042ddb8e1ab5","_id":"@achtjs/common@1.0.0","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-6RxhdgvCaKRgw211Y0UKpSdm5t4erbDEH/kcDAFEsq9G/vsz8KxFp0UePu987y4lv+lR6waN1aFcMjM2emlOsQ==","shasum":"f85b10b985960d90b34956fd53f11a1104b24778","tarball":"https://registry.npmjs.org/@achtjs/common/-/common-1.0.0.tgz","fileCount":37,"unpackedSize":36238,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF/ajTmx+hQ5ydT0FRTGLqKGEfxTZi52dAuqJ9kKmeXFAiAHlhpxazX1hul79z7GA2xqH/YayVLWGR3Fbi5H7I0osg=="}]},"_npmUser":{"name":"jharbs","email":"harbspj@gmail.com"},"directories":{},"maintainers":[{"name":"jharbs","email":"harbspj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common_1.0.0_1692548620088_0.4241553892763734"},"_hasShrinkwrap":false},"0.1.2":{"name":"@achtjs/common","version":"0.1.2","description":"achtJS Common Module","main":"lib/index.js","types":"lib/index.d.ts","author":{"name":"Pedro Harbs","email":"harbspj@gmail.com"},"license":"MIT","keywords":["nodejs","rest","api","http"],"repository":{"type":"git","url":"git+https://github.com/achtjs/common.git"},"bugs":{"url":"https://github.com/achtjs/common/issues"},"homepage":"https://github.com/achtjs/common#readme","scripts":{"build":"tsc"},"devDependencies":{"@achtjs/router":"^0.1.1","@achtjs/ts-config":"^0.1.1","@types/node":"^14.14.40","reflect-metadata":"^0.1.13","ts-node":"^8.8.2","typescript":"^4.1.2"},"gitHead":"fa0cfa70199dd96f821a7100ce2852a50294fa05","_id":"@achtjs/common@0.1.2","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-4lg0G7al7XhI/0d+YRCjYG6R9wKU1T6wdLi+5ZqNF9DiZB0ZwU+JM5br4L75Qex92MhYFuHzbNXoQHknbUzTYA==","shasum":"62bff774d1e895ae59c1ce6e901c0faa66c4296f","tarball":"https://registry.npmjs.org/@achtjs/common/-/common-0.1.2.tgz","fileCount":38,"unpackedSize":45166,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDir4ZE3BNSQc8X+5MTZrb8M0Qvb77YiytgU9+C0AXaZAiEAjXOcAOqRTUJ6pV1zxnKsQUuYJK+uEAhBZz3pZmkVxu4="}]},"_npmUser":{"name":"jharbs","email":"harbspj@gmail.com"},"directories":{},"maintainers":[{"name":"jharbs","email":"harbspj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common_0.1.2_1692557230650_0.6454149336345223"},"_hasShrinkwrap":false},"0.1.3":{"name":"@achtjs/common","version":"0.1.3","description":"achtJS Common Module","main":"lib/index.js","types":"lib/index.d.ts","author":{"name":"Pedro Harbs","email":"harbspj@gmail.com"},"license":"MIT","keywords":["nodejs","rest","api","http"],"repository":{"type":"git","url":"git+https://github.com/achtjs/common.git"},"bugs":{"url":"https://github.com/achtjs/common/issues"},"homepage":"https://github.com/achtjs/common#readme","scripts":{"build":"tsc"},"devDependencies":{"@achtjs/router":"^0.1.1","@achtjs/ts-config":"^0.1.3","@types/node":"^14.14.40","reflect-metadata":"^0.1.13","ts-node":"^8.8.2","typescript":"^4.1.2"},"gitHead":"1beff9eb0b5e9eefa045fdeb61728d4c989cc9f5","_id":"@achtjs/common@0.1.3","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-95tg58F2EMmo5hOF6VbDoQfKoNqw+sAcGr6RZEjvFKMeGD1UsGvlVPuM2d6ZMLaCkeqUZO2nSjCC82DqpiMEIg==","shasum":"29abcfa52f8e43ffba5e122f8448531ac4f3edee","tarball":"https://registry.npmjs.org/@achtjs/common/-/common-0.1.3.tgz","fileCount":26,"unpackedSize":33663,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBmdkdjCoeUQWP+L8xXXqb0KTxvQKcFik0KldIMZIHW3AiEA7Xy/6dTkRXuZpH2gpRtra8IXxOjwmrEAdUdAaizakV8="}]},"_npmUser":{"name":"jharbs","email":"harbspj@gmail.com"},"directories":{},"maintainers":[{"name":"jharbs","email":"harbspj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common_0.1.3_1692565014454_0.41587115052861723"},"_hasShrinkwrap":false},"0.2.0":{"name":"@achtjs/common","version":"0.2.0","description":"achtJS Common Module","main":"lib/index.js","types":"lib/index.d.ts","author":{"name":"Pedro Harbs","email":"harbspj@gmail.com"},"license":"MIT","keywords":["nodejs","rest","api","http"],"repository":{"type":"git","url":"git+https://github.com/achtjs/common.git"},"bugs":{"url":"https://github.com/achtjs/common/issues"},"homepage":"https://github.com/achtjs/common#readme","scripts":{"build":"tsc"},"devDependencies":{"@achtjs/router":"^0.1.3","@achtjs/ts-config":"^0.1.3","@types/node":"^14.14.40","reflect-metadata":"^0.1.13","ts-node":"^8.8.2","typescript":"^4.1.2"},"gitHead":"aaf4a7ef960bdd43ca6b03d65f2e71d08f2ce385","_id":"@achtjs/common@0.2.0","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-tFig8VTGyUE0Gx87ZKtTrzM4D5ASGJ+p1pnPkA2zUU2vO+wxtCg9BOjynLk8fYn8oipGbSYmSBOnLlPuW8XCJw==","shasum":"1d306d0848de2a01acbbfabaf7a74900734f4337","tarball":"https://registry.npmjs.org/@achtjs/common/-/common-0.2.0.tgz","fileCount":26,"unpackedSize":33663,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvc3E/vuPkSMF2V/HY0U1Dcs92x08v3W/uRWxlgdBZLAIhAIz4BDqDiB2f+q4/D+ad9HJl5sJ3NxwMfCnu8k9QphWz"}]},"_npmUser":{"name":"jharbs","email":"harbspj@gmail.com"},"directories":{},"maintainers":[{"name":"jharbs","email":"harbspj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common_0.2.0_1692565203505_0.46712514457729015"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-20T16:23:39.979Z","1.0.0":"2023-08-20T16:23:40.265Z","modified":"2023-08-20T21:00:04.098Z","0.1.2":"2023-08-20T18:47:10.872Z","0.1.3":"2023-08-20T20:56:54.636Z","0.2.0":"2023-08-20T21:00:03.839Z"},"maintainers":[{"name":"jharbs","email":"harbspj@gmail.com"}],"description":"achtJS Common Module","homepage":"https://github.com/achtjs/common#readme","keywords":["nodejs","rest","api","http"],"repository":{"type":"git","url":"git+https://github.com/achtjs/common.git"},"author":{"name":"Pedro Harbs","email":"harbspj@gmail.com"},"bugs":{"url":"https://github.com/achtjs/common/issues"},"license":"MIT","readme":"# @achtjs/common\n\n<h1 align=\"center\">AchtJS Common Module</h1>\n\n## Installation\n\n```sh\nnpm i @achtjs/common\n```\n\n## Decorators\n\n-   [GET](#get)\n-   [POST](#post)\n-   [PATCH](#patch)\n-   [PATCH](#put)\n-   [DELETE](#delete)\n\n## Validations\n\n-   [Check](#check)\n    -   [isNumber](#isnumber)\n    -   [isBoolean](#isboolean)\n    -   [isString](#isstring)\n    -   [isAddress](#isaddress)\n    -   [isRegExp](#isregexp)\n    -   [isDate](#isdate)\n    -   [isEmail](#isemail)\n    -   [isArray](#isarray)\n    -   [isPassword](#ispassword)\n    -   [includes](#includes)\n    -   [minLength](#minlength)\n    -   [maxLength](#maxlength)\n    -   [notEmpty](#notempty)\n    -   [required](#required)\n\n# METHOD DECORATORS\n\nThis are functions that defines what function to be used in a route method inside a `controller`.\n\n## Usage\n\nBefore using a decorator you must first import it from `@achtjs/common` module.\n\n```ts\nimport { Get, Post, Put, Patch, Delete } from \"@achtjs/common\";\n```\n\nYou can use a method decorator like calling a normal function with the exception of adding an `@` sign before the function name. The route path has a default value of `\"/\"`.\n\n```ts\n@Get()\nfunction(){\n    // Do some GET stuff here\n}\n```\n\nYou can also provides additional parameters that includes the `path` and `middlewares` for that specific route.\n\n```ts\n@Get({ path: \"/\", middlewares: [] })\nfunction(){\n    // Route logic\n}\n```\n\n> Note: `middlewares` are **OPTIONAL**\n\nYou can also just provide a string denoting the name of the route.\n\n```ts\n@Get(\"/\")\nfunction(){\n    // Route logic\n}\n```\n\nYou can also just provide an array of middleware and its path will have a default value of `\"/\"` as the route name.\n\n```ts\n@Get([middlewares])\nfunction(){\n    // Route logic\n}\n```\n\n## GET\n\nThis is a decorator function is for creating a **GET METHOD ROUTE**. GET request is used to retreive a resource.\n\n```ts\nimport { Get } from \"@achtjs/common\";\n```\n\n## POST\n\nThis is a decorator function is for creating a **POST METHOD ROUTE**. POST requests are used to send data to the API sever to create a resource.\n\n```ts\nimport { Post } from \"@achtjs/common\";\n```\n\n## PUT\n\nThis is a decorator function is for creating a **PUT METHOD ROUTE**. PUT requests are used to replace a resource.\n\n```ts\nimport { Put } from \"@achtjs/common\";\n```\n\n## PATCH\n\nThis is a decorator function is for creating a **PATCH METHOD ROUTE**. PATCH is similar to POST and PUT but used only to apply partial modifications to a resource.\n\n```ts\nimport { Patch } from \"@achtjs/common\";\n```\n\n## DELETE\n\nThis is a decorator function is for creating a **DELETE METHOD ROUTE**. DELETE request is used to delete the resource at the specified URL.\n\n```ts\nimport { Delete } from \"@achtjs/common\";\n```\n\n# VALIDATIONS\n\n## Check\n\nThis is a function used for validating fields for `BODY` and `PARAMS` of a request.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"age\") // Name of the fields to be checked. `defaults` to check the `body` of the request.\n     .isNumber() // Checks if the field is a number\n     .minLength(5) // Checks if the field has a minimum length of 5\n     .maxLength(10) // Checks if the field has a maximum length of 10\n     .notEmpty() // Checks if the field is not empty\n     .required(), // Checks if the field is present or not undefined\n] })\nfunction(){}\n```\n\n## isNumber\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a `number` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"age\").isNumber(),\n] })\nfunction(){}\n```\n\n## isBoolean\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a `boolean` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"islogin\").isBoolean(),\n] })\nfunction(){}\n```\n\n## isString\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a `string` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").isString(),\n] })\nfunction(){}\n```\n\n## isAddress\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a `valid address` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"address\").isAddress(),\n] })\nfunction(){}\n```\n\n## isRegExp\n\nThis is a validation function that is used along with `Check`. This function accepts a RegExp and checks if the field will match the regex. If the test fails it will send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").isRegExp(/^[A-Za-z0-9.,\\s]*$/),\n] })\nfunction(){}\n```\n\n## minLength\n\nThis is a validation function that is used along with `Check`. This function accepts an argument which is a number and checks if the field length is greater than or equal to the parameter. If the field length is not greater than or equal to the parameter it will send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").minLength(5),\n] })\nfunction(){}\n```\n\n## maxLength\n\nThis is a validation function that is used along with `Check`. This function accepts an argument which is a number and checks if the field length is less than or equal to the parameter. If the field length is not less than or equal to the parameter it will send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").maxLength(10),\n] })\nfunction(){}\n```\n\n## isDate\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a valid `date` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"date\").isDate(),\n] })\nfunction(){}\n```\n\n## isEmail\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a valid `email` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"email\").isEmail(),\n] })\nfunction(){}\n```\n\n## isPassword\n\nThis is a validation function that is used along with `Check`. This function checks if the field is a valid `password` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").isPassword(),\n] })\nfunction(){}\n```\n\n## notEmpty\n\nThis is a validation function that is used along with `Check`. This function checks if the field is not empty and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"password\").notEmpty(),\n] })\nfunction(){}\n```\n\n## required\n\nThis is a validation function that is used along with `Check`. This function checks if the field is not `undefined` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"user\").required(),\n] })\nfunction(){}\n```\n\n## isArray\n\nThis is a validation function that is used along with `Check`. This function checks if the field is an `array` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"user\").isArray(),\n] })\nfunction(){}\n```\n\n## includes\n\nThis is a validation function that is used along with `Check`. This function accepts an array of values and checks if the field or fields items values is included on the `array` and send a validation error response if its not.\n\n### Import\n\n```javascript\nimport { Check } from \"@achtjs/common\";\n```\n\n### Usage\n\n```javascript\n@Post({ path: \"/\", middlewares: [\n     Check(\"user\").includes<string>([\"cats\", \"dogs\"]),\n] })\nfunction(){}\n```\n","readmeFilename":"README.md"}