{"id":16531363,"url":"https://github.com/marcbachmann/coercion","last_synced_at":"2025-07-06T00:37:24.823Z","repository":{"id":17596960,"uuid":"20400651","full_name":"marcbachmann/coercion","owner":"marcbachmann","description":"Node module with query helpers to write a REST API","archived":false,"fork":false,"pushed_at":"2023-12-15T08:54:09.000Z","size":33,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-02T11:49:14.846Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcbachmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-02T10:42:50.000Z","updated_at":"2019-04-03T07:52:45.000Z","dependencies_parsed_at":"2023-12-15T09:43:55.248Z","dependency_job_id":"45dfae5d-3758-435a-a036-80cffc7b468e","html_url":"https://github.com/marcbachmann/coercion","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":0.09677419354838712,"last_synced_commit":"9fe9a681f4d82dca3e4fe0040d375c89ec5b145e"},"previous_names":["marcbachmann/api-query-parser"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fcoercion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fcoercion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fcoercion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fcoercion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcbachmann","download_url":"https://codeload.github.com/marcbachmann/coercion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fcoercion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258799038,"owners_count":22759765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T18:08:37.474Z","updated_at":"2025-07-06T00:37:24.784Z","avatar_url":"https://github.com/marcbachmann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coercion\n## A node.js module for type coercion.\n\n# Usage\n    \n    parse = require('coercion')\n    parse.dateRange(\"2014-01-01-2014-06-01\")\n    \n    {\n      from: Wed Jan 01 2014 01:00:00 GMT+0100 (CET),\n      to: Sun Jun 01 2014 02:00:00 GMT+0200 (CEST)\n    }\n\n\n## Functions\n\n### sort\n\n    parse.sort('-created,title')\n\n    {\n      created: 'desc',\n      title: 'asc'\n    }\n\n\n### csv\n\n    parse.csv('allowed,created,title,notallowed', {allowed: ['allowed', 'created', 'title']})\n\n    [ 'allowed', 'created', 'title' ]\n\n\n### boolean\nAlways returns a boolean. Default value is false\n\n    // returns true for true, 'true', 1, '1', 'yes'\n    parse.boolean('1')\n\n    \u003e true\n\n\n    parse.boolean('0')\n\n    \u003e false\n\n\n### integer\nAlways returns a number. Default value is 0\n\n\t// always returns a number\n\tparse.integer('foo')\n\t\n\t\u003e 0\n\n\t// Use a default value\n\tparse.integer('foo', {default: 10})\n\n\t\u003e 10\n\n\n\t// Use a maxium value\n\tparse.integer(1000, {default: 10, max: 100})\n\n\t\u003e 100\n\n\n### positiveInteger\nAlways returns a number. Default value is 0\n\n\t// parse.positiveInteger(number as string or int, default, max value)\n\tparse.positiveInteger(req.query.limit, {default: 10, max: 100})\n\n\t\u003e 100\n\n\n### date\nAlways returns a date. Undefined if parsing failed.\n\n    parse.date(\"2014-01-01\")\n\n    Wed Jan 01 2014 01:00:00 GMT+0100 (CET)\n\n\n### dateRange\nAlways returns an Object.\n\n    parse.dateRange(\"2014-01-01-2014-06-01\")\n\n    {\n      from: Wed Jan 01 2014 01:00:00 GMT+0100 (CET),\n      to: Sun Jun 01 2014 02:00:00 GMT+0200 (CEST)\n    }\n\n\n### pagination\nAlways returns an Object. Default limit is 50\n\n    parse.pagination({page: '10'})\n\n    {\n      offset: 450,\n      limit: 50\n    }\n\n\n    // Override the offset\n    parse.pagination({offset: 450})\n\n    {\n      offset: 450,\n      limit: 50\n    }\n\n\n    // Set the limit\n    parse.pagination({page: 5, limit: 10})\n\n    { offset: 40, limit: 10 }\n\n\n## middlewares\n    parse.middlewares.all(config)\n\n    -\u003e returns function(req, res, next) {\n\n      // which populates req.options\n      req.options = req.options || {}\n\n      // And pagination, sort \u0026 fields on req.options\n      req.options.pagination = {\n        offset: 0\n        limit: 50\n      }\n      req.options.sort = {\n        title: 'asc'\n      }\n\n      req.options.fields = ['title', 'name']\n    }\n\n### sort\n### fields\n### pagination\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Fcoercion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcbachmann%2Fcoercion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Fcoercion/lists"}