{"id":13736281,"url":"https://github.com/Caesar2011/denotrain","last_synced_at":"2025-05-08T12:32:31.324Z","repository":{"id":56590398,"uuid":"257041046","full_name":"Caesar2011/denotrain","owner":"Caesar2011","description":"Web framework for Deno with often-used functions included","archived":false,"fork":false,"pushed_at":"2020-11-21T18:02:08.000Z","size":752,"stargazers_count":103,"open_issues_count":5,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-15T04:32:07.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Caesar2011.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}},"created_at":"2020-04-19T15:58:23.000Z","updated_at":"2023-12-19T12:39:17.000Z","dependencies_parsed_at":"2022-08-15T21:31:14.862Z","dependency_job_id":null,"html_url":"https://github.com/Caesar2011/denotrain","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caesar2011%2Fdenotrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caesar2011%2Fdenotrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caesar2011%2Fdenotrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caesar2011%2Fdenotrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Caesar2011","download_url":"https://codeload.github.com/Caesar2011/denotrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253068924,"owners_count":21848890,"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-08-03T03:01:18.788Z","updated_at":"2025-05-08T12:32:30.961Z","avatar_url":"https://github.com/Caesar2011.png","language":"TypeScript","readme":"# denotrain\n\nThis is a web server library inspired by [expressJS](https://expressjs.com) written for node. It supports routers, query parameters and url parameters. The library is desired to use with deno.\n\n![Deno Train Logo](./doc/denotrain-scaled.png)\n\n## Features\n\n - [Getting Started!](./doc/getting_started.md)\n - [Request handlers \u0026 lifecycle](./doc/handlers.md)\n - [Responses](./doc/responses.md)\n - Routing (see also \"Request handlers \u0026 lifecycle\")\n - [Body, query and parameters](./doc/parameters.md)\n - [Cookies](./doc/cookies.md)\n - View Engines / Templates\n - Logging\n - Extend application and requests\n - Custom Middleware\n   - Static\n   - Request Logging\n   - User Management\n   - Entity Validation (TODO)\n   - Database Connector (TODO)\n   - Permission System (TODO)\n\n## Example\n\nRun this example on port 3000 with `deno run --allow-net=0.0.0.0 https://deno.land/x/denotrain@v0.5.4/example/routers/example.ts`.\n\nTry the following routes:\n\n - `GET /`\n - `GET /doesnotexist`\n - `GET /admin`\n - `GET /17`\n - `GET /admin/edit`\n - `POST /formtest`\n\nMore examples are in this repository under `/examples`.\n\n```ts\nimport { Application, Router } from \"https://deno.land/x/denotrain@v0.5.4/mod.ts\";\n\n// Create a new application (port defaults to 3000, hostname to 0.0.0.0)\nconst app = new Application();\n// Optional: Generate router and hook routes to it\nconst router = new Router();\n\n// Middleware \napp.use((ctx) =\u003e {\n  // Add data to the response object and return undefined\n  // -\u003e Still passed to other handlers\n\n  // Add cookies to the deno train cookie handler\n  ctx.cookies[\"user.session\"] = \"qwertz\";\n  ctx.cookies[\"a\"] = \"123\";\n  ctx.cookies[\"b\"] = \"456\";\n  delete ctx.cookies[\"user.session\"];\n  return;\n});\n\n// this will only listen on GET requests\nrouter.get(\"/\", (ctx) =\u003e {\n  // Returning a string, JSON, Reader or Uint8Array automatically sets\n  // Content-Type header and no further router will match\n  return new Promise((resolve) =\u003e resolve(\"This is the admin interface!\")); \n});\nrouter.get(\"/edit\", async (ctx) =\u003e {\n  return \"This is an edit mode!\"; \n});\n\napp.get(\"/\", (ctx) =\u003e {\n  // Returning a json\n  return {\"hello\": \"world\"};\n});\n\n// Hook up the router on \"/admin\". The routes are now\n// available on \"/admin\" and \"/admin/edit\"\napp.use(\"/admin\", router);\n\napp.get(\"/:id\", (ctx) =\u003e {\n  // Use url parameters\n  return \"Hello World with ID: \" + ctx.req.params.id\n});\n\n// Make a post request; try it with sending json or url-form-encoded\n// and a corresponding Content-Type header\napp.post(\"/formtest\", async (ctx) =\u003e {\n  return ctx.req.body;\n});\n\n// Run the application on the specified port\nawait app.run();\n```\n\n## App Parameters\n\nThe constructor of `Application` accepts an object with options. All options are optional, and defaults are set for many values.\n\n - **`port`** (`number`, *default: `3000`*) Port of the server.\n\n - **`hostname`** (`string`, *default: `0.0.0.0`*) Hostname of the server. You also need to permit Deno to serve on this address by `--allow-net=0.0.0.0`.\n\n - **`certFile`** (`string`) Path to the HTTPS public certificate. If `certFile` and `keyFile` are present, Denotrain will automatically serve the server with HTTPS. You also need to permit Deno to access this file by `--allow-read=path/to/file.crt`\n\n - **`keyFile`** (`string`) Path to the HTTPS private key. You also need to permit Deno to access this file by `--allow-read=path/to/file.key`.\n\n - **`additionalServers`** (`ListenOptions[]`, *default: `[]`*) An array of objects, each may contain any of the four parameters listed above. It can be used to serve the application on additional servers.\n\n - **`logger`** (`Logger`, *default: `new SinkLogger([new ConsoleSink()])`*) An array of objects, each may contain any of the four parameters listed above. It can be used to serve the application on additional servers.\n\n - **`logLevel`** (`\"LOG\" | \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\" | \"CRITICAL\"`, *default: `\"LOG\"`*) All logs that are higher or equal to the specified log level are output. After initializing the application, the log level is set to the specified value. For production environments, `\"INFO\"` or `\"WARN\"` is recommended. See the documentation for more information.\n\n - **`cookieKey`** (`string`, *default: `\"train.ticket\"`*) The ticket that identifies the client in the `CookieStorage` is stored as an HTTP cookie. The key of that HTTP cookie is specified here.\n\n - **`cookieStorage`** (`CookieStorage`, *default: `new MemoryCookieStorage()`*) The storage of the cookies in which the keys and their associated values are stored. The default `MemoryCookieStorage` stores the values only temporarily until a server restart and is therefore not recommended for productive use.\n\n - **`cookieOptions`** (`CookieOptions`, *default: `{ maxAge: 60 * 60 * 24 }`*) Each time the HTTP cookie is set for the `CookieStorage`, HTTP cookie options are set. These can be specified here. More details can be found in the [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) or [in the Denotrain documentation](./doc/cookies.md).\n\n - **`cookieSecret`** (`string`, *default: `\"changeThis\"`*) To prevent session hijacking, the randomly generated user UUID is mixed with this secret. This prevents simple manipulation of the cookie. This secret should be changed, even in development environments. Furthermore, the secret should not be known to the users of the system.\n\n## Documentation\n\nView documentation on the [official documentation website](https://doc.deno.land/https/deno.land/x/denotrain@master/mod.ts).\n","funding_links":[],"categories":["Modules","基础设施"],"sub_categories":["Online Playgrounds","Assistants","Deno 源"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCaesar2011%2Fdenotrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCaesar2011%2Fdenotrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCaesar2011%2Fdenotrain/lists"}