Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 17712a4

Browse files
committed
feat(gateway): range and conditional requests
- Switched from deprecated `hapi` and `joi` to `@hapi/hapi` and `@hapi/joi` - Added support for Conditional Requests (RFC7232) - Returning `304 Not Modified` if `If-None-Match` is a CID matching `Etag` - Added `Last-Modified` to `/ipfs/` responses (improves client-side caching) - Always returning `304 Not Modified` when `If-Modified-Since` is present for immutable `/ipfs/` - Added support for Byte Range requests (RFC7233, Section-2.1) - Added support for `?filename=` parameter (improves downloads of raw cids) License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
1 parent 373f69e commit 17712a4

File tree

15 files changed

+324
-18
lines changed

15 files changed

+324
-18
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
"stream-to-promise": "^2.2.0"
8383
},
8484
"dependencies": {
85+
"@hapi/ammo": "^3.1.0",
86+
"@hapi/hapi": "^18.3.1",
87+
"@hapi/joi": "^15.0.0",
8588
"async": "^2.6.1",
8689
"bignumber.js": "^8.0.2",
8790
"binary-querystring": "~0.1.2",
@@ -103,7 +106,6 @@
103106
"fsm-event": "^2.1.0",
104107
"get-folder-size": "^2.0.0",
105108
"glob": "^7.1.3",
106-
"hapi": "^18.0.0",
107109
"hapi-pino": "^5.2.0",
108110
"human-to-milliseconds": "^1.0.0",
109111
"interface-datastore": "~0.6.0",
@@ -131,7 +133,6 @@
131133
"is-pull-stream": "~0.0.0",
132134
"is-stream": "^1.1.0",
133135
"iso-url": "~0.4.6",
134-
"joi": "^14.3.0",
135136
"just-flatten-it": "^2.1.0",
136137
"just-safe-set": "^2.1.0",
137138
"libp2p": "~0.25.0",

src/http/api/resources/bitswap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const Joi = require('joi')
3+
const Joi = require('@hapi/joi')
44
const multibase = require('multibase')
55
const { cidToString } = require('../../../utils/cid')
66
const { parseKey } = require('./block')

src/http/api/resources/block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const CID = require('cids')
44
const multipart = require('ipfs-multipart')
5-
const Joi = require('joi')
5+
const Joi = require('@hapi/joi')
66
const multibase = require('multibase')
77
const Boom = require('boom')
88
const { cidToString } = require('../../../utils/cid')

src/http/api/resources/dag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const promisify = require('promisify-es6')
44
const CID = require('cids')
55
const multipart = require('ipfs-multipart')
66
const mh = require('multihashes')
7-
const Joi = require('joi')
7+
const Joi = require('@hapi/joi')
88
const multibase = require('multibase')
99
const Boom = require('boom')
1010
const debug = require('debug')

src/http/api/resources/dht.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const Joi = require('joi')
3+
const Joi = require('@hapi/joi')
44
const Boom = require('boom')
55

66
const CID = require('cids')

src/http/api/resources/files-regular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const toPull = require('stream-to-pull-stream')
1010
const pushable = require('pull-pushable')
1111
const toStream = require('pull-stream-to-stream')
1212
const abortable = require('pull-abortable')
13-
const Joi = require('joi')
13+
const Joi = require('@hapi/joi')
1414
const Boom = require('boom')
1515
const ndjson = require('pull-ndjson')
1616
const { PassThrough } = require('readable-stream')

src/http/api/resources/name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const Joi = require('joi')
3+
const Joi = require('@hapi/joi')
44

55
exports.resolve = {
66
validate: {

src/http/api/resources/object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { DAGNode, DAGLink } = dagPB
88
const calculateCid = promisify(dagPB.util.cid)
99
const deserialize = promisify(dagPB.util.deserialize)
1010
const createDagNode = promisify(DAGNode.create)
11-
const Joi = require('joi')
11+
const Joi = require('@hapi/joi')
1212
const multibase = require('multibase')
1313
const Boom = require('boom')
1414
const { cidToString } = require('../../../utils/cid')

src/http/api/resources/pin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const multibase = require('multibase')
4-
const Joi = require('joi')
4+
const Joi = require('@hapi/joi')
55
const Boom = require('boom')
66
const isIpfs = require('is-ipfs')
77
const { cidToString } = require('../../../utils/cid')

src/http/api/resources/ping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const Joi = require('joi')
3+
const Joi = require('@hapi/joi')
44
const pull = require('pull-stream')
55
const ndjson = require('pull-ndjson')
66
const { PassThrough } = require('readable-stream')

0 commit comments

Comments
 (0)