Skip to content

PrismaPlugin

This file defines the PrismaPlugin class, which implements the Prisma integration plugin for the @sodacore/core framework. The plugin loads its metadata from package.json and registers the Prisma service with the application, enabling database access via Prisma.


Features

  • Automatic Metadata Loading: Reads plugin metadata (name, version, description, author) from package.json at runtime.
  • Service Registration: Registers the PrismaService with the application during installation.
  • Extends BasePlugin: Inherits from BasePlugin for consistent plugin lifecycle and configuration handling.

Usage

typescript
import PrismaPlugin from './module/plugin';
import Application from '@sodacore/core';

const app = new Application();
const prismaPlugin = new PrismaPlugin();
await prismaPlugin.install(app);

API

Properties

  • name: The plugin name, loaded from package.json.
  • version: The plugin version, loaded from package.json.
  • description: The plugin description, loaded from package.json.
  • author: The plugin author, loaded from package.json.

Constructor

typescript
constructor(protected config: IConfig = {})
  • config: Optional configuration object for the plugin.

Methods

async install(app: Application): Promise<void>

Registers the PrismaService with the Sodacore application instance.


How It Works

  1. Loads plugin metadata from package.json using Bun's file API.
  2. Sets the plugin's metadata properties.
  3. On installation, registers the PrismaService with the Sodacore application.

Notes

  • This plugin is designed to be used with the Sodacore framework and expects Bun as the runtime.
  • Throws an error if package.json is not found.
  • All Prisma-related functionality is encapsulated and registered via the install method.

Released under the Apache-2.0 License.