Implements support in Sails


Implements support in Sails.

This is a core hook in the Sails.js framework. You can override or disable it using your .sailsrcfile or environment variables. See Concepts > Configurationfor more information.


If you have further questions or are having trouble, click here.

What version of Sails is this for?

This hook is for Sails v1.0 and up.

Prior to Sails v1.0, this hook was a dependency of Sails core. But now, it is now installed as a direct dependency of your Sails app.

What is this? What does it do?

This repo contains a hook, one of the building blocks Sails is made out of.

This hook's responsibilities are:

  • When initialized...
    • fire up server
    • listen for connect / disconnect events
      • listen for get/post/put/delete/patch events
        • create bare-bones request and response contexts, then pass them to the core interpreter in Sails to be routed on the fly.
    • Bind after"shadow" routes...
      • GET /__getcookie
    • Expose on the sailsapp object:

What version of does this hook use?

Click hereto check out the semver range for this hook's dependency.

For reproducibility, we always pin 3rd party dependencies to a specific version, using a consistent verified version string when possible (see kit).


To report a bug, click here.


Please observe the guidelines and conventions laid out in the Sails project contribution guidewhen opening issues or submitting pull requests.

Running the tests

First, clone this repo, cd into it, and install dependencies:

git clone
cd sails-hook-sockets
npm install
Run them all

To run all the tests, start a local redis server on port 6380 and then run the tests using mocha:

redis-server --port 6380 --requirepass 'secret'
npm test
Run only certain tests

Alternatively, you can run a particular set of tests with:

node ./node_modules/mocha/bin/mocha -g 'without session'

(this may be useful if you don't want to wait for all the tests to run, or e.g. if you aren't able to install a redis server locally. However please make sure all the tests pass before submitting a PR.)


The Sails frameworkis free and open-source under the MIT License.




  • 面试题:Hooks 与 React 生命周期的关系

    React 生命周期很多人都了解,但通常我们所了解的都是 单个组件 的生命周期,但针对 Hooks 组件、多个关联组件(父子组件和兄弟组件) 的生命周期又是怎么样的喃?你有思考和了解过吗,接下来我们将...

    10 个月前
  • 面试官: 聊一聊 HOC、Render props、Hooks

    在以前我们可能会看到很多文章在分析 HOC 和 render props, 但是在 2020 年 ,我们有了新欢 “hook” . 本篇文章会分析 hook , render props 和 HOC ...

    3 个月前
  • 通过简单的示例来理解React Hook

    This hook makes it easy to dynamically change the appearance of your app using CSS variables. You si...

    1 年前
  • 让你我不得不学习的React Hook

    1 什么是Hook 首先我们要明白的是React 16.8 的新增特性。它可以让我们在不编写 class 的情况下使用 state 以及其他的 React 特性。

    1 年前
  • 自定义 React Hook

    对于开发者来说,函数是对某一个功能的封装,那么 hook 就是对相同逻辑功能的封装。当你觉得重复在做一件事情的时候,那么你会把它封装成一个函数。同理,当你觉得在写重复的逻辑时,那么它就可以是一个 ho...

    1 天前
  • 结合React的Effect Hook分析组件副作用的清除

    一个订阅好友在线的组件 我们在DidMount的时候通过ID订阅了好友的在线状态 并且为了防止内存泄漏,我们需要在WillUnmount清除订阅 但是当组件已经显示在屏幕上时,friend pr...

    8 个月前
  • 终于搞懂 React Hooks了!!!!!

    (/public/upload/776f7115c905ba46eadd00ff62b8c272) (/public/upload/aa428a9f0941877303e5b6476eea...

    3 个月前
  • 精读《怎么用 React Hooks 造轮子》

    1 引言 上周的 精读《React Hooks》(

    2 年前
  • 精读《React Hooks》

    1 引言 React Hooks 是 React 版本推出的新特性,想尝试的同学安装此版本即可。 React Hooks 要解决的问题是状态共享,是继 renderprops(https://...

    2 年前
  • 精读《React Hooks 最佳实践》

    简介 React 16.8 于 2019.2 正式发布,这是一个能提升代码质量和开发效率的特性,笔者就抛砖引玉先列出一些实践点,希望得到大家进一步讨论。 然而需要理解的是,没有一个完美的最佳实践...

    9 个月前


扫码加入 JavaScript 社区