Slava Fomin II
Slava Fomin II

Reputation: 28611

Disable some built-in functionality in Sails.js

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?

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.

Upvotes: 11

Views: 2308

Answers (1)

sgress454
sgress454

Reputation: 24948

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',
    'compress',
    'methodOverride',
    'poweredBy',
    '$custom',
    'router',
    // 'www',
    // 'favicon',
    '404',
    '500'      
  ]
}

That should get you on your way.

Upvotes: 18

Related Questions