1.0.0 • Published 9 months ago

@helia/pinning-service-api-server v1.0.0

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
9 months ago

@helia/pinning-service-api-server

ipfs.tech Discuss codecov CI

An IPFS Pinning Service API server powered by Helia

About

Implements HTTP routes for a Fastify server that conform to the IPFS Pinning Service API.

Example

import { createHelia } from 'helia'
import { createPinningServiceAPIServer} from '@helia/pinning-service-api-server'

const helia = await createHelia()
const server = await createRemotePinningServer(helia, {
  validateAccessToken: async (accessToken, options) => {
    // validate the user passed a valid token
    return true
  },
  listen: {
    // fastify listen options
  }
})

// now make http requests

Alternatively if you have a Fastify instance already you can add routes to it.

Example

import fastify from 'fastify'
import cors from '@fastify/cors'
import { createHelia } from 'helia'
import routes from '@helia/pinning-service-api-server/routes'

const server = fastify({
 // fastify options
})
await server.register(cors, {
  origin: '*',
  methods: ['GET', 'OPTIONS'],
  strictPreflight: false
})

const helia = await createHelia()

// configure Pinning Service HTTP API routes
routes(server, helia)

await server.listen({
  // fastify listen options
})

// now make http requests

Install

$ npm i @helia/pinning-service-api-server

API Docs

License

Licensed under either of

Contribute

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.

npm.io