
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
type-arango
Advanced tools
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.
@Index(type, options)
joi
schemasFoxx.Routes
as simple as @Route.POST(input => string())
.reader
and writer
rolescreators
, readers
, updaters
and deleters
@Route.use('GET', 'POST', ...)
🌞 TypeArango is in development and will receive additional features. Contributors wanted 🙋
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`
}
}
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.
Screenshot from ArangoDBs Web Interface
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.
yarn add --D type-arango
or
npm i --save-dev type-arango
Read the 📘 Examples or dive into the 📗 API Reference
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()
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)
.
Read the 📘 Examples first, then dive into the 📗 API Reference.
FAQs
ArangoDB Foxx decorators and utilities for TypeScript
We found that type-arango demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.