@imigueldiaz/mongodb-labeler
v0.2.0
Published
A MongoDB-based labeling system for content moderation with cryptographic signing
Downloads
307
Maintainers
Readme
MongoDB Labeler
A versatile data management and labeling tool that helps you organize, tag, and manage your MongoDB collections efficiently. Originally inspired by ATProtocol's labeling system, it can be used both for general MongoDB data labeling and ATProtocol content moderation.
Acknowledgments
This project is a fork of @skyware/labeler, which was originally designed for Bluesky/ATProto labeling. We've adapted and expanded it to work with MongoDB databases while maintaining compatibility with ATProtocol labeling workflows.
Features
- Efficient data labeling interface
- MongoDB integration
- Support for custom label schemas
- ATProtocol compatibility
- Content moderation support
- Batch labeling operations
- Export and import functionality
- TypeScript support
Installation
npm install @imigueldiaz/mongodb-labeler
# or using pnpm
pnpm install @imigueldiaz/mongodb-labeler
Usage
import { MongoDBLabeler } from "@imigueldiaz/mongodb-labeler";
// Initialize the labeler
const labeler = new MongoDBLabeler({
uri: "your-mongodb-uri",
database: "your-database",
collection: "your-collection",
});
// Start labeling session
await labeler.start();
Configuration
The labeler can be configured with the following options:
{
/** The DID of the labeler account */
did: string;
/** The private signing key used for the labeler */
signingKey: string;
/** MongoDB connection URI */
mongoUri: string;
/** The name of the MongoDB database to use (defaults to 'labeler') */
databaseName?: string;
/** The name of the MongoDB collection to use */
collectionName?: string;
/** Custom authorization function for label creation */
auth?: (did: string) => boolean | Promise<boolean>;
/** Host to bind the server to */
host?: string;
/** Port to run the server on (defaults to 4100) */
port?: number;
}
For basic MongoDB usage:
import { MongoDBLabeler } from "@imigueldiaz/mongodb-labeler";
const labeler = new MongoDBLabeler({
mongoUri: "mongodb://localhost:27017",
databaseName: "my_database",
collectionName: "my_labels",
});
For ATProtocol usage:
import { LabelerServer } from "@imigueldiaz/mongodb-labeler";
const server = new LabelerServer({
did: "your-did",
signingKey: "your-signing-key",
mongoUri: "mongodb://localhost:27017",
databaseName: "atproto_labels",
});
server.start((error, address) => {
if (error) {
console.error(error);
} else {
console.log(`Labeler server listening on ${address}`);
}
});
Development
To set up the development environment:
# Clone the repository
git clone https://github.com/imigueldiaz/mongodb-labeler.git
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the project
pnpm build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
- Ignacio de Miguel Díaz
Special Thanks
Special thanks to the @skyware/labeler team for their excellent work on the original project that served as the foundation for this tool.