{"id":19361560,"url":"https://github.com/ajuhos/api-core","last_synced_at":"2025-07-24T03:07:00.524Z","repository":{"id":12283919,"uuid":"71443163","full_name":"ajuhos/api-core","owner":"ajuhos","description":" Model-based dynamic multi-level APIs for any provider, plus multiple consumption channels","archived":false,"fork":false,"pushed_at":"2023-11-11T08:05:33.000Z","size":848,"stargazers_count":5,"open_issues_count":20,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-01T14:45:28.644Z","etag":null,"topics":["api","api-service","edges","model"],"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/ajuhos.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-20T08:48:13.000Z","updated_at":"2024-07-26T06:45:40.000Z","dependencies_parsed_at":"2024-06-18T23:08:23.252Z","dependency_job_id":null,"html_url":"https://github.com/ajuhos/api-core","commit_stats":{"total_commits":157,"total_committers":6,"mean_commits":"26.166666666666668","dds":"0.36305732484076436","last_synced_commit":"1ad65e2095ba255aa1e8041ec3725a4f5af8e034"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ajuhos/api-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajuhos%2Fapi-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajuhos%2Fapi-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajuhos%2Fapi-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajuhos%2Fapi-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajuhos","download_url":"https://codeload.github.com/ajuhos/api-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajuhos%2Fapi-core/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266786798,"owners_count":23983871,"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-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["api","api-service","edges","model"],"created_at":"2024-11-10T07:23:54.961Z","updated_at":"2025-07-24T03:07:00.502Z","avatar_url":"https://github.com/ajuhos.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### API Core\n\nLightweight framework for building dynamic multi-level APIs for any provider (Express, socket.io, etc.), consumable via multiple channels (HTTP, socket.io, etc.)\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ajuhos/api-core/master/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/ajuhos/api-core.svg)](https://github.com/ajuhos/api-core/issues)\n[![Build Status](https://travis-ci.org/ajuhos/api-core.svg?branch=master)](https://travis-ci.org/ajuhos/api-core)\n[![Coverage Status](https://coveralls.io/repos/github/ajuhos/api-core/badge.svg?branch=master)](https://coveralls.io/github/ajuhos/api-core?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4b1dd6ebe9eb4634aef02811c374efaf)](https://www.codacy.com/app/ajuhos/api-core?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=ajuhos/api-core\u0026amp;utm_campaign=Badge_Grade)\n\n## Features\n\n - Dynamic model-based API routes\n - Extensible API queries with pre- and post-query steps  (coming soon)\n     - Transformations (via api-core-mapper or your own library)\n     - Authentication, ACL (via node-acl, passport, etc.)\n - Multi level API routes (eg. /schools/42/students/3/courses)\n - Multi channel APIs (eg. consuming HTTP and socket.io via api-provider packages)\n - Multi database APIs (different database for every route, if you need)\n - Versioned APIs\n - Swagger compatibility (via [api-core-mapper](https://github.com/ajuhos/api-core-mapper))\n\n## Installation\n\nTo install the latest version, use NPM:\n\n```bash\n$ npm install api-core\n```\n\n## Basics\n\n#### API Edges\n\nIn API Core every API is built from edges. \nAn edge defines operations and relations of a Data Model.\n\nEvery edge provides the following operations:\n\n - List entries (eg. GET /students)\n - Get an entry (eg. GET /students/3)\n - Create an entry (eg. POST /students)\n - Replace/Update an entry (eg. PUT /students/3)\n - Edit an entry (eg. PATCH /students/3)\n - Remove an entry (eg. DELETE /students/3)\n - Access to operations of one-to-one relations (eg. GET /students/3/class)\n - Access to operations of one-to-many relations (eg. GET /schools/42/students/3/courses) \n - Access to custom operations (eg. PUT /students/3/rename)\n\nEvery operation provides standard features like filtering, sorting, \npopulation and pagination.\n\n**Also every operation is available via all enabled channels.**\n\nSo while you can list students via a HTTP request, you also can do the \nsame via a socket.io message or any custom channel defined by you.\n\n#### API Providers\n\nYou can use API Providers to make your API consumable via different\nchannels.\n\nWe have (or working on) providers for the following channels:\n \n - HTTP\n     - Express: [api-provider-express](https://github.com/ajuhos/api-provider-express)\n     - _Koa: api-provider-koa (coming soon)_\n     - _Restify: api-provder-restify (coming soon)_\n     - Ellipse: [api-provider-ellipse](https://github.com/ajuhos/api-provider-ellipse)\n - Socket\n     - _socket.io: api-provider-socket.io (coming soon)_\n     \nAlso you can implement your own API provider.\n\n#### Data Models\n\nEvery API requires a set of data models. As with API Providers, you have\na bunch of options when choosing your library for creating the models.\n\nWe have (or working on) data model libraries for the following frameworks:\n\n  - MongoDB: [api-model-mongoose](https://github.com/ajuhos/api-model-mongoose)\n  - _MySQL_\n  - ...\n  \nAlso you can implement your own API model library.\n\n## Usage\n\nWe have two working examples in the following repository, one with a \nlocal in-memory model (master branch) and one with a Mongoose model (mongodb branch).\n\nWorking Demo: [api-demo](https://github.com/ajuhos/api-demo)\n\n**A complete API with 5 models and relations in 67 lines:**\n```typescript\nimport {ApiEdgeError, OneToOneRelation, OneToManyRelation, ApiEdgeQueryResponse, Api} from \"api-core\";\nimport {MongooseModelFactory} from \"api-model-mongoose\";\nimport {EllipseApiRouter} from \"api-provider-ellipse\";\nimport * as mongoose from \"mongoose\";\n\nconst Ellipse = require('ellipse'),\n      app = new Ellipse;\n\nmongoose.Promise = global.Promise;\nmongoose.connect(\"mongodb://localhost/api-demo\");\nconst ObjectId = mongoose.Schema.Types.ObjectId;\n\nconst studentEdge =\n          MongooseModelFactory.createModel(\"student\", \"students\", {\n              id: String,\n              firstName: String,\n              lastName: String,\n              email: String,\n              phone: String,\n              school: { type: ObjectId, ref: 'school' },\n              classId: { type: ObjectId, ref: 'class' }\n          }),\n      classEdge =\n          MongooseModelFactory.createModel(\"class\", \"classes\", {\n              id: String,\n              name: String,\n              semester: String,\n              room: String,\n              school: { type: ObjectId, ref: 'school' }\n          }),\n      courseEdge =\n          MongooseModelFactory.createModel(\"course\", \"courses\", {\n              id: String,\n              name: String,\n              class: { type: ObjectId, ref: 'class' },\n              courseType: { type: ObjectId, ref: 'courseType' }\n          }),\n      courseTypeEdge =\n          MongooseModelFactory.createModel(\"courseType\", \"courseTypes\", {\n              id: String,\n              name: String\n          }),\n      schoolEdge =\n          MongooseModelFactory.createModel(\"school\", \"schools\", {\n              id: String,\n              name: String,\n              address: String,\n              phone: String\n          });\n\nconst api10\n    = new Api({name: 'test-service', version: '1.0'})\n        .edge(studentEdge);\n\nconst api11\n    = new Api({name: 'test-service', version: '1.1'})\n        .edge(studentEdge)\n        .edge(classEdge)\n        .edge(courseEdge)\n        .edge(courseTypeEdge)\n        .edge(schoolEdge);\n\napp.use(require('body-parser').json());\n\nconst router = new EllipseApiRouter(api11, api10);\nrouter.apply(app);\n\napp.listen(8080);\n```\n\n## Tests\n\nWe maintain high test coverage to provide a reliable framework \nfor your APIs.\n\nTo run tests, execute the following NPM commands:\n\n```bash\n$ npm install\n$ npm test\n```\n\n## License\n\nThe [MIT License](https://github.com/ajuhos/api-core/blob/master/LICENSE). Free forever. :)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajuhos%2Fapi-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajuhos%2Fapi-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajuhos%2Fapi-core/lists"}