npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fooler-session

v1.0.1

Published

redis session for fooler

Downloads

4

Readme

fooler-session

  1. fooler-session 是一 fooler-core 框架 的session 支持;

一、安装使用

  1. npm install fooler-session
  2. 设置启动配置 session 的 redis 链接配置
  3. 路由使用 这个组件

二、示例1 在指定路由设置使用session

const { Fooler } = require('fooler-core');
const Session = require('fooler-session');
const app = Fooler.create({
    p: 8080,
    processes: 1,

    "session": {            //这个配置时必须的
        "port": 6379,
        "host": "127.1.0.1",
        "options": {}       //如果设置密码 options的值 {"password": "123456","db": 0}
    }
});
app.route.GET(/^.*/)
    .then(Session)          //在置顶路由中使用
    .then(async ({ ctx }) => {
        let data = await ctx.session.get();
        ctx.session.set('times', (data.times || 0) + 1);
        ctx.sendJSON(data)
    });
app.run();

三、全局设置 session

const { Fooler } = require('fooler-core');
const Session = require('fooler-session');
const app = Fooler.create({
    p: 8080,
    processes: 1,

    "session": {            //这个配置时必须的
        "port": 6379,
        "host": "127.1.0.1",
        "options": {}       //如果设置密码 options的值 {"password": "123456","db": 0}
    }
});
app.route.then(Session);    //在顶级路由中设置session
app.route.GET(/^.*/)
    .then(async ({ ctx }) => {
        let data = await ctx.session.get();
        ctx.session.set('times', (data.times || 0) + 1);
        ctx.sendJSON(data)
    });
app.run();

三、给指定路由组 session

const { Fooler } = require('fooler-core');
const Session = require('fooler-session');
const app = Fooler.create({
    p: 8080,
    processes: 1,

    "session": {        //这个配置时必须的
        "port": 6379,
        "host": "127.1.0.1",
        "options": {}   //如果设置密码 options的值 {"password": "123456","db": 0}
    }
});
app.route.when('/my')
    .then(Session)      //给指定路由组 session
    .childen((r)=>{
        r.when('/book/add').then(async ({ ctx }) => {
            let data = await ctx.session.get();
            ctx.session.set('times', (data.times || 0) + 1);
            ctx.sendJSON(data)
        }
        r.when('/book/rem').then(async ({ ctx }) => {
            let data = await ctx.session.get();
            ctx.session.set('times', (data.times || 0) + 1);
            ctx.sendJSON(data)
        }
    });
app.run();