{"id":19091358,"url":"https://github.com/andrei-cacio/ironwing","last_synced_at":"2025-12-12T04:58:29.124Z","repository":{"id":23042960,"uuid":"26395959","full_name":"andrei-cacio/ironwing","owner":"andrei-cacio","description":"universal, framework agnostic, transport layer","archived":false,"fork":false,"pushed_at":"2021-10-21T17:58:57.000Z","size":369,"stargazers_count":16,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T07:57:51.917Z","etag":null,"topics":["ajax","xhr"],"latest_commit_sha":null,"homepage":"http://andrei-cacio.github.io/ironwing","language":"JavaScript","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/andrei-cacio.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":"2014-11-09T13:11:58.000Z","updated_at":"2024-06-02T08:51:22.000Z","dependencies_parsed_at":"2022-08-28T23:22:24.299Z","dependency_job_id":null,"html_url":"https://github.com/andrei-cacio/ironwing","commit_stats":null,"previous_names":["andrei-cacio/mjs"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-cacio%2Fironwing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-cacio%2Fironwing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-cacio%2Fironwing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-cacio%2Fironwing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrei-cacio","download_url":"https://codeload.github.com/andrei-cacio/ironwing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249494042,"owners_count":21281659,"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":["ajax","xhr"],"created_at":"2024-11-09T03:13:12.954Z","updated_at":"2025-12-12T04:58:29.067Z","avatar_url":"https://github.com/andrei-cacio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/ironwing.svg)](http://badge.fury.io/js/ironwing)\n[![Bower version](https://badge.fury.io/bo/ironwing.svg)](http://badge.fury.io/bo/ironwing)\n[![Build Status](https://travis-ci.org/andrei-cacio/ironwing.svg?branch=master)](https://travis-ci.org/andrei-cacio/ironwing)\n\n# About\n\nIn a few words, **ironwingjs** is a lightweight, isomorphic, framework-agnostic JavaScript library. **ironginwjs** is ment to be super easy to use and easy to integrate on any app. Out of the box it offers CRUD manipulation over a REST API interface.\n\n### Installation\n\n```sh\n$ npm install ironwing\n```\n\n### How it works\n\nIronwing was ment to be simple. So let's say we have the `/api/users` endpoint and we want to manipulate the data that's coming from that API.\n\n```javascript\n// Tell ironwing to interact with the /api base path for all operations\nironwing.base = '/api';\n\n// Fetch a collection and make a GET hit on /api/users\nironwing('users').then((users) =\u003e {\n  // do something with users collection\n});\n\n// Fetch a single resource\nironwing('users', 100).then((user) =\u003e {\n  // do something with the fetched user resource\n});\n\n// Update a resource\nironwing('users', 100).then((user) =\u003e {\n  // access the resource attributes via the .attr object\n  user.attr.name = 'Carl';\n  user.update();\n});\n\n// Delete a resource\nironwing('users', 100).then((user) =\u003e {\n  user.delete();\n});\n```\n\n#### REST\nHere is a map of the endpoints *ironwing* will hit on every operation\n\n| Action            | Method | URL        | Returns    |\n| ----------------- | -------|------------|----------- |\n| ironwing('users', 1) | GET    | /users/:id | Model      |\n| ironwing('users')    | GET    | /users     | Collection |\n| user.update()     | PUT    | /users/:id | Model      |\n| ironwing.create()        | POST   | /users     | Model      |\n| user.delete()     | DELETE | /users/:id | NULL       |\n\n### Core concepts\n___\n\n#### Adapters\n\nAn adapter is an object which follows a predefined interface so that it can be integrated with ironwing. Out of the box, ironwingjs comes with a ***JSON*** adapter which is an intermediate object that communicates with the `XMLHttpRequest` API. The developer doesn't interact directly with the adapter. The adapter is used *“under the hood”* by **ironwing**. The main purpose of adapters is to easily modify how **ironwing** interacts with the server. Anyone can write their own adapter and use it with ironwingjs. By default, ironwing loads the ***JSON*** adapter. You only have to specify the API's path so ironwing can communicate with your service properly.\nHere's a simple example:\n```javascript\nimport ironwing from './ironwing';\n\nironwing.base = '/api';\n```\n### Storage\n\nBy default, **ironwing** has a local *(heap)* storage. After **ironwing** fetches a new model, by default it stores it locally for later use. So for example if we were to fetch data from an endpoint called ***/users/100***:\n```javascript\nironwing('users', 100).then((user) =\u003e { \n    console.log(user.attr.name); \n});\n```\nWe can later on retrieve that model from memory without any extra trips to the server, by simply calling\n```javascript \nvar userModel =  ironwing.storage.find('users', 100);\n```\nOr, if we fetched a collection\n```javascript\nironwing('users',).then((users) =\u003e { \n  console.log(users.length); \n});\n```\nwe can later on get one or all users type model\n```javascript\nvar usersCollection =  ironwing.storage.findAll('users');\n```\nFor the moment, only the default storage can be used. In future releases we hope to implement a way to switch between storage implementations like an adapter for *local storage* so you can save the state of your models after refresh.\n\n### Proxy objects\n\nThe constructor method ironwing() is basically a factory method which returns `Model` instances. Each model exposes CRUD methods for manipulating your data. However, **ironwing** never modifies the raw JSON data directly. It exposes a ***proxy object*** as an intermediate. Each model object has a `.attr` object which contains a camel cased transformation of the JSON response. Everything you edit on the *attr proxy object*, it will be later synced with the original raw response and sent to the back-end. This technique offers control over what gets edited and what doesn't. In future releases, with the help of the proxy object, some cool features can be added like validators on attributes.\n\nA quick create and update example:\n```javascript\nimport ironwing from './ironwing';\n\nvar userData = {\n    first_name: 'Jon',\n    last_name: 'Doe';\n};\n\nironwing.base = '/api';\nironwing.create('users', userData).then((userModel) =\u003e {\n    /**\n    * a POST request is sent to the server\n    * /api/users\n    */\n    userModel.attr.firstName = 'Jon';\n    userModel.attr.lastName = 'Doe';\n\n    userModel.update().then(() =\u003e {\n        /**\n        * a PUT request is sent to the server\n        * /api/users/:id\n        */\n    });\n});\n```\n\n---\n\n# ironwingjs in [Today Software Magazine](http://www.todaysoftmag.com)\n\n[Introducing Ironwingjs](http://www.todaysoftmag.com/article/1703/introducing-ironwingjs)\n\nLicense\n----\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei-cacio%2Fironwing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrei-cacio%2Fironwing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei-cacio%2Fironwing/lists"}