2.0.0 • Published 2 years ago
@verixyz/remote-server v2.0.0
verixyz Express
A utility module that contains express.js routers to:
- expose some agent methods to other agents or APIs
- serve open API schema for these methods
- serve did:web did documents
Functions
apiKeyAuth({ apiKey })
createDefaultDid(options)
Interfaces
AgentRouterOptions
ApiSchemaRouterOptions
Variables
AgentRouter
Creates a router that exposes Agent methods
ApiSchemaRouter
Creates a router that exposes Agent OpenAPI schema
didDocEndpoint
MessagingRouter
Creates a router for handling incoming messages
RequestWithAgentRouter
Creates a router that adds veramo agent to the request object
WebDidDocRouter
Creates a router that serves did:web DID Documents
Example
import express from 'express'
import { agent } from './agent'
import { AgentRouter, ApiSchemaRouter, WebDidDocRouter } from '@veramo/remote-server'
const getAgentForRequest = async (req: express.Request) => agent
const exposedMethods = agent.availableMethods()
const basePath = '/agent'
const schemaPath = '/open-api.json'
const agentRouter = AgentRouter({
getAgentForRequest,
exposedMethods,
})
const schemaRouter = ApiSchemaRouter({
basePath,
getAgentForRequest,
exposedMethods,
})
const didDocRouter = WebDidDocRouter({
getAgentForRequest,
})
const app = express()
app.use(basePath, agentRouter)
app.use(schemaPath, schemaRouter)
app.use(didDocRouter)
app.listen(3002)