{"id":20985785,"url":"https://github.com/faustogerman/Rhino","last_synced_at":"2025-05-14T17:32:12.778Z","repository":{"id":62421470,"uuid":"268218876","full_name":"faustotnc/Rhino","owner":"faustotnc","description":"Rhino 🦏 - Deno Framework for scalable APIs.","archived":false,"fork":false,"pushed_at":"2023-04-08T18:32:31.000Z","size":2139,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T12:15:32.745Z","etag":null,"topics":["backend","deno","http","rest-api","server"],"latest_commit_sha":null,"homepage":null,"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/faustotnc.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":"2020-05-31T05:59:37.000Z","updated_at":"2023-04-08T18:32:37.000Z","dependencies_parsed_at":"2022-11-01T17:32:22.999Z","dependency_job_id":null,"html_url":"https://github.com/faustotnc/Rhino","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustotnc%2FRhino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustotnc%2FRhino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustotnc%2FRhino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustotnc%2FRhino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faustotnc","download_url":"https://codeload.github.com/faustotnc/Rhino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225191551,"owners_count":17435564,"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":["backend","deno","http","rest-api","server"],"created_at":"2024-11-19T06:10:13.164Z","updated_at":"2025-05-14T17:32:06.689Z","avatar_url":"https://github.com/faustotnc.png","language":"TypeScript","readme":"# Rhino 🦏 - The Framework for scalable APIs.\n\n🎉 RC-2 introduced out-of-the-box support for parsing JSON and Form data from the request body, as well as the ability to send files to the client in the response body. [Check out the highlights!](https://github.com/faustotnc/Rhino/releases) 🎉\n\nRhino is an Angular-inspired framework for creating scalable REST-APIs. It provides a route-endpoint architecture that takes advantage of the many features provided by the TypeScript language. It encourages a project structure that is self-described and consistent, so that programmers within the project can collaborate seamlessly.\n\n[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/faustotnc/rhino?include_prereleases\u0026color=3d6057)](https://github.com/faustotnc/Rhino/releases)\n[![tag](https://img.shields.io/badge/deno-\u003e=1.0.0-green.svg?color=3d6057)](https://github.com/denoland/deno)\n[![tag](https://img.shields.io/badge/std-0.56.0-green.svg?color=3d6057)](https://github.com/denoland/deno)\n[![GitHub license](https://img.shields.io/github/license/faustotnc/rhino?color=bf9f32)](https://github.com/faustotnc/Rhino/blob/master/LICENSE)\n\n\nRhino comes with five different modules for strong REST-API creation:\n\n- **@RhinoServer** - *Class Decorator*: Creates a new server.\n- **RhinoRouter** - *Class*: Defines the routes and endpoints for a server.\n- **@RhinoEndpoint** - *Class Decorator*: Defines an endpoint handler.\n- **@RhinoHook** - *Class Decorator*: Defines a middleware that can be hooked to the request-response middleware pipeline.\n- **@RhinoError** - *Class Decorator*: Defines an error handler.\n\n\n\n## Hello World\n\n### Step 1) Create a Server\nCrete a file named `server.ts`, then copy and paste the following code inside it.\n``` typescript\nimport {\n    RhinoServer, OnServerListening,\n    ServerOptions, RunServers\n} from \"https://deno.land/x/rhino/mod.ts\";\n\n// The server's router (next step)\nimport { myRouter } from  './router.ts';\n\n// Creates a server\n@RhinoServer({\n    port: 3200,\n    router: myRouter\n})\nexport class myServer implements OnServerListening {\n    /** Executes once the server starts listening to requests */\n    public onListening(app: ServerOptions) {\n        console.log(`\\nListening to request made to ${app.hostname}:${app.port}`)\n    }\n}\n\n/**\n * Runs all the servers for this application.\n * (A single application can have multiple servers)\n */\nRunServers([myServer]);\n```\n\n\n\n### Step 2) Create a Router\nCreate a file named `router.ts`, then copy and paste the following code inside it.\n``` typescript\nimport { RhinoRouter } from \"https://deno.land/x/rhino/mod.ts\";\n\n// Creates a new router\nconst ROUTER = new RhinoRouter();\n\n// Endpoints (next step)\nimport { helloWorld } from \"./hello_world.endpoint.ts\";\n\n// Mounts the helloWorld endpoint to the root of the server\nROUTER.addEndpoint(helloWorld);\n\n// Exports the router\nexport const myRouter = ROUTER;\n```\n\n\n\n### Step 3) Create an Endpoint\nCreate a file named `hello_world.endpoint.ts`, then copy and paste the following code inside it.\n``` typescript\nimport {\n    RhinoEndpoint, OnEndpointCalled, RhinoRequest,\n    RhinoResponse, NextHook, NextError, HttpMethod, MIMEType\n} from \"https://deno.land/x/rhino/mod.ts\";\n\n\n@RhinoEndpoint({\n    path: \"/hello\", // The path for this endpoint\n    method: HttpMethod.GET, // This endpoint will only listen to GET requests\n})\nexport class helloWorld implements OnEndpointCalled {\n\n    // The constructor accepts the following parameters (in that order):\n    // The Request Object,\n    // The Response Object,\n    // The Next Hook function (middlewares of type \"After\"), and\n    // The Error function\n    constructor(\n        private req: RhinoRequest,\n        private res: RhinoResponse,\n        private next: NextHook,\n        private error: NextError\n    ) { }\n\n    /** Executed when this endpoint is requested */\n    public onEndpointCall() {\n        // Sets the content type, and sends data to the client\n        this.res.contentType(MIMEType.TextHTML).send(\"\u003ch1\u003eHello Rhinos 🦏!\u003c/h1\u003e\");\n    }\n}\n```\nOpen a command line and run ``$ deno run -c ./tsconfig.json --allow-net server.ts``.\n\n**NOTE:** Using Rhino requires the ``\"experimentalDecorators\": true`` in your project's tsconfig.json file.\n\nFinally, navigate to `localhost:3200/hello` to be greeted by your newly created Rhino server.\n\n\n\n## Scalability\nYou may be wondering, why so many files for a simple \"hello world\" project? The answer lies in scalability. Most real-world REST-APIs do not have a single file for all their code. Instead, the code is split into many files, folders, and sub-folders to create a robust application. Rhino takes care of all the thinking that goes behind defining a folder structure for your project by encouraging code refraction. To see an example of a simple Rhino project, visit the ``_example`` folder.\n\n\n\n**NOTE:** This project is still on its (very) early stages, and the definitions are subject to change.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaustogerman%2FRhino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaustogerman%2FRhino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaustogerman%2FRhino/lists"}