Compare commits

..
3 Commits
Author SHA1 Message Date
Chris Troutner ac451fd601 Merge pull request #71 from Permissionless-Software-Foundation/ct-unstable
Passing pagination paramter through to PSFFPP
2025-04-16 07:38:00 -07:00
Chris Troutner 6857fe0166 linting 2025-04-16 07:29:40 -07:00
Chris Troutner 89a03e561a feat(GET /pins/:page): Adding pagenation to endpoint 2025-04-16 07:29:27 -07:00
5 changed files with 14 additions and 7 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"password": "mldYweOqZuC1X3hWOulN",
"password": "YsFhsCVCqussWyyLYUjM",
"email": "system@system.com",
"id": "67fb37a215494c3f09dae5ed",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3ZmIzN2EyMTU0OTRjM2YwOWRhZTVlZCIsImlhdCI6MTc0NDUxNzAyNn0.HpNCWf8VXveKHIF32eLV9sf9G0QlTmLdLKzEp9BxOg4"
"id": "67ffbea61a8de3388f82c401",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3ZmZiZWE2MWE4ZGUzMzg4ZjgyYzQwMSIsImlhdCI6MTc0NDgxMzczNH0.a4wM-CfGudF40yi4lwTsnd_aDZHrRn87zjHYxFZmeC4"
}
+4 -1
View File
@@ -191,8 +191,11 @@ class IpfsFilesAdapter {
throw new Error('No IPFS File Pin Service provider available yet.')
}
const { page } = inObj
const rpcData = {
endpoint: 'getPins'
endpoint: 'getPins',
page
}
// Generate a UUID for the call.
+2 -2
View File
@@ -262,11 +262,11 @@ class IpfsRESTControllerLib {
*/
async getPins (ctx) {
try {
// const { cid } = ctx.params
const { page } = ctx.params
const ipfsFiles = this.adapters.ipfsFiles
const pinData = await ipfsFiles.getPins()
const pinData = await ipfsFiles.getPins({ page })
console.log('getPins() pinData: ', pinData)
ctx.body = pinData
+1 -1
View File
@@ -60,7 +60,7 @@ class IpfsRouter {
this.router.get('/download/:cid', this.ipfsRESTController.downloadFile)
this.router.get('/service', this.ipfsRESTController.getService)
this.router.get('/file-info/:cid', this.ipfsRESTController.getFileInfo)
this.router.get('/pins', this.ipfsRESTController.getPins)
this.router.get('/pins/:page', this.ipfsRESTController.getPins)
this.router.get('/cid2json/:cid', this.ipfsRESTController.cid2json)
this.router.post('/pin-claim', this.ipfsRESTController.pinClaim)
// Attach the Controller routes to the Koa app.
@@ -400,12 +400,14 @@ describe('#IPFS REST API', () => {
assert.isTrue(ctx.body.success)
})
})
describe('#getPins', () => {
it('should return 422 status on biz logic error', async () => {
try {
sandbox.stub(uut.adapters.ipfsFiles, 'getPins').throws(new Error('test error'))
ctx.request.body = {}
ctx.params = { page: 1 }
await uut.getPins(ctx)
@@ -421,12 +423,14 @@ describe('#IPFS REST API', () => {
sandbox.stub(uut.adapters.ipfsFiles, 'getPins').resolves({ success: true })
ctx.request.body = {}
ctx.params = { page: 1 }
await uut.getPins(ctx)
assert.isTrue(ctx.body.success)
})
})
describe('#cid2json', () => {
it('should return 422 status on biz logic error', async () => {
try {