Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问route.js文件中router和routes有什么区别? #40

Closed
695954085 opened this issue Jul 31, 2018 · 1 comment
Closed

请问route.js文件中router和routes有什么区别? #40

695954085 opened this issue Jul 31, 2018 · 1 comment

Comments

@695954085
Copy link

module.exports = function (io, _io, routes) {
    const router = Object.keys(routes).reduce((result, route) => {
        io.on(route, noop);
        result[route] = routes[route];
        return result;
    }, {});
    return async (ctx) => {
        if (router[ctx.event]) {
            const { event, data, socket } = ctx;
            ctx.res = await router[ctx.event]({
                event,
                data,
                socket,
                io,
                _io,
            });
        }
    };
};

routes入参和router局部变量,不都是同样内容吗?

@yinxin630
Copy link
Owner

yinxin630 commented Jul 31, 2018

不好意思, 这块逻辑确实有问题, 回头修改一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants