{"id":13795587,"url":"https://github.com/RienNeVaPlus/type-arango","last_synced_at":"2025-05-12T23:32:25.970Z","repository":{"id":40775573,"uuid":"177680893","full_name":"RienNeVaPlus/type-arango","owner":"RienNeVaPlus","description":"🥑 TypeArango manages ArangoDB collections, documents, relations and routes by taking advantage of TypeScript typings.","archived":false,"fork":false,"pushed_at":"2022-10-07T22:32:53.000Z","size":1676,"stargazers_count":65,"open_issues_count":4,"forks_count":15,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-05T13:06:54.523Z","etag":null,"topics":["arangodb","decorators","foxx-service","orm","roles","routes","typescript"],"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/RienNeVaPlus.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":"2019-03-25T23:35:54.000Z","updated_at":"2025-02-19T05:00:34.000Z","dependencies_parsed_at":"2023-01-19T14:45:16.161Z","dependency_job_id":null,"html_url":"https://github.com/RienNeVaPlus/type-arango","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RienNeVaPlus%2Ftype-arango","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RienNeVaPlus%2Ftype-arango/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RienNeVaPlus%2Ftype-arango/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RienNeVaPlus%2Ftype-arango/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RienNeVaPlus","download_url":"https://codeload.github.com/RienNeVaPlus/type-arango/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253841011,"owners_count":21972579,"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":["arangodb","decorators","foxx-service","orm","roles","routes","typescript"],"created_at":"2024-08-03T23:00:59.093Z","updated_at":"2025-05-12T23:32:25.350Z","avatar_url":"https://github.com/RienNeVaPlus.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/logo.png\" alt=\"TYPE-ARANGO\" /\u003e\n\u003c/p\u003e\n\n\u003ch6 align=\"center\"\u003e\n    Powerful decorators for \u003ca href=\"https://www.arangodb.com\"\u003eArangoDB\u003c/a\u003e \u003ca href=\"https://docs.arangodb.com/3.4/Manual/Foxx/\"\u003eFoxx Apps\u003c/a\u003e when working with TypeScript.\n\u003c/h6\u003e\n\n\u003cp align=\"center\"\u003e\n\tTypeArango manages ArangoDB \u003ccode\u003ecollections\u003c/code\u003e, \u003ccode\u003edocuments\u003c/code\u003e, \u003ccode\u003erelations\u003c/code\u003e and \u003ccode\u003eroutes\u003c/code\u003e\u003cbr\u003eby taking advantage of TypeScript's typings. It comes with a fast and easy to use \u003cstrong\u003epermission\u003cbr/\u003esystem\u003c/strong\u003e, provides an \u003cstrong\u003eORM\u003c/strong\u003e, event \u003cstrong\u003elisteners\u003c/strong\u003e, \u003cstrong\u003edocumented endpoints\u003c/strong\u003e as well as plenty of\u003cbr/\u003eother tools to make it fun to build ReST APIs in a declarative \u0026 elegant manner.\n\t\u003cbr/\u003e\n\t\u003csub\u003e\u003ci\u003eTypeArango is probably the \u003ca href=\"#-worlds-fastest-way-to-create-documented-endpoints\"\u003efastest\u003c/a\u003e way of setting up documented \u0026 validated endpoints.\u003c/i\u003e\u003c/sub\u003e\n\u003c/p\u003e\n\n![divider](./assets/divider.png)\n\n### ⭐ Features\n- **Beautiful Code** thanks to decorators\n- **A single Schema** for all TypeScript environments\n- **[Manages ArangoDB Collections](./API.md#collectionofdocument-options)** by deriving their information from entities classes\n- **[Manages ArangoDB Indexes](./API.md#indextype-options)** by decorating attributes with `@Index(type, options)`\n- **[Auto Schema from types](./API.md#-en-hanced-joi)** derives typing information into `joi` schemas\n- **[Auto Documentation](#-worlds-fastest-way-to-create-documented-endpoints)** optimized swagger docs from types and decorators\n- **[Route Decorators](./API.md#route--get-post-put-patch-delete--list)** for creating and documenting `Foxx.Routes` as simple as `@Route.POST(input =\u003e string())`.\n- **[Attribute-based authorization](./examples/2-roles)** with `reader` and `writer` roles\n- **[Route-based authorization](./API.md#routegroupscreators-readers-updaters-deleters)** with `creators`, `readers`, `updaters` and `deleters`\n- **[Request-based authorization](./API.md#routerolesrolefunctions)** on entity- or global basis\n- **[CRUD like](./API.md#crud-like)** route setup with `@Route.use('GET', 'POST', ...)`\n- **[Custom Routes](./API.md#route--get-post-put-patch-delete--list)** with input schemas and access roles\n- **[Validate Input Data](./API.md#attributeschema-readers-writers)** by describing the entity or providing joi schemas for routes\n- **[Event Listener](./API.md#-listener)** on a document or attribute basis to globally modify collection data\n- **[Internationalize document values](./API.md#-typei18n)** and return translated strings based upon the session or a parameter\n- **[Advanced ReST features](./API.md#route--get-post-put-patch-delete--list)** for returning lists and limiting output\n- **[Logging integrated](./API.md#-configuration)** for an easy setup and debugging\n\n![divider](./assets/divider.small.png)\n\n### 💨 Shortcuts\n- 🛫 **[Getting started](#-getting-started)**\n- 📘 **[Tutorial Examples](./examples)**\n- 📗 **[API Reference](./API.md)**\n\n![divider](./assets/divider.small.png)\n\n🌞 **TypeArango is in development and will receive additional features.** **Contributors wanted** 🙋\n\n[![Mentioned in Awesome ArangoDB](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/RienNeVaPlus/awesome-arangodb)\n[![last-commit][github-last-commit]][github-last-commit-url]\n[![version][github-version]][github-version-url]\n[![npm][npm-badge]][npm-badge-url]\n[![license][npm-license]][npm-license-url]\n![size][shields-size]\n\n![divider](./assets/divider.png)\n\n### 📝 Example\n\nThe example will setup a User entity stored inside a Users collection with a total of 6 documented routes.\n\n\u003e Various other examples of how to use typeArango with certain features can be found in the 📘 **[examples](./examples)** folder.\n\n```ts\nimport { Document, Entity, Type, Collection, Entities, Route, Authorized, Index, Related, Attribute, OneToMany, RouteArg } \n  from 'type-arango'\n\n// `User` document entity\n@Document() class User extends Entity {\n    @Index(type =\u003e 'hash')\n    @Attribute(str =\u003e str.email())\n    email: string\n    \n    @Attribute()\n    name: string\n    \n    @Authorized(readers =\u003e ['viewer','admin'], writers =\u003e ['admin'])\n    @Attribute(nr =\u003e nr.min(0).max(100))\n    rating: number\n    \n    @Attribute()\n    createdAt: Type.DateInsert\n    \n    @OneToMany(type =\u003e Address, Address =\u003e Address.owner)\n    addresses: Related\u003cAddress[]\u003e\n}\n\n// `Users` collection\n@Collection(of =\u003e User)\n@Route.groups(\n    creators =\u003e ['guest'],\n    readers =\u003e ['user', 'admin'],\n    writers =\u003e ['viewer', 'admin'],\n    deleters =\u003e ['admin']\n)\n@Route.use('GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'LIST')\nexport class Users extends Entities {\n    @Route.GET(\n        path =\u003e ':id/addresses',\n        roles =\u003e ['viewer'],\n        summary =\u003e 'Returns User Address[]'\n    ) static GET({param}: RouteArg){\n        const user = Users.find(param.id)\n        return user.relation('addresses')\n    }\n    \n    @Route.GET(\n        path =\u003e 'query',\n        $ =\u003e ({\n            id: $(String).required()\n        }),\n        roles =\u003e ['guest'],\n        summary =\u003e 'Runs a query'\n    )\n    static QUERY({_, param: { id }}: RouteArg){\n        return _ `FOR item IN Items\n                    FILTER item.id == ${id}\n                    RETURN item`\n    }\n}\n```\n\n![divider](./assets/divider.png)\n\n### ⚡ World's fastest way to create documented endpoints\n\nTypeArango uses the provided entity types to validate and document routes, for example a simple `@Route.all` creates five fully documented routes with a role system in place. \n\n![Swagger Screenshot](./assets/swagger.screen.png)\n\u003csub\u003e*Screenshot from ArangoDBs Web Interface*\u003c/sub\u003e\n\n![divider](./assets/divider.png)\n\n### 🛫 Getting started\n\n#### 1. Setup ArangoDB Foxx service\n\nIf you don't have a foxx service running yet, you can create one by using \n[arangodb-typescript-setup](https://github.com/RienNeVaPlus/arangodb-typescript-setup).\n\n\u003e TypeArango requires ArangoDB `3.4.4` or newer.\n\n![divider](./assets/divider.small.png)\n\n#### 2. Install\n\n```\nyarn add --D type-arango\n```\nor\n```\nnpm i --save-dev type-arango\n```\n![divider](./assets/divider.small.png)\n\n#### 3. Create the Entities\n\nRead the 📘 [Examples](./examples) or dive into the 📗 [API Reference](./API.md)\n\n\n![divider](./assets/divider.small.png)\n\n#### 4. Setup\n\n`typeArango()` has to be called **before** the entities are imported, it returns a function to be called **after** the decorators have been applied. It takes an optional 📝 [Configuration](./API.md#-configuration) argument.\n\n**shared/entities/index.ts**:\n```ts\nimport typeArango from 'type-arango'\n\nconst complete = typeArango({\n    // Configuration\n})\n\nexport * from './User'\n\ncomplete()\n```\n\n\n![divider](./assets/divider.small.png)\n\n#### 5. Create routes\nWhen using the `@Route` decorator, it is required to provide the `Foxx.Router`\nto TypeArango by calling `createRoutes(router)`.\n\n**foxx-service/main.ts**:\n```ts\nimport createRouter from '@arangodb/foxx/router'\nimport {createRoutes} from 'type-arango'\n\n// Initialize all entities before creating the routes\nimport * as _Entities from 'shared/entities'\n\n// Create the foxx router and hand it to type-arango\nconst router = createRoutes( createRouter() )\n```\n\nAs the routes are built by the `@Route.*` decorators, it is required to import all\nentities before calling `createRoutes(Foxx.Router)`.\n\n![divider](./assets/divider.png)\n\n### 📚 Documentation\n\nRead the 📘 [Examples](./examples) first, then dive into the 📗 [API Reference](./API.md).\n\n![divider](./assets/divider.png)\n\n### 🌻 Credits\n- type-arango is inspired by [TypeORM](https://github.com/typeorm/typeorm) and [type-graphql](https://github.com/19majkel94/type-graphql)\n\n[github-version]: https://img.shields.io/github/package-json/v/riennevaplus/type-arango.svg\n[github-version-url]: https://github.com/RienNeVaPlus/type-arango/blob/master/package.json\n[github-last-commit]: https://img.shields.io/github/last-commit/riennevaplus/type-arango.svg\n[github-last-commit-url]: https://github.com/RienNeVaPlus/type-arango/commits/master\n[npm-badge]: https://img.shields.io/npm/v/type-arango.svg\n[npm-badge-url]: https://www.npmjs.com/package/type-arango\n[npm-license]: https://img.shields.io/npm/l/type-arango.svg\n[npm-license-url]: https://github.com/ionic-team/stencil/blob/master/LICENSE\n[shields-size]: https://img.shields.io/github/repo-size/riennevaplus/type-arango.svg\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRienNeVaPlus%2Ftype-arango","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRienNeVaPlus%2Ftype-arango","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRienNeVaPlus%2Ftype-arango/lists"}