npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prisma-eventify

v0.0.6-alpha

Published

Prisma-Eventify is a crucial module designed to facilitate seamless communication between the ORM (Prisma) and the HTTP server (GraphQL | Rest) by employing event-driven development principles.

Downloads

23

Readme

Prisma-Eventify

Prisma-Eventify is a crucial module designed to facilitate seamless communication between the ORM (Prisma) and the HTTP server (GraphQL | Rest) by employing event-driven development principles.

It comprises a set of generated service classes (e.g., user.service.ts) that serve as intermediaries for communicating with the ORM, thereby enabling event-driven development. Each method within these service classes is equipped with standard-named generated events for various hooks (before, after). These events serve as entry points for integrating validations, mutations, and custom logics, ensuring flexibility and reliability in your application architecture.

Automatically subscribed to an event bus, these generated events streamline the flow of data and actions between your ORM and HTTP server. Additionally, Prisma-Eventify generates an eventify.config.ts file in the project's root, containing example event handler callback functions for each subscribed generated event.

When the HTTP server utilizes one of these generated services, a cascade of events for each hook is published to the event bus. This triggers the execution of custom subscribed callbacks defined within eventify.config.ts, empowering you to seamlessly implement and customize your application's behavior according to your specific requirements.

Getting Started

To get started with Prisma-Eventify, follow these steps:

  1. Add the generator to schema.prisma:
generator client {
  provider        = "prisma-eventify"
  excludeModels   = []
  excludeFields   = ["id"]
}
  1. Load the event bus inside you application:
import { loadEventBus } from 'prisma-eventify'

const eventBus = loadEventBus({
    /* Excluded models */
    excludeModels: [],
    /* Excluded fields for all models */
    excludeFields: ['id'],
    /* Inject your application context */
    context: this.ctx
})

Context Injection

As previously described, it's possible to inject your own application context into event handler callback functions. However, this context may vary depending on the background framework being used...

NuxtJS

Injecting the NuxtJS context inside the event bus and the event bus itself inside NuxtJS context:

import { loadEventBus } from 'prisma-eventify'

export default defineNuxtPlugin(nuxtApp => {
  return {
    provide: {
      eventBus: () => loadEventBus({
          /* Excluded models */
          excludeModels: [],
          /* Excluded fields for all models */
          excludeFields: ['id'],
          /* Inject your application context */
          context: nuxtApp
      })
    }
  }
})

Contributing

Clone this repository:

https://github.com/LorenzoRottigni/prisma-eventify.git
cd prisma-eventify
code .

Run a Postgres DB:

docker run --name postgres-container -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

Prepare environment:

yarn
yarn prisma:generate --schema=tests/prisma/schema.prisma
yarn prisma:migrate dev --schema=tests/prisma/schema.prisma

Testing:

yarn test