
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
@types/connect-redis
Advanced tools
TypeScript definitions for connect-redis
@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://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/connect-redis.
/// <reference types="express" />
/// <reference types="express-session" />
/// <reference types="redis" />
declare module "connect-redis" {
import * as express from "express";
import * as session from "express-session";
import * as ioRedis from "ioredis";
import * as redis from "redis";
function s(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore;
namespace s {
type Client = redis.RedisClient | ioRedis.Redis | ioRedis.Cluster;
interface RedisStore extends session.Store {
new(options: RedisStoreOptions): RedisStore;
client: Client;
}
interface RedisStoreOptions {
client?: Client | undefined;
host?: string | undefined;
port?: number | undefined;
socket?: string | undefined;
url?: string | undefined;
ttl?: number | string | ((store: RedisStore, sess: session.SessionData, sid: string) => number) | undefined;
disableTTL?: boolean | undefined;
disableTouch?: boolean | undefined;
db?: number | undefined;
pass?: string | undefined;
prefix?: string | undefined;
unref?: boolean | undefined;
serializer?: Serializer | JSON | undefined;
logErrors?: boolean | ((error: string) => void) | undefined;
scanCount?: number | undefined;
}
interface Serializer {
stringify: Function;
parse: Function;
}
}
export = s;
}
These definitions were written by Xavier Stouder, Seth Butler, and Jip Sterk.
FAQs
TypeScript definitions for connect-redis
The npm package @types/connect-redis receives a total of 139,456 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.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.