{"id":17793413,"url":"https://github.com/pyk/worter","last_synced_at":"2025-03-16T19:30:37.336Z","repository":{"id":54278307,"uuid":"342311096","full_name":"pyk/worter","owner":"pyk","description":"[WIP] An easy-way to build REST API in Cloudflare Workers","archived":false,"fork":false,"pushed_at":"2021-02-27T07:12:26.000Z","size":123,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T00:07:35.763Z","etag":null,"topics":["cloudflare-workers","middleware","rest-api","wip"],"latest_commit_sha":null,"homepage":"","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/pyk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-25T16:41:08.000Z","updated_at":"2021-11-23T21:57:31.000Z","dependencies_parsed_at":"2022-08-13T10:50:18.277Z","dependency_job_id":null,"html_url":"https://github.com/pyk/worter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2Fworter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2Fworter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2Fworter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2Fworter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyk","download_url":"https://codeload.github.com/pyk/worter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243769956,"owners_count":20345217,"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":["cloudflare-workers","middleware","rest-api","wip"],"created_at":"2024-10-27T11:08:36.864Z","updated_at":"2025-03-16T19:30:37.056Z","avatar_url":"https://github.com/pyk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 😺 Worter\n\nBuild production-ready [Cloudflare Workers](https://workers.cloudflare.com/)\napps.\n\n-   👌 TypeScript by default.\n-   📦 Simple \u0026 lightweight. Only ~7kb in production build.\n-   🤞 A great list of middlewares to help you to build your application faster\n    without reinventing the wheel.\n-   🚀 All features are tested in Production Cloudflare environments.\n\nYou can build fast and scalable API server or web apps that runs on Cloudflare\nWorkers with Worter in no time 🔥.\n\nTODO: Build site with link to this markdown, the site should be deployed on\ncloudflare workers.\n\n## Features\n\n-   ✅ **Advanced routing**. Worter offers an advanced and efficient routing\n    mechanism that you can use to handle highly dynamic URLs.\n-   ✅ **Middleware as first-class citizen**. Worter application is essentially\n    a series of middleware function calls. With such an architecture, it becomes\n    easy for you to add, remove, or modify various features to and from the\n    application, giving high scalability to the application.\n-   ✅(WIP) **Template engines support**. Worter supports all template engines\n    that allows your Cloudflare Workers apps to have dynamic content by\n    constructing HTML templates on the server side, replacing dynamic content\n    with their proper values, and then sending these to the client side for\n    rendering.\n-   ✅(WIP) **Easy to test**. Worter provides set of tools that you can use to\n    test your application in Production Cloudflare environments. Yes, it's okay\n    to deploy on a Friday at 5pm 😉.\n\n## 💃 Getting started\n\nAdd to existing project:\n\n    npm i worter --save-exact\n\nor start new Worter project:\n\n    $ wrangler generate my-app https://github.com/pyk/worter-template\n    $ cd my-app/\n    $ npm install\n\nStart the development server using the following command:\n\n    $ wrangler dev\n\nAnd you are ready to go! 🚀\n\nContinue read the guide below to learn more about the Worter.\n\n### 🌎 Hello world example\n\n```typescript\nimport { Worter } from \"worter\";\n\nconst app = new Worter();\n\napp.get(\"/\", (request, response) =\u003e {\n    return response.json({ message: \"Hello from Worter 😺!\" });\n});\n\naddEventListener(\"fetch\", (event) =\u003e {\n    event.respondWith(app.serve(event.request));\n});\n```\n\nRun the app on your local machine with the following command:\n\n    $ wrangler dev\n\nThe `wrangler` starts a server and listens on port 8787 for connections. The app\nresponds with the following JSON formatted string:\n\n```json\n{\n    \"message\": \"Hello from Worter 😺!\"\n}\n```\n\nfor requests to the root URL (/) or route. For every other path, it will respond\nwith a 404 Not Found.\n\nNext, let's talk about the basic routing mechanism in Worter apps.\n\n### 🎛️ Basic routing\n\nRouting refers to determining how an application responds to a request to a\nparticular endpoint, which is a URI (or path) and a specific HTTP request method\n(GET, POST, and so on).\n\nEach route can have one handler function, which are executed when the route is\nmatched.\n\nIn Worter, route definition takes the following structure:\n\n    app.METHOD(PATH, HANDLER)\n\nWhere:\n\n-   `app` is an instance of Worter.\n-   `METHOD` is an HTTP request method, in lowercase. For example `app.get`,\n    `app.post` and so on.\n-   `PATH` is a specified path to handle.\n-   `HANDLER` is the function executed when the route is matched.\n\nIt is highly-inpired by [express.js](https://expressjs.com/).\n\nThe following examples illustrate defining simple routes.\n\nRespond with `Hi!` on the homepage:\n\n```typescript\napp.get(\"/\", (request, response) =\u003e {\n    return response.text(\"Hi!\");\n});\n```\n\nRespond to `POST` request on the root route (`/`), the application’s home page:\n\n```typescript\napp.post(\"/\", (request, response) =\u003e {\n    return response.text(\"POST request accepted\");\n});\n```\n\nRespond to a `PUT` request to the `/product` route:\n\n```typescript\napp.put(\"/product\", (request, response) =\u003e {\n    return response.text(\"PUT request accepted\");\n});\n```\n\nRespond to a `DELETE` request to the `/product` route:\n\n```typescript\napp.delete(\"/product\", (request, response) =\u003e {\n    return response.text(\"DELETE request accepted\");\n});\n```\n\nFor more details about routing, see the [routing guide](./guide/routing.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyk%2Fworter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyk%2Fworter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyk%2Fworter/lists"}