Skip to content

@privateaim/server-kit ​

Server-side foundation package providing logging, authentication integration, AMQP messaging, Redis, caching, and DI module infrastructure. Used by all Hub backend services.

Installation ​

bash
npm install @privateaim/server-kit

Usage ​

Logger (Winston) ​

typescript
import { useLogger, LoggerModule } from '@privateaim/server-kit';

const logger = useLogger();
logger.info('Service started');

Message Bus (AMQP) ​

typescript
import { MessageBusModule } from '@privateaim/server-kit';

Redis ​

typescript
import { RedisModule } from '@privateaim/server-kit';

Authup Integration ​

typescript
import { AuthupModule } from '@privateaim/server-kit';

Query Schema Description ​

describeQuerySchema() serializes a rapiq entity schema into the SchemaDescription that controllers publish under meta.schema — the static upper bound of an endpoint's queryable vocabulary. Pass RECORD_QUERY_PARAMETERS on single-record reads to advertise only the fields + relations subset a record read processes.

typescript
import { RECORD_QUERY_PARAMETERS, describeQuerySchema } from '@privateaim/server-kit';

// Collection GET — full vocabulary
return { data, meta: { ...meta, schema: describeQuerySchema(nodeSchema) } };

// Record GET — fields + relations only
return { data: entity, meta: { schema: describeQuerySchema(nodeSchema, RECORD_QUERY_PARAMETERS) } };

Descriptions are memoized per (schema, parameters) and deep-frozen: the returned object is shared by reference, so never mutate it. Always spread when merging — meta: { ...meta, schema }, never meta.schema = ... (that throws under ESM strict mode).

See API Reference for the consumer-side reading rules.

Application Builder ​

typescript
import { BaseApplicationBuilder } from '@privateaim/server-kit';

class MyAppBuilder extends BaseApplicationBuilder {
    // Add withConfig(), withDatabase(), withHTTP() etc.
}

API ​

Exports ​

ModuleDescription
appBaseApplicationBuilder, Application base class
loggerWinston logger setup and LoggerModule
message-busAMQP message bus module and utilities
redisRedis module and connection helpers
authupAuthup authentication middleware module
cacheCache module (Redis-backed)
configConfiguration reading via envix
core/querydescribeQuerySchema(), RECORD_QUERY_PARAMETERS — rapiq schema description for meta.schema
entity-eventEntity event pub/sub system
task-managerTask lifecycle management
aggregatorAMQP event aggregator base classes
componentAMQP task consumer component base classes
constantsModule names, injection keys

Shared DI Modules ​

Module ClassPurpose
LoggerModuleWinston logger with optional telemetry transport
RedisModuleRedis client registration
MessageBusModuleAMQP connection and queue management
AuthupModuleAuthup middleware and token validation
CacheModuleRedis-backed caching
EntityEventModuleDomain event dispatching

Dependencies ​

  • winston — Logging
  • @ebec/http — HTTP error types
  • @hapic/oauth2 — OAuth2 client
  • @rapiq/core — Query schema definition and description (describeQuerySchema)
  • orkos — Module system (IModule)
  • eldin — DI container (TypedToken)
  • envix — Environment variable reading