Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oviecodes committed Feb 15, 2024
1 parent 8815ab2 commit 06cce28
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ import { getSelectedServerNames } from './lib/servers.js'
import { EnrichedEvent, AuthEvent } from './lib/adapter.js'
import { ClusterEvent } from './lib/cluster.js'
import { getMessagesSchema } from './lib/util.js'
import { OperationReplyInterface } from '@asyncapi/parser'
import {loadEnvConfig} from '@next/env'
import pkg from '@next/env'
const { loadEnvConfig } = pkg

<<<<<<< HEAD
=======

>>>>>>> 1f51e1f (feat: add support for multiple .env files. (#683))
const isDev = process.env.NODE_ENV === 'development'
loadEnvConfig(process.cwd(), isDev)

Expand Down Expand Up @@ -103,37 +99,45 @@ export default async function GleeAppInitializer() {
app.use(errorLogger)
app.useOutbound(errorLogger)
await generateDocs(config)
parsedAsyncAPI.operations().filterByReceive().forEach(operation => {
const channel = operation.channels()[0] // operation can have only one channel.
if (operation.reply()) {
logWarningMessage(`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`)
}
if (operation.reply()) {
logWarningMessage(`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`)
}
const schema = getMessagesSchema(operation)
if (schema.oneOf.length > 0) app.use(channel.id(), validate(schema))
app.use(channel.id(), (event, next) => {
triggerFunction({
app,
operation,
message: event
}).then(next).catch(next)
parsedAsyncAPI
.operations()
.filterByReceive()
.forEach((operation) => {
const channel = operation.channels()[0] // operation can have only one channel.
if (operation.reply()) {
logWarningMessage(
`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`
)
}
const schema = getMessagesSchema(operation)
if (schema.oneOf.length > 0) app.use(channel.id(), validate(schema))
app.use(channel.id(), (event, next) => {
triggerFunction({
app,
operation,
message: event,
})
.then(next)
.catch(next)
})
})
})

parsedAsyncAPI.operations().filterBySend().forEach(operation => {
const channel = operation.channels()[0] // operation can have only one channel.
if (operation.reply()) {
logWarningMessage(`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`)
}
if (operation.reply()) {
logWarningMessage(`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`)
}
const schema = getMessagesSchema(operation)
if (schema.oneOf.length > 0) app.useOutbound(channel.id(), validate(schema))
app.useOutbound(channel.id(), json2string)
})
parsedAsyncAPI
.operations()
.filterBySend()
.forEach((operation) => {
const channel = operation.channels()[0] // operation can have only one channel.
if (operation.reply()) {
logWarningMessage(
`Operation ${operation.id()} has a reply defined. Glee does not support replies yet.`
)
}
const schema = getMessagesSchema(operation)
if (schema.oneOf.length > 0) {
app.useOutbound(channel.id(), validate(schema))
}
app.useOutbound(channel.id(), json2string)
})

app.on('adapter:auth', async (e: AuthEvent) => {
logLineWithIcon(
Expand Down

0 comments on commit 06cce28

Please sign in to comment.