preset-development

command
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 7 Imported by: 0

README

Development Preset Example

This example demonstrates the Development Preset - the fastest way to get started with Simple Content.

Features

  • One-line setup: NewDevelopment() creates a fully configured service
  • In-memory database: No PostgreSQL or database setup required
  • Filesystem storage: Data persists at ./dev-data/ across restarts
  • Automatic cleanup: Cleanup function removes storage directory

Quick Start

go run main.go

What This Example Shows

  1. Service Creation - One line to create a working service
  2. Upload Content - Upload documents and images
  3. Derived Content - Create thumbnails from images
  4. Download Content - Download uploaded files
  5. Content Details - Get comprehensive information about content

Code Walkthrough

Create Service
svc, cleanup, err := presets.NewDevelopment()
if err != nil {
    log.Fatal(err)
}
defer cleanup() // Remove ./dev-data/ when done
Upload Content
content, err := svc.UploadContent(ctx, simplecontent.UploadContentRequest{
    OwnerID:      uuid.New(),
    TenantID:     uuid.New(),
    Name:         "Development Guide",
    DocumentType: "text/plain",
    Reader:       strings.NewReader("This is a guide for local development."),
    FileName:     "dev-guide.txt",
})
Create Derived Content
thumbnail, err := svc.UploadDerivedContent(ctx, simplecontent.UploadDerivedContentRequest{
    ParentID:       imageID,
    DerivationType: "thumbnail",
    Variant:        "thumbnail_256",
    Reader:         thumbnailReader,
    FileName:       "screenshot_thumb.png",
    MimeType:       "image/png",
})

Customization

The development preset supports customization options:

// Custom storage directory
svc, cleanup, err := presets.NewDevelopment(
    presets.WithDevStorage("./my-custom-dir"),
)

// Custom port (for future server integration)
svc, cleanup, err := presets.NewDevelopment(
    presets.WithDevPort("3000"),
)

When to Use

Use the Development Preset when:

  • Learning Simple Content for the first time
  • Prototyping new features
  • Local development without database setup
  • Testing integration with your application
  • Running demos and presentations

Next Steps

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL