1
votes

I'm trying to build a very simple Rest API, I'd like to use sails (v0.11.0) blueprints.

Initially;

  • I only want to use Http GET disable other methods
  • Just return plain json, no views for findOne, findAll.
  • Use a prefix like '/api/v1' but don't want to include all controllers, Example: Make controllerA url like '/api/v1/controllerA' but not '/api/v1/controllerB'

I have been playing with the blueprints but I couldn't be able to do all above. Sorry for too many questions all at once! but I really appreciate if somebody can help.

Thanks

1
This is all available in the sails documentation: sailsjs.org/#! - Travis Webb

1 Answers

4
votes

I only want to use Http GET disable other methods

You should override built-in blueprints by creating files in your /api/blueprints folder with empty functions or throwing errors.

Just return plain json, no views for findOne, findAll

I guess this is default behaviour of sails blueprints.

Use a prefix like '/api/v1'

Sails has blueprints configuration (in your /config folder). There you can set useful prefix and/or restPrefix options that are designed to do exactly what you want

but don't want to include all controllers

You should set _config object in your controller to be:

_config: {
    actions: false,
    shortcuts: false,
    rest: false
}