最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable some built-in functionality in Sails.js - Stack Overflow

programmeradmin1浏览0评论

I'm developing a REST API backend application using Sails.js 0.10 as a framework. This application will be strictly REST, authentication will be implemented using oAuth bearer tokens. All responses will be in JSON format.

Considering this specific requirements I do not need some functionality embedded into Sails.js and I want to remove it from my application (so it will run faster without extraneous code).

So, my question is: How do I disable the following built-in functionality?

  • Blueprints
  • Static
  • Cookies
  • Sessions
  • Views
  • WebSocket
  • CSRF
  • i18n

What else can be disabled that is not required in my use case?

The documentation is kinda fragmented on this specific question. All configuration options are described for each module, but there is no information of how such a module can be disabled and/or removed from the application.

I'm developing a REST API backend application using Sails.js 0.10 as a framework. This application will be strictly REST, authentication will be implemented using oAuth bearer tokens. All responses will be in JSON format.

Considering this specific requirements I do not need some functionality embedded into Sails.js and I want to remove it from my application (so it will run faster without extraneous code).

So, my question is: How do I disable the following built-in functionality?

  • Blueprints
  • Static
  • Cookies
  • Sessions
  • Views
  • WebSocket
  • CSRF
  • i18n

What else can be disabled that is not required in my use case?

The documentation is kinda fragmented on this specific question. All configuration options are described for each module, but there is no information of how such a module can be disabled and/or removed from the application.

Share Improve this question edited Jan 19, 2015 at 17:25 Slava Fomin II asked Jan 18, 2015 at 23:09 Slava Fomin IISlava Fomin II 28.7k34 gold badges134 silver badges208 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 18

Hardcore! You'll need to disable several hooks, and also some middleware. First, in your .sailsrc file, set:

"hooks": {
  "session": false,
  "sockets": false,
  "pubsub": false,
  "views": false,
  "csrf": false,
  "i18n": false,
  "blueprints": false
}

Then in your config/https.js:

middleware: {
  order: [
    'startRequestTimer',
    // 'cookieParser',
    // 'session',
    'bodyParser',
    'handleBodyParserError',
    'press',
    'methodOverride',
    'poweredBy',
    '$custom',
    'router',
    // 'www',
    // 'favicon',
    '404',
    '500'      
  ]
}

That should get you on your way.

发布评论

评论列表(0)

  1. 暂无评论