Skip to content

Commit

Permalink
fix(samples): mediator wallet and http transport (#1508)
Browse files Browse the repository at this point in the history
Signed-off-by: Ariel Gentile <[email protected]>
  • Loading branch information
genaris authored Jul 19, 2023
1 parent 002be4f commit 04a8058
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/node/src/transport/HttpInboundTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ export class HttpInboundTransport implements InboundTransport {
this.app = app ?? express()
this.path = path ?? '/'

this.app.use((req, res, next) => {
const contentType = req.headers['content-type']

if (!contentType || !supportedContentTypes.includes(contentType)) {
return res
.status(415)
.send('Unsupported content-type. Supported content-types are: ' + supportedContentTypes.join(', '))
}

return next()
})

this.app.use(text({ type: supportedContentTypes, limit: '5mb' }))
}

Expand All @@ -48,6 +36,14 @@ export class HttpInboundTransport implements InboundTransport {
})

this.app.post(this.path, async (req, res) => {
const contentType = req.headers['content-type']

if (!contentType || !supportedContentTypes.includes(contentType)) {
return res
.status(415)
.send('Unsupported content-type. Supported content-types are: ' + supportedContentTypes.join(', '))
}

const session = new HttpTransportSession(utils.uuid(), req, res)
try {
const message = req.body
Expand Down
3 changes: 3 additions & 0 deletions samples/mediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { InitConfig } from '@aries-framework/core'
import type { Socket } from 'net'

import express from 'express'
import * as indySdk from 'indy-sdk'
import { Server } from 'ws'

import { TestLogger } from '../packages/core/tests/logger'
Expand All @@ -29,6 +30,7 @@ import {
LogLevel,
WsOutboundTransport,
} from '@aries-framework/core'
import { IndySdkModule } from '@aries-framework/indy-sdk'
import { HttpInboundTransport, agentDependencies, WsInboundTransport } from '@aries-framework/node'

const port = process.env.AGENT_PORT ? Number(process.env.AGENT_PORT) : 3001
Expand Down Expand Up @@ -58,6 +60,7 @@ const agent = new Agent({
config: agentConfig,
dependencies: agentDependencies,
modules: {
indySdk: new IndySdkModule({ indySdk }),
mediator: new MediatorModule({
autoAcceptMediationRequests: true,
}),
Expand Down

0 comments on commit 04a8058

Please sign in to comment.