Skip to content

Fabstir/fabstirdb-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FabstirDB Backend

Introduction

Welcome to FabstirDB Backend, a scalable server software that manages a OrbitDB instance, enabling decentralized data storage and querying. This project is designed to work in tandem with our companion library package, FabstirDB, which provides an interface mimicking GUN API to make it easier to integrate into applications.

Summary

This project exposes several key components for an OrbitDb backend server that uses IPFS to store its data.

Functions

  • startServer(): This function starts the server asynchronously. It includes several middleware functions for user authentication and access control.
  • initAclDB(): This function initializes the Access Control List (ACL) database.
  • initUserDB(): This function initializes the User database.

API Endpoints

  • GET /acl/:alias: Retrieves the Access Control List (ACL) entry for a user.
  • GET /:path*: Fetches data based on a path.
  • POST /:path*: Saves data to a specified path.
  • DELETE /:path*: Deletes data at a specified path.

Each function and API endpoint is documented in detail, including its purpose, the parameters it accepts, and any errors it may throw.

Documentation

Functions

startServer()

Starts the server asynchronously.

initAclDB()void

Initializes the Access Control List (ACL) database.

initUserDB()void

Initializes the User database.

P

startServer()

Starts the server asynchronously.

Kind: global function
Throws:

startServer~authenticate(req, res, next) ⇒ void

Middleware function for authenticating a user.

Kind: inner method of startServer
Throws:

  • Error If the token is invalid.
Param Type Description
req Object The Express request object.
res Object The Express response object.
next function The next middleware function.

startServer~checkWriteAccess(req, res, next) ⇒ void

Middleware function for checking write access of a user.

Kind: inner method of startServer
Throws:

  • Error If the access check fails.
Param Type Description
req Object The Express request object.
res Object The Express response object.
next function The next middleware function.

startServer~authenticateTempToken(req, res, next) ⇒ void

Middleware function for authenticating a temporary token.

Kind: inner method of startServer
Throws:

  • Error If the token is invalid or expired.
Param Type Description
req Object The Express request object.
res Object The Express response object.
next function The next middleware function.

initAclDB() ⇒ void

Initializes the Access Control List (ACL) OrbitDB database.

Kind: global function
Throws:

  • Error If there is an error while creating the identity, initializing IPFS, creating the OrbitDB instance, or creating the ACL store.

initUserDB() ⇒ void

Initializes the User OrbitDB database.

Kind: global function
Throws:

  • Error If there is an error while creating the IPFS instance.

API Documentation

GET /acl/:alias

Express route handler for retrieving the Access Control List (ACL) entry for a user.

  • Type: Async
  • Request: req (Object)
    • req.params (Object)
      • req.params.alias (string): The alias of the user whose ACL entry is being retrieved.
  • Response: res (Object)
  • Returns: void
  • Throws: Error if there is an error while retrieving the ACL entry.

GET /:path*

Express route handler for fetching data based on a path.

  • Type: Async
  • Request: req (Object)
    • req.params (Object)
      • req.params.path (string): The path of the data to be fetched.
  • Response: res (Object)
  • Returns: void
  • Throws: Error if there is an error while fetching the data.

POST /:path*

Express route handler for saving data to a specified path.

  • Type: Async
  • Request: req (Object)
    • req.params (Object)
      • req.params.path (string): The path where the data will be saved.
    • req.body (Object): The body of the request, containing the data to be saved.
  • Response: res (Object)
  • Returns: void
  • Throws: Error if there is an error while saving the data.

DELETE /:path*

Express route handler for deleting data at a specified path.

  • Type: Async
  • Request: req (Object)
    • req.params (Object)
      • req.params.path (string): The path of the data to be deleted.
  • Response: res (Object)
  • Returns: void
  • Throws: Error if there is an error while deleting the data.

Installation and Setup

This application uses JSON Web Tokens (JWT) for authentication. To enable this, you need to set a secret key that's used to sign and verify the tokens. You set this key by setting the JWT_SECRET environment variable.

yarn install
node server.js

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published