{"id":15877895,"url":"https://github.com/k1r0s/ritley-alpha","last_synced_at":"2025-10-09T07:38:36.152Z","repository":{"id":86020405,"uuid":"117271880","full_name":"k1r0s/ritley-alpha","owner":"k1r0s","description":"[DEPRECATED] use k1r0s/ritley instead","archived":false,"fork":false,"pushed_at":"2018-05-30T16:03:26.000Z","size":699,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T23:29:22.246Z","etag":null,"topics":["back-end","dependency-injection","oop","rest-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/k1r0s.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-12T17:55:04.000Z","updated_at":"2018-09-02T13:33:02.000Z","dependencies_parsed_at":"2023-03-11T22:00:57.674Z","dependency_job_id":null,"html_url":"https://github.com/k1r0s/ritley-alpha","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/k1r0s/ritley-alpha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1r0s%2Fritley-alpha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1r0s%2Fritley-alpha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1r0s%2Fritley-alpha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1r0s%2Fritley-alpha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k1r0s","download_url":"https://codeload.github.com/k1r0s/ritley-alpha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1r0s%2Fritley-alpha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000961,"owners_count":26082973,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["back-end","dependency-injection","oop","rest-api"],"created_at":"2024-10-06T02:04:48.020Z","updated_at":"2025-10-09T07:38:36.136Z","avatar_url":"https://github.com/k1r0s.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca\u003e\u003cimg src=\"https://i.imgur.com/6BKD8jW.png\"\u003e\u003c/a\u003e\n  \u003ch2\u003eRitley JS\u003c/h2\u003e\n\u003c/p\u003e\n\n\n[![version](https://img.shields.io/npm/v/ritley.svg)](https://www.npmjs.com/package/ritley/)\n[![dependencies](https://david-dm.org/k1r0s/ritley/status.svg)](https://david-dm.org/k1r0s/ritley/status.svg)\n[![downloads](https://img.shields.io/npm/dm/ritley.svg)](https://www.npmjs.com/package/ritley)\n\n#### About\nRitley is a small package __with only two dependencies__ that allows you to create REST applications in no time. You can define `Resources` as entities which handle requests to the server. Create as many instances as you need. Also you can extend (inherit) previous entities to build more complex behaviors. Ritley is build on top `kaop` OOP features. [You may use this package to provide Dependency Injection, Method overriding, Transaction Advices, etc](https://github.com/k1r0s/kaop).\n\n#### Disclaimer\nRitley is still on development and it doesn't provide SSL support yet so, for now, I don't recommend use it on serious production environments.\n\n#### Getting Started\n\nInstall ritley:\n`npm install ritley --save`\n\nCreate a file structure like this:\n```\n├── public\n│   └── index.html\n├── ritley.cfg.js\n├── start.js\n└── package.json\n```\n\nRitley expects to receive a configuration file with some parameters which define its behavior such as these:\n```javascript\n// ./ritley.cfg.js\nmodule.exports = {\n  \"base\": `/rest`,                  // api resource prefix\n  \"static\": `${__dirname}/public`,  // static directory to serve your front\n  \"port\": 8080,                     // port to be used by ritley to run the app\n}\n```\nFirst you should use `setConfig` to set up providers that will take care of configuring modules. Start defining your resource by extending from `AbstractResource`. Then you can create instances providing your entity name to be handled:\n```javascript\n// ./start.js\nconst { setConfig, AbstractResource, extend } = require(\"ritley\");\n\nsetConfig(require(\"./ritley.cfg\")); // load configuration\n\nconst BasicResource = extend(AbstractResource, {\n  get(request, response) {          // curl localhost:8080/rest/dummy?id=1 -X GET -v\n    console.log(this.$abspath);     // \"rest/dummy\"\n    console.log(this.$uri);         // \"dummy\"\n    console.log(request.query);     // { \"id\": 1 }\n    response.statusCode = 200;\n    response.end();\n  },\n  post(request, response) {         // curl localhost:8080/rest/dummy -X POST --data '{ \"something\": 1 }' -v\n    console.log(request.toJSON());  // { \"something\": 1 }\n    response.statusCode = 200;\n    response.end();\n  },\n});\n\nnew BasicResource(\"dummy\");\n```\n\n#### In deep (wip)\nRitley rely on NodeJS default http package to perform 99% of its operations. This library is only a shell that helps you organize your code into OOP patterns and Resources. Say you have the following configuration file:\n```\n{\n  \"base\": `/api`,\n  \"static\": `${__dirname}/dist`,\n  \"port\": 8080,\n}\n```\n\n- If you browse `localhost:8080` ritley will try to search your `/dist/index.html`\n\n- If you browse `localhost:8080/js/bundle.js` ritley will try to search your `/dist/js/bundle.js`\n\nBasically if any route doesn't start by the api prefix which is `base`, then __ecstatic__ package will try to resolve it using configuration's `static` entry.\n\nSo, if you're requesting a POST to `localhost:8080/api/resource1` from anywhere, lets say `axios` within your JavaScript application, ritley will look if there is any resource listening that route for that HTTP verb.\n\nYou may create different resources by extending from basic ones if you need to handle auth or other complex behavior.\n\n#### Docs\nRitley uses Node's default http package to manage all stuff. You don't have to worry about learn another API but [this one](https://nodejs.org/api/http.html) that you may already known.\n\nAlthough there are a few aditions:\n\n- `request.query` contains a json representation of querystring parameters\n- `request.body` contains the payload represented in string\n- `request.buffer` contains the binary payload inside a buffer\n- `request.toJSON()` will try to convert request.body to json object using `JSON.parse`\n\nFor convenience inside any AbstractResource subclass you can access:\n\n```javascript\nthis.$uri       // resource name\nthis.$srv       // node http server (singleton)\nthis.$cfg       // ritley confg object (full)\nthis.$abspath   // `${this.$cfg.base}/${this.$uri}`;\n```\n\n#### Examples\n- Working 'getting started' [`example/` folder](https://github.com/k1r0s/ritley/tree/master/example)\n- [Repo example](https://github.com/k1r0s/micro-ritley-lowdb-example)\n- [Article based on previous repo](https://medium.com/@k1r0s/how-to-write-scalable-nodejs-services-code-examples-b48baa2d9eb9)\n#### Roadmap\n- Create examples for advanced behaviors\n- Setup testing\n- SSL support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1r0s%2Fritley-alpha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1r0s%2Fritley-alpha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1r0s%2Fritley-alpha/lists"}