All Projects → RienNeVaPlus → type-arango

RienNeVaPlus / type-arango

Licence: MIT license
🥑 TypeArango manages ArangoDB collections, documents, relations and routes by taking advantage of TypeScript typings.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to type-arango

route-decorators
ES7 decorators that simplify Koa and Express route creation
Stars: ✭ 71 (+29.09%)
Mutual labels:  routes, decorators
TvrboReact
Dream starter project: React, Redux, React Router, Webpack
Stars: ✭ 13 (-76.36%)
Mutual labels:  decorators
socket.io-react
A High-Order component to connect React and Socket.io easily
Stars: ✭ 67 (+21.82%)
Mutual labels:  decorators
radlkarte
Hand-crafted routing information for cyclists
Stars: ✭ 14 (-74.55%)
Mutual labels:  routes
twc
TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
Stars: ✭ 33 (-40%)
Mutual labels:  decorators
ngx-redux-core
The modern redux integration for Angular 6+
Stars: ✭ 32 (-41.82%)
Mutual labels:  decorators
djburger
Framework for safe and maintainable web-projects.
Stars: ✭ 75 (+36.36%)
Mutual labels:  decorators
mocha-allure2-example
Allure 2 Mocha examples
Stars: ✭ 18 (-67.27%)
Mutual labels:  decorators
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (-25.45%)
Mutual labels:  decorators
firebase-spring-boot-rest-api-authentication
Firebase Spring Boot Rest API Authentication
Stars: ✭ 172 (+212.73%)
Mutual labels:  roles
fastify-loader
The route loader for the cool kids!
Stars: ✭ 17 (-69.09%)
Mutual labels:  routes
view-admin-as
View the WordPress admin as a different role, switch between users, temporarily change your capabilities, set default screen settings for roles, manage your roles and capabilities.
Stars: ✭ 44 (-20%)
Mutual labels:  roles
ts-test-decorators
Write your tests in a Java-like annotation-driven manner via JS decorators
Stars: ✭ 37 (-32.73%)
Mutual labels:  decorators
xml-core
xml-core is a set of classes that make it easier to work with XML within the browser and node.
Stars: ✭ 18 (-67.27%)
Mutual labels:  decorators
arangodb
ArangoDB Starter - starts ArangoDB clusters & single servers with ease.
Stars: ✭ 77 (+40%)
Mutual labels:  arangodb
final-form-calculate
Decorator for calculating field values based on other field values in 🏁 Final Form
Stars: ✭ 111 (+101.82%)
Mutual labels:  decorators
tsed
📐 Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone.
Stars: ✭ 2,350 (+4172.73%)
Mutual labels:  decorators
serialize
Serializers for typescript based on decorators
Stars: ✭ 14 (-74.55%)
Mutual labels:  decorators
ansible-role-containerd
Ansible Role - containerd.io
Stars: ✭ 45 (-18.18%)
Mutual labels:  roles
futils
Utilities for generic functional programming
Stars: ✭ 21 (-61.82%)
Mutual labels:  decorators

TYPE-ARANGO

Powerful decorators for ArangoDB Foxx Apps when working with TypeScript.

TypeArango manages ArangoDB collections, documents, relations and routes
by taking advantage of TypeScript's typings. It comes with a fast and easy to use permission
system
, provides an ORM, event listeners, documented endpoints as well as plenty of
other tools to make it fun to build ReST APIs in a declarative & elegant manner.
TypeArango is probably the fastest way of setting up documented & validated endpoints.

divider

Features

divider

💨 Shortcuts

divider

🌞 TypeArango is in development and will receive additional features. Contributors wanted 🙋

Mentioned in Awesome ArangoDB last-commit version npm license size

divider

📝 Example

The example will setup a User entity stored inside a Users collection with a total of 6 documented routes.

Various other examples of how to use typeArango with certain features can be found in the 📘 examples folder.

import { Document, Entity, Type, Collection, Entities, Route, Authorized, Index, Related, Attribute, OneToMany, RouteArg } 
  from 'type-arango'

// `User` document entity
@Document() class User extends Entity {
    @Index(type => 'hash')
    @Attribute(str => str.email())
    email: string
    
    @Attribute()
    name: string
    
    @Authorized(readers => ['viewer','admin'], writers => ['admin'])
    @Attribute(nr => nr.min(0).max(100))
    rating: number
    
    @Attribute()
    createdAt: Type.DateInsert
    
    @OneToMany(type => Address, Address => Address.owner)
    addresses: Related<Address[]>
}

// `Users` collection
@Collection(of => User)
@Route.groups(
    creators => ['guest'],
    readers => ['user', 'admin'],
    writers => ['viewer', 'admin'],
    deleters => ['admin']
)
@Route.use('GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'LIST')
export class Users extends Entities {
    @Route.GET(
        path => ':id/addresses',
        roles => ['viewer'],
        summary => 'Returns User Address[]'
    ) static GET({param}: RouteArg){
        const user = Users.find(param.id)
        return user.relation('addresses')
    }
    
    @Route.GET(
        path => 'query',
        $ => ({
            id: $(String).required()
        }),
        roles => ['guest'],
        summary => 'Runs a query'
    )
    static QUERY({_, param: { id }}: RouteArg){
        return _ `FOR item IN Items
                    FILTER item.id == ${id}
                    RETURN item`
    }
}

divider

World's fastest way to create documented endpoints

TypeArango 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.

Swagger Screenshot Screenshot from ArangoDBs Web Interface

divider

🛫 Getting started

1. Setup ArangoDB Foxx service

If you don't have a foxx service running yet, you can create one by using arangodb-typescript-setup.

TypeArango requires ArangoDB 3.4.4 or newer.

divider

2. Install

yarn add --D type-arango

or

npm i --save-dev type-arango

divider

3. Create the Entities

Read the 📘 Examples or dive into the 📗 API Reference

divider

4. Setup

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 argument.

shared/entities/index.ts:

import typeArango from 'type-arango'

const complete = typeArango({
    // Configuration
})

export * from './User'

complete()

divider

5. Create routes

When using the @Route decorator, it is required to provide the Foxx.Router to TypeArango by calling createRoutes(router).

foxx-service/main.ts:

import createRouter from '@arangodb/foxx/router'
import {createRoutes} from 'type-arango'

// Initialize all entities before creating the routes
import * as _Entities from 'shared/entities'

// Create the foxx router and hand it to type-arango
const router = createRoutes( createRouter() )

As the routes are built by the @Route.* decorators, it is required to import all entities before calling createRoutes(Foxx.Router).

divider

📚 Documentation

Read the 📘 Examples first, then dive into the 📗 API Reference.

divider

🌻 Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].