Skip to content

@web-engine-dev/ugc

User-generated content management for web-engine-dev. Handles content validation, versioning, storage, and licensing.

Features

  • Content Upload: Secure file uploads
  • Validation: Content type validation
  • Versioning: Content version history
  • Storage: CDN-backed storage
  • Licensing: Rights management
  • Moderation: Content review queue

Installation

bash
npm install @web-engine-dev/ugc
# or
pnpm add @web-engine-dev/ugc

Quick Start

typescript
import { UGCService } from '@web-engine-dev/ugc';

const ugc = new UGCService({
  apiKey: 'your-api-key',
});

// Upload content
const content = await ugc.upload({
  type: 'level',
  title: 'My Custom Level',
  description: 'A challenging platformer level',
  files: levelData,
  tags: ['hard', 'platformer'],
});

// Browse content
const levels = await ugc.browse({
  type: 'level',
  sortBy: 'popular',
});

// Download content
const data = await ugc.download(contentId);

API Overview

Upload

typescript
const content = await ugc.upload({
  type: 'level', // 'level', 'skin', 'mod', etc.
  title: 'My Level',
  description: '...',
  thumbnail: thumbnailFile,
  files: {
    main: levelFile,
    assets: assetFiles,
  },
  tags: ['easy', 'puzzle'],
  license: 'cc-by',
  visibility: 'public',
});

Browse

typescript
const results = await ugc.browse({
  type: 'level',
  tags: ['puzzle'],
  sortBy: 'popular', // 'popular', 'newest', 'rating'
  timeframe: 'week',
  page: 1,
  limit: 20,
});

for (const item of results.items) {
  console.log(item.title);
  console.log(item.author);
  console.log(item.downloads);
  console.log(item.rating);
}

Content Details

typescript
const content = await ugc.getContent(contentId);

console.log(content.title);
console.log(content.description);
console.log(content.author);
console.log(content.version);
console.log(content.downloads);
console.log(content.rating);
console.log(content.createdAt);

Versioning

typescript
// Update content
await ugc.updateContent(contentId, {
  version: '1.1.0',
  changelog: 'Fixed bug in level 3',
  files: newFiles,
});

// Get version history
const versions = await ugc.getVersions(contentId);

// Download specific version
const data = await ugc.download(contentId, { version: '1.0.0' });

Ratings/Reviews

typescript
// Rate content
await ugc.rate(contentId, 5);

// Write review
await ugc.review(contentId, {
  rating: 5,
  text: 'Great level!',
});

// Get reviews
const reviews = await ugc.getReviews(contentId);

Proprietary software. All rights reserved.