fix(about): Adding about JSON command

This commit is contained in:
Chris Troutner
2021-04-14 07:36:30 -07:00
parent 1e36b40ac0
commit 0abc332a80
8 changed files with 124 additions and 7 deletions
+15
View File
@@ -0,0 +1,15 @@
/*
This file should be customized for your app. The string in this file is
displayed when a user makes the 'about' JSON RPC call.
*/
module.exports = `
This is the about string for the ipfs-service-provider repository:
https://github.com/Permissionless-Software-Foundation/ipfs-service-provider
Brought to you by the Permissionless Software Foundation:
https://PSFoundation.cash
Documentation:
https://ipfs-service-provider.fullstack.cash/
`
+7 -5
View File
@@ -6587,7 +6587,8 @@
},
"ini": {
"version": "1.3.5",
"resolved": "",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"optional": true
},
"is-fullwidth-code-point": {
@@ -6790,7 +6791,8 @@
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"optional": true
}
}
@@ -8677,9 +8679,9 @@
}
},
"ipfs-coord": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-3.0.4.tgz",
"integrity": "sha512-z9c1vxR8krDGPnV97A6GrJ7o5NjpMFzoNWoQNmQdud13pO1tJbcXCvM2DVR/9m9CHs+WNht4PuC4zNF/61fXHw==",
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-3.0.6.tgz",
"integrity": "sha512-EmlLcYptpOztZ9aLB6DHL8vy0gsnRzvRMzBOno1jW7Ht/SP7KhhYGpXvG/8+BYRFgFhAHPHiC2CJMn9N9La4fw==",
"requires": {
"bch-encrypt-lib": "^2.0.0",
"orbit-db": "^0.26.1"
+1 -1
View File
@@ -40,7 +40,7 @@
"bcryptjs": "^2.4.3",
"glob": "^7.1.6",
"ipfs": "^0.54.4",
"ipfs-coord": "^3.0.4",
"ipfs-coord": "^3.0.6",
"jsonrpc-lite": "^2.2.0",
"jsonwebtoken": "^8.5.1",
"kcors": "^2.2.2",
+2 -1
View File
@@ -85,7 +85,8 @@ class IPFSLib {
// type: 'browser',
bchjs: this.bchjs,
privateLog: this.rpc.router,
isCircuitRelay: this.config.isCircuitRelay
isCircuitRelay: this.config.isCircuitRelay,
apiInfo: 'https://ipfs-service-provider.fullstack.cash/'
})
await this.ipfsCoord.isReady()
+45
View File
@@ -0,0 +1,45 @@
/*
This is the JSON RPC router for the users API
*/
// Public npm libraries
const jsonrpc = require('jsonrpc-lite')
// Local libraries
const aboutStr = require('../../../config/about')
class AuthRPC {
constructor (localConfig) {
// Encapsulate dependencies
this.jsonrpc = jsonrpc
}
/**
* @api {JSON} /about About IPFS Node
* @apiPermission public
* @apiName About
* @apiGroup JSON About
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"555","method":"about"}
*
* @apiDescription
* This endpoint can be customized so that users can retrieve information about
* your IPFS node and Service Provider application. This is a great place to
* put a website URL, an IPFS hash, an other basic information.
*/
// This is the top-level router for this library.
// This is a bit different than other router libraries, because there is
// only one response, which is a string about this node.
async aboutRouter (rpcData) {
return {
success: true,
status: 200,
message: aboutStr,
endpoint: 'about'
}
}
}
module.exports = AuthRPC
+10
View File
@@ -47,6 +47,16 @@ class AuthRPC {
}
}
/**
* @api {JSON} /auth Get JWT Token
* @apiPermission public
* @apiName AuthUser
* @apiGroup JSON Auth
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"556","method":"auth","params":{ "endpoint": "authUser", "login": "test555@test.com", "password": "password"}}
*
*/
async authUser (rpcData) {
try {
// console.log('authUser rpcData: ', rpcData)
+4
View File
@@ -9,6 +9,7 @@ const jsonrpc = require('jsonrpc-lite')
const wlogger = require('../lib/wlogger')
const UserController = require('./users')
const AuthController = require('./auth')
const AboutController = require('./about')
let _this
@@ -18,6 +19,7 @@ class JSONRPC {
this.jsonrpc = jsonrpc
this.userController = new UserController()
this.authController = new AuthController()
this.aboutController = new AboutController()
// This will be replaced once the ipfs-coord lib finishes initializing.
this.ipfsCoord = {}
@@ -60,6 +62,8 @@ class JSONRPC {
case 'auth':
retObj = await _this.authController.authRouter(parsedData)
break
case 'about':
retObj = await _this.aboutController.aboutRouter(parsedData)
}
// console.log('retObj: ', retObj)
+40
View File
@@ -129,6 +129,16 @@ class UserRPC {
}
}
/**
* @api {JSON} /users Get all users
* @apiPermission public
* @apiName GetAllUsers
* @apiGroup JSON Users
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"555","method":"users","params":{ "endpoint": "getAllUsers", "apiToken": "<JWT>"}}
*
*/
// Get all Users.
async getAll () {
try {
@@ -155,6 +165,16 @@ class UserRPC {
}
}
/**
* @api {JSON} /users Get a user
* @apiPermission public
* @apiName GetAUser
* @apiGroup JSON Users
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"123","method":"users","params":{ "endpoint": "getUser", "apiToken": "<JWT>", "userId": "<_id>"}}
*
*/
// Get a specific user.
async getUser (rpcData, userModel) {
try {
@@ -186,6 +206,16 @@ class UserRPC {
}
}
/**
* @api {JSON} /users Update a user
* @apiPermission public
* @apiName UpdateAUser
* @apiGroup JSON Users
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"123","method":"users","params":{ "endpoint": "updateUser", "apiToken": "<JWT>", "userId": "<_id>", "name": "test999"}}
*
*/
async updateUser (rpcData, userModel) {
try {
// console.log('updateUser rpcData: ', rpcData)
@@ -214,6 +244,16 @@ class UserRPC {
}
}
/**
* @api {JSON} /users Delete a user
* @apiPermission public
* @apiName DeleteAUser
* @apiGroup JSON Users
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"123","method":"users","params":{ "endpoint": "deleteUser", "userId": "<_id>", "apiToken": "<JWT>"}}
*
*/
async deleteUser (rpcData, userModel) {
try {
// console.log('deleteUser rpcData: ', rpcData)