Skip to content

🟨 Auto-generated Node.js client library for EAPP system contracts. TypeScript support with gRPC client for modern JavaScript applications.

Notifications You must be signed in to change notification settings

50gramx/eapp-nodejs-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EAPP Node.js Domain 🟨

Node.js Version npm Version License Build Status Downloads

Node.js client library for EAPP (Ethos Apps Platform) - Auto-generated protobuf client code for seamless Node.js integration with EAPP services.

πŸ“‹ Table of Contents

🌟 Overview

EAPP Node.js Domain provides auto-generated JavaScript/TypeScript client code for all EAPP system contracts. This package is automatically generated from Protocol Buffer definitions and provides type-safe, efficient access to EAPP services from Node.js applications.

🎯 Key Features

  • πŸ”„ Auto-Generated - Built from protobuf definitions in eapp-system-contracts
  • πŸ“¦ Type-Safe - Full TypeScript support with type definitions
  • ⚑ High Performance - Optimized protobuf serialization
  • πŸ”„ Async/Await - Modern JavaScript with async/await support
  • πŸ”’ Production Ready - Used in production EAPP services
  • πŸ“š Comprehensive - Covers all EAPP service contracts

πŸ—οΈ Service Coverage

Service Category Description Available
πŸ” Identity User authentication & authorization βœ…
πŸ’¬ Communication Messaging & notifications βœ…
🧠 Cognitive AI & knowledge management βœ…
πŸ›οΈ Commerce Transactions & payments βœ…
🌌 Multiverse Space & universe management βœ…

πŸš€ Quick Start

1. Installation

# Install from npm
npm install eapp-nodejs-domain

# Or install with yarn
yarn add eapp-nodejs-domain

2. Basic Usage

const { User, Account, UserStatus, AccountStatus } = require('eapp-nodejs-domain');

// Create a user
const user = new User({
  id: 'user123',
  name: 'John Doe',
  email: 'john@example.com',
  status: UserStatus.ACTIVE
});

// Create an account
const account = new Account({
  id: 'acc123',
  userId: user.id,
  status: AccountStatus.ACTIVE
});

console.log(`User: ${user.name} (${user.email})`);
console.log(`Account: ${account.id} - Status: ${account.status}`);

3. Service Integration

const grpc = require('@grpc/grpc-js');
const { AccountServiceClient } = require('eapp-nodejs-domain');

async function createAccount() {
  const client = new AccountServiceClient(
    'localhost:50051',
    grpc.credentials.createInsecure()
  );

  const request = {
    userId: 'user123',
    accountType: 'PERSONAL'
  };

  try {
    const response = await client.createAccount(request);
    console.log(`Created account: ${response.account.id}`);
  } catch (error) {
    console.error('Error:', error);
  } finally {
    client.close();
  }
}

createAccount();

πŸ“¦ Installation

Requirements

  • Node.js: 18.0.0+
  • Dependencies:
    • protobufjs: ^7.0.0
    • @grpc/grpc-js: ^1.8.0

Installation Methods

1. npm (Recommended)

npm install eapp-nodejs-domain

2. yarn

yarn add eapp-nodejs-domain

3. From GitHub Releases

# Download from GitHub releases
wget https://github.com/50gramx/eapp-nodejs-domain/releases/latest/download/eapp-nodejs-domain.tar.gz
tar -xzf eapp-nodejs-domain.tar.gz
npm install ./eapp-nodejs-domain

4. Local Development

git clone https://github.com/50gramx/eapp-nodejs-domain.git
cd eapp-nodejs-domain
npm install

πŸ”§ Usage

Importing Modules

// CommonJS
const { User, Account, Space } = require('eapp-nodejs-domain');
const { AccountServiceClient, UserServiceClient } = require('eapp-nodejs-domain');

// ES Modules
import { User, Account, Space } from 'eapp-nodejs-domain';
import { AccountServiceClient, UserServiceClient } from 'eapp-nodejs-domain';

Working with Messages

const { User, UserStatus } = require('eapp-nodejs-domain');

// Create messages
const user = new User({
  id: 'user123',
  name: 'John Doe',
  email: 'john@example.com',
  status: UserStatus.ACTIVE
});

// Serialize to buffer
const userBuffer = User.encode(user).finish();

// Deserialize from buffer
const userFromBuffer = User.decode(userBuffer);

// Convert to/from JSON
const userJson = User.toObject(user, { longs: String, enums: String });
const userFromJson = User.fromObject(userJson);

gRPC Service Calls

const grpc = require('@grpc/grpc-js');
const { AccountServiceClient } = require('eapp-nodejs-domain');

async function getUserAccounts(userId) {
  const client = new AccountServiceClient(
    'localhost:50051',
    grpc.credentials.createInsecure()
  );

  try {
    const request = { userId };
    const response = await client.getUserAccounts(request);
    return response.accounts;
  } finally {
    client.close();
  }
}

// Usage
getUserAccounts('user123')
  .then(accounts => console.log('Accounts:', accounts))
  .catch(error => console.error('Error:', error));

Express.js Integration

const express = require('express');
const grpc = require('@grpc/grpc-js');
const { UserServiceClient, User } = require('eapp-nodejs-domain');

const app = express();
app.use(express.json());

const userClient = new UserServiceClient(
  'localhost:50051',
  grpc.credentials.createInsecure()
);

// Create user endpoint
app.post('/users', async (req, res) => {
  try {
    const { name, email } = req.body;
    
    const request = {
      name,
      email,
      status: 'ACTIVE'
    };

    const response = await userClient.createUser(request);
    res.json(response.user);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

// Get user endpoint
app.get('/users/:id', async (req, res) => {
  try {
    const { id } = req.params;
    
    const request = { id };
    const response = await userClient.getUser(request);
    res.json(response.user);
  } catch (error) {
    res.status(404).json({ error: 'User not found' });
  }
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

TypeScript Support

import { User, Account, UserStatus, AccountStatus } from 'eapp-nodejs-domain';
import { AccountServiceClient } from 'eapp-nodejs-domain';
import * as grpc from '@grpc/grpc-js';

interface CreateUserRequest {
  name: string;
  email: string;
  status: UserStatus;
}

async function createUser(request: CreateUserRequest): Promise<User> {
  const client = new AccountServiceClient(
    'localhost:50051',
    grpc.credentials.createInsecure()
  );

  try {
    const response = await client.createUser(request);
    return response.user;
  } finally {
    client.close();
  }
}

πŸ“š API Reference

Core Entities

User

const user = new User({
  id: 'string',           // Unique user identifier
  name: 'string',         // Display name
  email: 'string',        // Email address
  status: UserStatus.ACTIVE,  // User status
  createdAt: 'timestamp', // Creation timestamp
  updatedAt: 'timestamp'  // Last update timestamp
});

Account

const account = new Account({
  id: 'string',           // Unique account identifier
  userId: 'string',       // Associated user ID
  type: 'PERSONAL',       // Account type
  status: AccountStatus.ACTIVE, // Account status
  createdAt: 'timestamp'  // Creation timestamp
});

Space

const space = new Space({
  id: 'string',           // Unique space identifier
  name: 'string',         // Space name
  description: 'string',  // Space description
  ownerId: 'string',      // Owner user ID
  type: 'PUBLIC',         // Space type
  createdAt: 'timestamp'  // Creation timestamp
});

Service Clients

AccountServiceClient

const client = new AccountServiceClient(address, credentials);

// Available methods:
// - createAccount(request)
// - getAccount(request)
// - updateAccount(request)
// - deleteAccount(request)
// - getUserAccounts(request)

UserServiceClient

const client = new UserServiceClient(address, credentials);

// Available methods:
// - createUser(request)
// - getUser(request)
// - updateUser(request)
// - deleteUser(request)
// - listUsers(request)

πŸ”„ Auto-Generation

This package is automatically generated from protobuf definitions in the eapp-system-contracts repository.

Generation Process

  1. Protobuf Changes - Updates to .proto files in system-contracts
  2. CI/CD Trigger - GitHub Actions workflow automatically triggers
  3. Code Generation - protoc generates JavaScript code from .proto files
  4. Package Building - Creates npm package with generated code
  5. Release Creation - Creates GitHub release with new version
  6. Index Update - Updates package index with new release

Versioning

  • Auto-generated versions - Based on timestamp: 0.1.0.{timestamp}
  • Release frequency - On every protobuf change
  • Backward compatibility - Maintained within major versions

🀝 Contributing

For Node.js-Specific Changes

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

For Protobuf Changes

  1. Update protobuf definitions in eapp-system-contracts
  2. Push to trigger auto-generation
  3. Review generated JavaScript code
  4. Test with your changes

Development Setup

# Clone repository
git clone https://github.com/50gramx/eapp-nodejs-domain.git
cd eapp-nodejs-domain

# Install dependencies
npm install

# Run tests
npm test

# Run linting
npm run lint

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ”— Quick Links


Auto-generated Node.js client for EAPP System Contracts

Built with ❀️ by the EAPP Team

About

🟨 Auto-generated Node.js client library for EAPP system contracts. TypeScript support with gRPC client for modern JavaScript applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published