hono-sessions-redis
所属分类:其他
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2024-04-26 07:58:25
上 传 者:
sh-1993
说明: Redis store adapter for hono-sessions, on Node.js (ioredis), stars:1, update:2024-04-25 19:40:31
文件列表:
dist/
src/
build.cjs
index.js
package.json
pnpm-lock.yaml
# hono-sessions-redis
Redis session store-connector to work with [hono-sessions](https://github.com/jcs224/hono_sessions)
This repo is a fork of [connect-redis-hono](https://github.com/crossunit/connect-redis-hono)
## Installation
```sh
$ pnpm add hono-sessions-redis
```
## Usage
```js
import { Hono } from "hono";
import { sessionMiddleware } from "hono-sessions";
import { RedisStoreAdapter } from "hono-sessions-redis";
// ...
// create your RedisClient and connect to your redis server
// ...
const store = new RedisStoreAdapter({
prefix: "AppPrefix:",
ttl: 3600, // seconds
client: RedisClient,
});
const app = new Hono();
app.use(sessionMiddleware({
store, // pass your store
// ...other session options
}));
app.get("/", (ctx) => {
return ctx.text("Session data stored on Redis");
});
export default {
port: 3000,
fetch: app.fetch,
};
```
## Redis client
As of right now this package is only compatible with [ioredis](https://www.npmjs.com/package/ioredis).
近期下载者:
相关文件:
收藏者: