Reputation: 6123
is there a way to use SailsJS only as an API?
I mean, once I download the Sails project I do not want to see the views or any other stuff there, all I want is use Sails as an API.
Upvotes: 1
Views: 158
Reputation: 1245
Sails provides APIs by default. Controllers by default returns res.json({})
. You can create views only if you need it (res.view()
).
For example, create a user controller with actions index
and edit
as follows:
sails generate controller user index edit
Now, when you access http://localhost:1337/user/edit
, you can see the default JSON response.
Learn more about sails controllers here: Controllers
Upvotes: 3
Reputation: 3043
Yes, it is. I imagine you have followed the instructions that are on their page, to install it:
$ sudo npm install sails -g
$ sails new testProject
You have everything described here. But for sure, you will configure the endpoints of your REST API on the routes definition, and if you don't want to expose any views, it's perfectly fine.
Upvotes: 2