Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
John Wolfe
@wolfejw86
i put a test function in there module.exports = { test: (req, res) => res.json({ it: 'works!'})} it worked for GET 'http://localhost:1337/v1/demo/test
did you check and see if in config/blueprints.js you have actions: true ?
newari
@newari
@wolfejw86 thanks for your response. But its not working from my side for default actions like find, update. And value of actions is true in config/blueprints.js
is it also working for find method(default blueprint action ) from your side?
John Wolfe
@wolfejw86
rest is true also??
newari
@newari
yes, its true
John Wolfe
@wolfejw86
does demo have a model as well?
newari
@newari
I have a model with same name of Demo.js
John Wolfe
@wolfejw86
yeah, i can't get it to work that way either
newari
@newari
Its working for custom actions but not blueprint actions (find, update etc)...
John Wolfe
@wolfejw86
yeah same
it works if you take out the v1
is it a common practice to version the models?
(i'm still a relatively new programmer and am unfamiliar with a lot of things)
newari
@newari
yes. But I need the api path with subfolder name.
John Wolfe
@wolfejw86
right
that makes sense if you want to version the models
newari
@newari
Actually I am using the subfolder for grouping my api because I have lots of API in my app. (Not for versioning in my case)
John Wolfe
@wolfejw86
gotcha, so just a lot of models and controllers.
newari
@newari
right
John Wolfe
@wolfejw86
and you want access to the default find/update routes from within those sub directories in the models
newari
@newari
yes.
John Wolfe
@wolfejw86
yeah i'm stumped as well, haven't needed to do that yet with the models. if you don't need to "version" them, but just need to call the default routes for them, they're all accessible though. i guess the other option is to include custom actions in your controllers to keep the url consistent (having v1,v2,etc. in it versus just api/demo1, api/demo2)
newari
@newari
But I have 50+ Model with 200+ Blueprint APIs. And the APIs are also used by many apps. Its difficult for me to change the path of APIs. It was working fine with V0.12
John Wolfe
@wolfejw86
ah, yeah, hopefully someone in here has dealt with a similar issue, sorry i couldn't be more helpful
newari
@newari
In v0.12 I am able to create blueprint routes with controller subfolder path name but in v1.0 it's not working. For example, I have controller in v1 sub directory like /api/controller/v1/DemoController.js . For this blueprint autogenerated api path is /api/v1/demo in Sails v0.12 but its not working in v1. In Sails v1 its working on path /api/demo. Is there any solution of my problem? @mikermcneil Help me please.
brookesb91
@brookesb91
@newari remove the first /
newari
@newari
/api ?
brookesb91
@brookesb91
just to clarify, mine look like…
GET /api/user’ : { action: ‘api/user’ }
@newari any luck?
newari
@newari
No, here '/api' is just prefix. 'GET /v1/demo' : {action : 'v1/demo.find'} and find is autogenerated action
If I define custom action or custom routes, its working fine. But not for blueprint with predefined actions
John Wolfe
@wolfejw86
i have a questions for the autogenerated rest routes as well if anyone has a second. I have two models, user and club. many to many relationship user has memberships: { collection: 'club', via: 'members' } . and club has members: { collection: 'user', via: 'memberships' } . I can get them to work for the development only shortcut routes GET /:modelIdentity/:id/:association/add/:fk , however i don't want to use shortcut routes. i want to use the example PUT /club/:id/members/add/:fk with :id being the club id and :fk being the user id and it keeps giving me not found. i'm sure i'm doing it wrong, but the boat / driver example is a little confusing. can anyone offer advice?
gabrielrondon
@gabrielrondon
Does anyone have some open source code using Sails v1.0 and Mongodb
?
I would like to see some examples
John Wolfe
@wolfejw86
I found the solution to my answer
if anyone else runs into this issue
this page in the docs says you need the /add/ as part of the url
looking closer at the add to reference doc page, https://sailsjs.com/documentation/reference/blueprint-api/add-to
you do not need the add word
so for me, PUT /:modelIdentity/:id/:association/:fk works beautifully
John Wolfe
@wolfejw86
does anyone know of a situation with sails 1.0 where you should use the add word? i am using it in a many to many scenario in mongo, perhaps there's a time when you need it?
Ayan Banerjee
@ayanb1991
I am using Sails@0.12.3 and want to serve my uploaded assets/files from a specified directory. But can not set static middleware.
Most of the solutions from stackoverflow implements a express middleware in config/http.js but in my case it's not working.
Mike McNeil
@mikermcneil
@wolfejw86 I've never worked on an app with versioned models
@KSDaemon redeploying the site now, cleared things up https://trello.com/c/TW3VEMJk
@KSDaemon thanks again for bringing it to my attention
Mike McNeil
@mikermcneil
https://sailsjs.com/documentation/reference/request-req/req-accepted-languages now redirects to https://sailsjs.com/documentation/reference/request-req/req-accepts-languages (and so on). Added note to upgrading guide. I think we're good here, but if anyone runs into any other related stuff from the that we missed from the Express 4 upgrade, please holler at me asap (twitter pm if necessary)! I want to get anything like that taken care of as early in the 1.0 release cycle as possible so we don't get forced to go 2.0 earlier than we'd like