1.0.4 • Published 4 months ago
bbs-sdk v1.0.4
BBS SDK
This package provides the types and interfaces needed to build apps for the TT-BBS system. It's placed at the root level of the repository to allow it to be used by multiple projects.
Installation
For local development within this repository:
# From a project in this repository:
npm install file:../bbs-sdk
# From an external project:
npm install file:/path/to/tt/bbs-sdk
For published versions:
npm install bbs-sdk
Usage
To create a BBS app, import the interfaces from this package and implement them:
import { BbsApp, CommandResult, BbsSession } from 'bbs-sdk';
const MyApp: BbsApp = {
id: 'my_app',
name: 'My App',
version: '1.0.0',
description: 'A simple BBS app',
author: 'Your Name',
getWelcomeScreen(): string {
return `
Welcome to My App!
Type HELP for commands.
`;
},
handleCommand(screenId: string | null, command: string, session: BbsSession): CommandResult {
// Handle commands and return a response
return {
screen: screenId, // Keep on the same screen
response: `You typed: ${command}`,
refresh: false
};
},
getHelp(screenId: string | null): string {
return `
Available commands:
HELP - Show this help text
BACK - Return to main menu
`;
}
};
// Export your app
export default MyApp;
Types
The package includes the following main interfaces:
BbsApp
: The main interface for BBS appsCommandResult
: Returned by thehandleCommand
methodBbsSession
: Represents a user's sessionBbsUser
: Represents a BBS userBbsStorage
: Interface for data persistenceBbsUtils
: Utility functions for BBS apps
Documentation
For detailed API documentation, see the JSDoc comments in the source code.
Publishing
When ready to publish this SDK to npm, run:
cd /path/to/tt/bbs-sdk
npm publish
License
MIT