Skip to content

Latest commit

 

History

History
84 lines (64 loc) · 2.53 KB

File metadata and controls

84 lines (64 loc) · 2.53 KB

jasper

Jasper Webserver

🌐 Spring Boot server for Jasper's web functionality

Project Structure

.webserver/
├── src/main/
│   ├── kotlin/tara/tb1/pw/
│   │   ├── Playwright/           # Playwright integration
│   │   │   ├── Playwright.kt     # Playwright core functionality
│   │   │   └── PlaywrightController.kt # REST endpoints
│   │   └── JasperWebserverApplication.kt # Main application
│   └── resources/
│       ├── templates/            # HTML templates
│       │   └── skullboard.html   # Skullboard message template
│       └── application.properties # Application configuration
├── build.gradle.kts             # Gradle build configuration
└── settings.gradle.kts          # Gradle settings

Key Components

  1. Playwright Integration: Handles browser automation for generating images from HTML templates.

    • Playwright.kt: Core functionality for browser control and image generation
    • PlaywrightController.kt: REST endpoints for image generation services
  2. HTML Templates: Located in src/main/resources/templates/, these files define the visual structure of generated content.

    • skullboard.html: Template for Discord message screenshots
  3. Application Configuration: Spring Boot configuration in application.properties

Development

  1. Install dependencies:

    ./gradlew build
  2. Run the server:

    ./gradlew bootRun

API Endpoints

Playwright Controller

  • GET /playwright/test

    • Tests if the Playwright service is working
    • Returns: String confirmation message
  • POST /playwright/execute

    • Executes a Playwright script
    • Body: Script content
    • Returns: Execution result
  • POST /playwright/render

    • Renders HTML content to an image
    • Body: RenderData object
    • Returns: PNG image

Environment Setup

The application requires:

  1. Java 17 or higher
  2. Gradle
  3. Playwright dependencies

Scripts

  • ./gradlew build - Builds the project
  • ./gradlew test - Runs tests
  • ./gradlew bootRun - Starts the development server
  • ./gradlew bootJar - Creates an executable JAR

Type Safety

The project is written in Kotlin and leverages:

  • Strong type system
  • Null safety features
  • Spring Boot type-safe configuration
  • Kotlin data classes for request/response models