UNPKG

zod-server-actions

Version:

Simple utility library to create server actions in Next.js

27 lines (26 loc) 689 B
import { logger } from "./logger"; export class Context { constructor(config) { this.config = config; } async get(key) { const context = await this.getContext(); if (key) { return context[key]; } return context; } async getContext() { if (!this.config.contextFn) return this.context; if (!this.context) { const context = await this.config.contextFn(); this.context = context; if (this.config.debug) logger.debug("Getting context: ", context); return context; } return this.context; } } new Proxy({}, {});