{"id":21961809,"url":"https://github.com/trapcodeio/xpresser-frontend-helpers","last_synced_at":"2025-07-22T12:32:20.226Z","repository":{"id":52957962,"uuid":"325781401","full_name":"trapcodeio/xpresser-frontend-helpers","owner":"trapcodeio","description":"XpresserJs Frontend Helper","archived":false,"fork":false,"pushed_at":"2023-12-14T06:26:25.000Z","size":273,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-29T08:42:23.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/trapcodeio.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}},"created_at":"2020-12-31T11:02:51.000Z","updated_at":"2023-09-20T13:01:07.000Z","dependencies_parsed_at":"2023-12-13T15:58:43.672Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/xpresser-frontend-helpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fxpresser-frontend-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fxpresser-frontend-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fxpresser-frontend-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fxpresser-frontend-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/xpresser-frontend-helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227096597,"owners_count":17730377,"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-11-29T10:18:22.845Z","updated_at":"2024-11-29T10:18:23.456Z","avatar_url":"https://github.com/trapcodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XpresserJs Frontend Helpers\n\nCreate a javascript file of all **named routes** that can be imported and bundled by webpack.\n\n## Problem\n\nWhen working with lots of routes, Sometimes you find it difficult to remember the url of your routes And the glorious\nxpresser `$.helpers.route()` helper function that converts names to urls can't be accessed in Frontend.\n\nFor Example, we have a route like this Backend\n\n```javascript\n$.router.get('/user/:userId/uploads/:fileId/') // /user/164/song/733\n```\n\nIn our Frontend\n\n```javascript\naxios.get(`/user/${userId}/uploads/${fileId}`)\n```\n\nRemembering **urls, required/un-required route named parameters** when you have over **500 routes** will be difficult.\n\n## Solution\n\nAUTOGENERATED routes file that can be imported into your Frontend. This plugin reads your routes then generates a file\nthat can be configured to use any `Http Library` you are using. This file includes all your routes as a Library.\n\nFor example using the same example above, But we have to add a name to identify the route.\n\n```javascript\nrouter.get('/user/:userId/uploads/:fileId/', http =\u003e {\n  return {file: 'image.png'}\n}).name('uploaded_file') // /user/164/song/733\n```\n\nIn your frontend\n\n```javascript\nimport req from \"./auto-generated-file\";\n\nawait req.get.uploaded_file([userId, fileId]); // returns {\"file\": \"image.png\"}\n```\n\n### More Examples\n\nBackend\n\n```javascript\nrouter.get('/users', 'UserController@users').name('users');\nrouter.post('/users', 'UserController@create').name('user.create');\n\nrouter.get('/user/:userId', 'UserController@user').name('user');\nrouter.patch('/user/:userId', 'UserController@update').name('user.update');\nrouter.delete('/user/:userId', 'UserController@delete').name('user.delete');\n\nrouter.get('/songs/:genre/:year?/:month?/:day?').name('songs');\n```\n\nFrontend.\n\n```javascript\nimport req from \"./auto-generated-file\";\n\nawait req.get.users({page: 2}) // GET: /user?page=2\nawait req.post.users({\n  id: 35, name: \"John Doe\", email: \"newuser@app.me\", password: \"password\"\n}) // POST: /users with body\n\nawait req.get.user(35) // GET: /user/35\nawait req.patch.user(35, {\n  password: \"newPassword\"\n}) // PATCH: /user/35\nawait req.delete.user(35) // DELETE: /user/35\n\nawait req.get.songs([\"hip-hop\", 2020, 4, 15]) // GET: /songs/hip-hop/2020/4/15\n```\n\n## What you get.\n\n- Autocomplete for faster development.\n- It will never make a `Http Verb` mistake like send `get` instead of `post`.\n- Easily supports any http library.\n\nThis came like an idea to me, so I decided to bring it to life.\n\nNote: this is still experimental, I have lots of work on my table. So I won't be paying attention to it for now... I\nwill be updating my local version during my day-to-day use then someday I will update this.\n\nFor now, it only generates the file. you have to configure it to work like the Examples above. 🤦‍♂️\n\nYou can run the test file included.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fxpresser-frontend-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fxpresser-frontend-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fxpresser-frontend-helpers/lists"}