
Security News
arXiv Is Rate Limiting Authors Following a Flood of AI Slop Submissions
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.
@device-router/middleware-express
Advanced tools
Express middleware for [DeviceRouter](https://github.com/SimplyLiz/DeviceRouter). Adds device classification and rendering hints to every request.
Express middleware for DeviceRouter. Adds device classification and rendering hints to every request.
pnpm add @device-router/middleware-express @device-router/storage cookie-parser
For automatic probe injection:
pnpm add @device-router/probe
import express from 'express';
import cookieParser from 'cookie-parser';
import { createDeviceRouter } from '@device-router/middleware-express';
import { MemoryStorageAdapter } from '@device-router/storage';
const app = express();
const { middleware, probeEndpoint } = createDeviceRouter({
storage: new MemoryStorageAdapter(),
});
app.use(express.json());
app.use(cookieParser());
app.post('/device-router/probe', probeEndpoint);
app.use(middleware);
app.get('/', (req, res) => {
const profile = req.deviceProfile;
if (profile?.hints.preferServerRendering) {
return res.send(renderSSR());
}
if (profile?.hints.deferHeavyComponents) {
return res.send(renderLite());
}
res.send(renderFull());
});
app.listen(3000);
req.deviceProfilereq.deviceProfile.hints and req.deviceProfile.tiers to adapt responsesAutomatically inject the probe <script> into HTML responses before </head>:
const { middleware, probeEndpoint, injectionMiddleware } = createDeviceRouter({
storage: new MemoryStorageAdapter(),
injectProbe: true,
probeNonce: 'my-csp-nonce', // optional, for Content-Security-Policy
});
app.use(injectionMiddleware); // before routes
app.post('/device-router/probe', probeEndpoint);
app.use(middleware);
Streaming responses: Injection intercepts
res.send()and requires the body to be a string. If you stream HTML viares.write(), the injection is silently skipped. Add the probe<script>tag to your HTML shell manually instead.
Override default tier classification boundaries:
const { middleware, probeEndpoint } = createDeviceRouter({
storage,
thresholds: {
cpu: { lowUpperBound: 4, midUpperBound: 8 },
memory: { midUpperBound: 8 },
},
});
| Option | Type | Default | Description |
|---|---|---|---|
storage | StorageAdapter | (required) | Storage backend for profiles |
cookieName | string | 'dr_session' | Session cookie name |
cookiePath | string | '/' | Cookie path |
cookieSecure | boolean | false | Set Secure flag on the session cookie |
ttl | number | 86400 (24h) | Profile TTL in seconds |
rejectBots | boolean | true | Reject bot/crawler probe submissions |
probePath | string | — | Custom probe endpoint path |
thresholds | TierThresholds | Built-in defaults | Custom tier thresholds (validated at startup) |
injectProbe | boolean | false | Auto-inject probe into HTML |
probeNonce | string | ((req: Request) => string) | — | CSP nonce for injected script |
fallbackProfile | FallbackProfile | — | Fallback profile for first requests |
classifyFromHeaders | boolean | false | Classify from UA/Client Hints |
createDeviceRouter(options) — All-in-one setup returning { middleware, probeEndpoint, injectionMiddleware? }createMiddleware(options) — Standalone middlewarecreateProbeEndpoint(options) — Standalone probe endpoint handlercreateInjectionMiddleware(options) — Standalone probe injection middlewarecookie-parser — required for session cookie handling (req.cookies)MIT
FAQs
Express middleware for DeviceRouter — device classification and rendering hints per request
The npm package @device-router/middleware-express receives a total of 1 weekly downloads. As such, @device-router/middleware-express popularity was classified as not popular.
We found that @device-router/middleware-express demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.

Research
/Security News
A new GhostAction wave hits hundreds of GitHub repos, expanding CI/CD secret theft to cloud and AI credentials in source code and git history.

Research
/Security News
Tensorlake npm SDK version 0.5.144 was compromised in a ChainDrop / Shai-Hulud attack, delivering credential-stealing malware.