Node.js client library for EAPP (Ethos Apps Platform) - Auto-generated protobuf client code for seamless Node.js integration with EAPP services.
- Overview
- π Quick Start
- π¦ Installation
- π§ Usage
- π API Reference
- π Auto-Generation
- π€ Contributing
- π License
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.
- π 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 Category | Description | Available |
|---|---|---|
| π Identity | User authentication & authorization | β |
| π¬ Communication | Messaging & notifications | β |
| π§ Cognitive | AI & knowledge management | β |
| ποΈ Commerce | Transactions & payments | β |
| π Multiverse | Space & universe management | β |
# Install from npm
npm install eapp-nodejs-domain
# Or install with yarn
yarn add eapp-nodejs-domainconst { 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}`);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();- Node.js: 18.0.0+
- Dependencies:
protobufjs: ^7.0.0@grpc/grpc-js: ^1.8.0
npm install eapp-nodejs-domainyarn add eapp-nodejs-domain# 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-domaingit clone https://github.com/50gramx/eapp-nodejs-domain.git
cd eapp-nodejs-domain
npm install// 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';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);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));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');
});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();
}
}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
});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
});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
});const client = new AccountServiceClient(address, credentials);
// Available methods:
// - createAccount(request)
// - getAccount(request)
// - updateAccount(request)
// - deleteAccount(request)
// - getUserAccounts(request)const client = new UserServiceClient(address, credentials);
// Available methods:
// - createUser(request)
// - getUser(request)
// - updateUser(request)
// - deleteUser(request)
// - listUsers(request)This package is automatically generated from protobuf definitions in the eapp-system-contracts repository.
- Protobuf Changes - Updates to
.protofiles in system-contracts - CI/CD Trigger - GitHub Actions workflow automatically triggers
- Code Generation -
protocgenerates JavaScript code from.protofiles - Package Building - Creates npm package with generated code
- Release Creation - Creates GitHub release with new version
- Index Update - Updates package index with new release
- Auto-generated versions - Based on timestamp:
0.1.0.{timestamp} - Release frequency - On every protobuf change
- Backward compatibility - Maintained within major versions
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Update protobuf definitions in eapp-system-contracts
- Push to trigger auto-generation
- Review generated JavaScript code
- Test with your changes
# 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 lintThis project is licensed under the MIT License - see the LICENSE file for details.
- π¦ npm: eapp-nodejs-domain
- ποΈ System Contracts: eapp-system-contracts
- π Issues: GitHub Issues
- π Documentation: API Docs
- π¬ Discussions: GitHub Discussions
Auto-generated Node.js client for EAPP System Contracts
Built with β€οΈ by the EAPP Team