Skip to main content

Node.js SDK

Backend SDK for building AppServer applications in Node.js and TypeScript.

Overview

The Node.js SDK (@easy/appserver-sdk) provides everything needed to build backend applications for Easy AppServer:

  • Lifecycle management with hooks
  • Type-safe AppContext
  • Database integration
  • Certificate handling
  • Structured logging
  • Event handling

Quick Start

npm install @easy/appserver-sdk
import { createApp } from '@easy/appserver-sdk';

const app = createApp({
onCreate: async (context) => {
console.log('App created');
},

onStartUp: async (context) => {
console.log('App started');
},

onRegister: async (context) => {
// Return app manifest
return {
id: 'my-app',
name: 'My Application',
version: '1.0.0',
// ... more manifest properties
};
},

onInstall: async (context) => {
// Run database migrations, initial setup
console.log('App installed');
}
});

// Start the app
await app.start();

Key Features

Singleton Architecture

  • One app instance per process
  • Automatic enforcement
  • Prevents accidental multiple instances

Lifecycle Hooks

  • onCreate - Process initialization
  • onStartUp - After AppServer connection
  • onRegister - Manifest declaration
  • onInstall - Installation setup
  • onUninstall - Cleanup
  • onDestroy - Process shutdown

AppContext

Type-safe context object providing:

  • App metadata
  • Database client
  • Logger
  • Settings access
  • Event bus
  • gRPC client to AppServer

Database Integration

  • PostgreSQL client with pooling
  • Connection management
  • Health checks
  • Automatic retries

Certificate Management

  • X.509 certificate loading
  • Private key handling
  • Automatic request signing

Documentation

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import type { AppContext, AppManifest } from '@easy/appserver-sdk';

Examples

TODO: Link to example apps