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.
This project exposes several key components for an OrbitDb backend server that uses IPFS to store its data.
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.
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.
- startServer()
Starts the server asynchronously.
- initAclDB() ⇒
void
Initializes the Access Control List (ACL) database.
- initUserDB() ⇒
void
Initializes the User database.
P
Starts the server asynchronously.
Kind: global function
Throws:
-
Error
If the server fails to start.
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. |
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. |
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. |
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.
Initializes the User OrbitDB database.
Kind: global function
Throws:
Error
If there is an error while creating the IPFS instance.
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.
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.
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.
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.
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