
Product
Introducing Custom Pull Request Alert Comment Headers
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
@arcblock/crawler-middleware
Advanced tools
This express middleware provides pre-rendered HTML generated by SnapKit for Blocklets, enabling them to return complete HTML content to web spider. This is essential for SEO and ensuring that search engines can properly index dynamically generated content
This express middleware provides pre-rendered HTML generated by SnapKit for Blocklets, enabling them to return complete HTML content to web spider. This is essential for SEO and ensuring that search engines can properly index dynamically generated content.
<meta name="arcblock-crawler" content="true">.
import { createSnapshotMiddleware } from '@arcblock/crawler-middleware';
const app = express();
const snapshotMiddleware = createSnapshotMiddleware({
endpoint: process.env.SNAP_KIT_ENDPOINT,
accessKey: process.env.SNAP_KIT_ACCESS_KEY,
allowCrawler: (req) => {
return req.path === '/';
},
});
// for all route
app.use(snapshotMiddleware);
// for one route
app.use('/doc', snapshotMiddleware, (req) => {
/* ... */
});
The options for createSnapshotMiddleware:
{
/** SnapKit endpoint */
endpoint: string;
/** SnapKit access key */
accessKey: string;
/** Max cache size for LRU cache */
cacheMax?: number;
/** When cache exceeds this time, it will try to fetch and update cache from SnapKit */
updateInterval?: number;
/** When failed cache exceeds this time, it will try to fetch and update cache from SnapKit */
failedUpdateInterval?: number;
/** Update queue concurrency */
updatedConcurrency?: number;
/** Call res.send(html) when cache hit */
autoReturnHtml?: boolean;
/** Custom function to determine whether to return cached content */
allowCrawler?: (req: Request) => boolean;
};
When using this middleware outside of a Blocklet environment, you need to configure the following environment variables:
BLOCKLET_DATA_DIR
: (Required) Directory path for storing the sqlite fileBLOCKLET_LOG_DIR
: (Required) Directory path for storing @blocklet/logger logsBLOCKLET_APP_URL
: (Optional) Deployed domainWhen createSnapshotMiddleware is called, it attempts to create an SQLite database at BLOCKLET_DATA_DIR
. This database is used to cache HTML content retrieved from SnapKit. Please ensure that the deployment environment supports SQLite.
FAQs
This express middleware provides pre-rendered HTML generated by SnapKit for Blocklets, enabling them to return complete HTML content to web spider. This is essential for SEO and ensuring that search engines can properly index dynamically generated content
We found that @arcblock/crawler-middleware demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.