From ea2bcbb217ba7b50502a2503ebcde90d98c59fc4 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 17 Jun 2025 23:17:19 +1000 Subject: [PATCH] feat: Add cache clear api route --- lib/handshake.js | 15 ++++++++++++++- package.json | 30 ++++++------------------------ public/demo.html | 11 ++++++++++- public/index.html | 13 +++++++++++++ server.js | 41 ++++++++++++++++++++++++++++++++++++++++- 5 files changed, 83 insertions(+), 27 deletions(-) diff --git a/lib/handshake.js b/lib/handshake.js index 4daa79d..482303a 100644 --- a/lib/handshake.js +++ b/lib/handshake.js @@ -328,6 +328,19 @@ function extractCidFromRecords(records) { return null; } + +/** + * Clear the cache for a specific domain + * @param {string} domain - The Handshake domain to clear from cache + */ +function clearCache(domain) { + if (CACHE_ENABLED) { + cache.del(`hns:${domain}`); + console.log(`Cache cleared for ${domain}`); + } +} + module.exports = { - resolveHandshake + resolveHandshake, + clearCache }; diff --git a/package.json b/package.json index 985f9ed..6c30074 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,17 @@ { "name": "fireportal", - "version": "0.1.0", - "description": "An IPFS gateway for Handshake domains", + "version": "1.0.0", + "description": "IPFS Gateway for Handshake Domains", "main": "server.js", "scripts": { "start": "node server.js", - "dev": "nodemon server.js", - "test": "jest", - "mock": "node tests/mock-resolver.js & node server.js" + "dev": "nodemon server.js" }, - "keywords": [ - "ipfs", - "handshake", - "gateway", - "hns", - "decentralized" - ], - "author": "", - "license": "MIT", "dependencies": { - "express": "^4.18.2", - "ipfs-http-client": "^56.0.3", - "dotenv": "^16.0.3", - "node-cache": "^5.1.2", - "cors": "^2.8.5", - "morgan": "^1.10.0", - "winston": "^3.8.2", - "body-parser": "^1.20.2" + "express": "^4.17.1", + "node-fetch": "^2.6.7" }, "devDependencies": { - "nodemon": "^2.0.22", - "jest": "^29.5.0" + "nodemon": "^2.0.15" } } diff --git a/public/demo.html b/public/demo.html index d357e96..654e2b7 100644 --- a/public/demo.html +++ b/public/demo.html @@ -5,14 +5,23 @@ IPFS.act + + + + + + +

IPFS.act

This is a demo page running on IPFS.

It is designed to showcase the capabilities of IPFS and Handshake domains.

+ Fire Portal +
- © Nathan.Woodburn/ + © Nathan.Woodburn/
\ No newline at end of file diff --git a/public/index.html b/public/index.html index 5c9ee35..c108fd6 100644 --- a/public/index.html +++ b/public/index.html @@ -157,6 +157,19 @@
  • Wait a few minutes and you should be able to see your IPFS content on the domain
  • + +
    +

    API Reference

    +

    + Fire Portal provides API endpoints to programmatically interact with the service: +

    + +