MCPcopy
hub / github.com/joschan21/digitalhippo / getPayloadClient

Function getPayloadClient

src/get-payload.ts:34–66  ·  view source on GitHub ↗
({
  initOptions,
}: Args = {})

Source from the content-addressed store, hash-verified

32}
33
34export const getPayloadClient = async ({
35 initOptions,
36}: Args = {}): Promise<Payload> => {
37 if (!process.env.PAYLOAD_SECRET) {
38 throw new Error('PAYLOAD_SECRET is missing')
39 }
40
41 if (cached.client) {
42 return cached.client
43 }
44
45 if (!cached.promise) {
46 cached.promise = payload.init({
47 email: {
48 transport: transporter,
49 fromAddress: 'hello@joshtriedcoding.com',
50 fromName: 'DigitalHippo',
51 },
52 secret: process.env.PAYLOAD_SECRET,
53 local: initOptions?.express ? false : true,
54 ...(initOptions || {}),
55 })
56 }
57
58 try {
59 cached.client = await cached.promise
60 } catch (e: unknown) {
61 cached.promise = null
62 throw e
63 }
64
65 return cached.client
66}

Callers 7

stripeWebhookHandlerFunction · 0.90
startFunction · 0.90
ThankYouPageFunction · 0.90
PageFunction · 0.90
index.tsFile · 0.90
payment-router.tsFile · 0.90
auth-router.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected