Reacting
Reacting

Reputation: 6123

SailsJS only for API Processes (?)

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

Answers (2)

Yedhu Krishnan
Yedhu Krishnan

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

facundofarias
facundofarias

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

Related Questions