Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@types/connect-redis
Advanced tools
@types/connect-redis provides TypeScript type definitions for the connect-redis package, which is a Redis session store for Express. This package allows developers to use Redis as a session store in their Express applications with type safety provided by TypeScript.
Setting up Redis session store
This code demonstrates how to set up a Redis session store in an Express application using the connect-redis package. The RedisStore is created with a Redis client and used as the session store in the Express app.
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const redisClient = require('redis').createClient();
const app = require('express')();
app.use(session({
store: new RedisStore({ client: redisClient }),
secret: 'your-secret-key',
resave: false,
saveUninitialized: false
}));
Configuring Redis store options
This code sample shows how to configure various options for the Redis store, such as host, port, TTL (time to live), database index, password, and key prefix. These options allow for more fine-grained control over the Redis session store.
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const redisClient = require('redis').createClient();
const app = require('express')();
app.use(session({
store: new RedisStore({
client: redisClient,
host: 'localhost',
port: 6379,
ttl: 260,
disableTTL: false,
db: 0,
pass: 'your-password',
prefix: 'sess:'
}),
secret: 'your-secret-key',
resave: false,
saveUninitialized: false
}));
@types/express-session provides TypeScript type definitions for the express-session package, which is a general session middleware for Express. While it does not specifically target Redis, it is a core dependency for connect-redis and can be used with various session stores.
@types/ioredis provides TypeScript type definitions for the ioredis package, which is a robust, full-featured Redis client for Node.js. While it does not provide session store functionality, it can be used to interact with Redis in a more general sense and can be combined with other packages to achieve similar results.
@types/redis provides TypeScript type definitions for the redis package, which is a popular Redis client for Node.js. Similar to @types/ioredis, it does not provide session store functionality but can be used to interact with Redis and can be combined with other packages for session management.
npm install --save @types/connect-redis
This package contains type definitions for connect-redis (https://npmjs.com/package/connect-redis).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/connect-redis
Additional Details
These definitions were written by Xavier Stouder https://github.com/xstoudi, Albert Kurniawan https://github.com/morcerf.
FAQs
TypeScript definitions for connect-redis
The npm package @types/connect-redis receives a total of 129,461 weekly downloads. As such, @types/connect-redis popularity was classified as popular.
We found that @types/connect-redis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.