{"id":17715680,"url":"https://github.com/jmjuanes/url-api","last_synced_at":"2026-05-02T19:36:01.245Z","repository":{"id":57387500,"uuid":"88725241","full_name":"jmjuanes/url-api","owner":"jmjuanes","description":"Format and generate the urls for an API service ","archived":false,"fork":false,"pushed_at":"2017-05-03T11:02:01.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-12-25T20:04:38.096Z","etag":null,"topics":["api","nodejs","url","url-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/url-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmjuanes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-19T09:15:12.000Z","updated_at":"2017-04-19T10:24:33.000Z","dependencies_parsed_at":"2022-09-26T16:50:50.933Z","dependency_job_id":null,"html_url":"https://github.com/jmjuanes/url-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmjuanes%2Furl-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmjuanes%2Furl-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmjuanes%2Furl-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmjuanes%2Furl-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmjuanes","download_url":"https://codeload.github.com/jmjuanes/url-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246458859,"owners_count":20780832,"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":["api","nodejs","url","url-api"],"created_at":"2024-10-25T12:06:44.493Z","updated_at":"2026-05-02T19:36:01.206Z","avatar_url":"https://github.com/jmjuanes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# url-api\n\n[![npm](https://img.shields.io/npm/v/url-api.svg?style=flat-square)](https://www.npmjs.com/package/url-api)\n[![npm](https://img.shields.io/npm/dt/url-api.svg?style=flat-square)](https://www.npmjs.com/package/url-api)\n[![npm](https://img.shields.io/npm/l/url-api.svg?style=flat-square)](https://github.com/jmjuanes/url-api)\n\n\u003e Format and generate the urls for an API service \n\nThis package will format all the string patterns used in frameworks like [express](http://expressjs.com/en/guide/routing.html) into full urls like [this](https://api.github.com).\n\n\n## Usage \n\n```javascript\n//Import dependencies \nvar url_api = require('url-api');\n\n//Url object \nvar url_obj = { protocol: 'https', hostname: 'mywebsite.com' }; \n\n//Api urls \nvar api = { projects: '/projects/:project', home: '/', users: '/users/:user' };\n\n//Simple api\nurl_api(url_obj, api);\n// { \n//   projects: 'https://mywebsite.com/projects/{project}',\n//   home: 'https://mywebsite.com/',\n//   users: 'https://mywebsite.com/users/{user}' \n// }\n\n//With options\nurl_api(url_obj, api, { prefix: '{{', suffix: '}}' });\n// { \n//   projects: 'https://mywebsite.com/projects/{{project}}',\n//   home: 'https://mywebsite.com/',\n//   users: 'https://mywebsite.com/users/{{user}}' \n// }\n```\n\n## API \n\n### url_api(url_obj, api[, opt])\n\nReturns a new object with all the pathnames formatted. This method accepts the following arguments: \n\n- `url_obj`: a [url object](https://nodejs.org/api/url.html#url_url_strings_and_url_objects) with the API host information. \n- `api`: an object with all the paths strings of your RESTful API service.\n- `opt` (optionally): an object with the options:\n  - `find`: a regular expression to find the pattern parameters. Default is set to find the parameters starting with `:`.\n  - `prefix`: the formatted pattern parameter prefix. Default is `{`. \n  - `suffix`: the formatted pattern parameter suffix. Default is `}`.\n\n## License\n\n[MIT LICENSE](./LICENSE) \u0026copy; Josemi Juanes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmjuanes%2Furl-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmjuanes%2Furl-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmjuanes%2Furl-api/lists"}