A Delegated Routing V1 HTTP API server powered by Helia
Implements HTTP routes for a Fastify server that conform to the Routing V1 HTTP API.
import { createHelia } from 'helia'
import { createDelegatedRoutingV1HttpApiServer } from '@helia/delegated-routing-v1-http-api-server'
const helia = await createHelia()
const server = await createDelegatedRoutingV1HttpApiServer(helia, {
listen: {
// fastify listen options
}
})
// now make http requests
Alternatively if you have a Fastify instance already you can add routes to it.
import fastify from 'fastify'
import cors from '@fastify/cors'
import { createHelia } from 'helia'
import routes from '@helia/routing-v1-http-api-server/routes'
const server = fastify({
// fastify options
})
await server.register(cors, {
origin: '*',
methods: ['GET', 'OPTIONS'],
strictPreflight: false
})
const helia = await createHelia()
// configure Routing V1 HTTP API routes
routes(server, helia)
await server.listen({
// fastify listen options
})
// now make http requests
$ npm i @helia/delegated-routing-v1-http-api-server
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Contributions welcome! Please check out the issues.
Also see our contributing document for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.