Skip to content

Commit

Permalink
fix: migration mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Souvikns committed Sep 28, 2023
1 parent 55881a9 commit 1181316
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
21 changes: 12 additions & 9 deletions src/adapters/mqtt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,22 @@ class MqttAdapter extends Adapter {

private getSecurityReqs() {

const parsedSecurityScehemes = this.parsedAsyncAPI.components().securitySchemes().all()

let userAndPasswordSecurityReq
let X509SecurityReq

for (const security of parsedSecurityScehemes) {
if (security.type() === 'userPassword') {
userAndPasswordSecurityReq = security
}
if (security.type() === 'x509') {
X509SecurityReq = security
const securityRequirements = this.AsyncAPIServer.security().map(e => e.map(e => e.scheme()))

securityRequirements.forEach(sec => {
for (const security of sec) {
if(security.type() === 'userPassword') {
userAndPasswordSecurityReq = security
}

if (security.type() === 'x509') {
X509SecurityReq = security
}
}
}
})

return {
userAndPasswordSecurityReq,
Expand Down
51 changes: 25 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,33 @@ export default async function GleeAppInitializer() {

channelNames.forEach((channelName) => {
const channel = parsedAsyncAPI.channels().get(channelName)
if (channel.operations().filterBySend().length !==0) {
const operationId = channel.operations()[0].operationId()
const publishOperation = channel.operations().filterBySend()[0]
if (operationId) {
const schema = {
oneOf: publishOperation
.messages()
.map(m => m.payload().json()),
} as any
app.use(channelName, validate(schema), (event, next) => {
triggerFunction({
app,
operationId,
message: event,
if (channel.operations().filterByReceive().length !==0) {

channel.operations().filterByReceive().forEach(operation => {
const receiveOperation = operation
const operationId = operation.operationId()
if (operationId) {
const schema = {
onOf: receiveOperation.messages().filterByReceive().map(m => m.payload())
} as any
app.use(channelName, validate(schema), (event, next) => {
triggerFunction({
app,
operationId,
message: event
}).then(next).catch(next)
})
.then(next)
.catch(next)
})
}
}
})
}
if (channel.operations().filterByReceive().length !== 0) {
const subscribeOperation = channel.operations().filterByReceive()[0]
const schema = {
oneOf: subscribeOperation
.messages()
.map(m => m.payload().json()),
} as any
app.useOutbound(channelName, validate(schema), json2string)
if (channel.operations().filterBySend().length !== 0) {
channel.operations().filterBySend().forEach(operation => {
const sendOperation = operation
const schema = {
onOf: sendOperation.messages().filterBySend().map(m => m.payload())
} as any
app.useOutbound(channelName, validate(schema), json2string)
})
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/lib/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function getSelectedServerNames(): Promise<string[]> {
}

const arrayOfNames = process.env.GLEE_SERVER_NAMES.split(',')
return parsedAsyncAPI.servers().all().map(e => e.url()).filter((name) => {
return parsedAsyncAPI.servers().all().map(e => e.id()).filter((name) => {
return arrayOfNames.includes(name)
})
}

0 comments on commit 1181316

Please sign in to comment.