mdconaway / sails-ember-rest Goto Github PK
View Code? Open in Web Editor NEWEmber Data REST-Adapter compatible controllers, policies, services and generators for Sails v1.0.x+
License: MIT License
Ember Data REST-Adapter compatible controllers, policies, services and generators for Sails v1.0.x+
License: MIT License
templates/actions/create.js
Model.create(data).exec((err, newInstance) => {
// Differentiate between waterline-originated validation errors
// and serious underlying issues. Respond with badRequest if a
// validation error is encountered, w/ validation info.
if (err) return res.serverError(err, actionUtil.parseLocals(req));
It seems the comment discusses handling this but it is not handled.
Hey friend, thanks for the fantastic work here. I just used this in a project and am extremely happy with it. Ember is awesome, Sails is awesome, and you're awesome.
I came across a sad today, and I'm not sure the issue belongs in your repo, so feel free to redirect me to knock on someone else's door. But either way, I thought you might want to know that it seems like Waterline (Sails 1.0.0-41) is now ignoring the following:
validations: {
ignoreProperties: ['includeIn']
}
...in sails.config.models. This makes configuring the presentation options impossible on a per-model basis with the latest version of sails-ember-rest.
error: The attribute `guests` on the `event` model contains invalid properties. The property `includeIn` isn't a recognized property.
error: Could not load Sails app.
I've been sleuthing around in Waterline trying to find something, anything, about specifying one's own reserved properties, but to no avail. I can't even find a doc about this breaking change. They appear to be defined here: https://github.com/balderdashy/waterline-schema/blob/master/accessible/valid-attribute-properties.js and enforced here: https://github.com/balderdashy/waterline-schema/blob/master/lib/waterline-schema/schema.js#L237
Anyway, thanks so much for this awesome repo. Let me know if there's any way I can help with this.
This is a reminder issue to cleanup:
Thanks for this library!
When I wanted to use the recommended actions2
I've get an error: The action find in someController/find.js conflicts with a previously-loaded action.
Can I somehow work this around?
Thank you
Hi,
First of all I want to thank you. You did a really good job in it.
But when I saw the Ember's DS.RESTAdapter documentation (https://www.emberjs.com/api/ember-data/release/classes/DS.RESTAdapter), in the JSON structure section, I figure out that the response of the findOne action is returning an array instead an object. e.g.
/posts/1 is returning:
{ "posts": [{ "title": "My post", "body": "My post content" }] }
instead of:
{ "posts": { "title": "My post", "body": "My post content" } }
When i did run the code sails generate ember-rest policies
on Sails.js,
It did returns me
error: A hook (policies) failed to load!
error: Failed to lift app: { Error: Attempted to require(D:\projetos\monitor-api\api\policies\emberSetHeader.js) , but an error occurred:
TypeError: SailsEmber.policies.emberSetHeader is not a constructor
at Object.<anonymous> (D:\projetos\monitor-api\api\policies\emberSetHeader.js:2:18)
The solution that i found was modify the archive ./templates/policies/emberSetHeader
adding the contructor :
const EmberController = require('./../controllers/EmberController');
module.exports = function(controller) {
controller = controller ? controller : new EmberController();
return function(req, res, next) {
if (!req.headers.ember) {
req.headers.ember = true;
}
next();
};
};
Change:
"const SailsEmber = require('sails-ember-rest');\nmodule.exports = SailsEmber.controller;\n"
To:
"const SailsEmber = require('sails-ember-rest');\nlet controller = new SailsEmber.controller({\n});\nmodule.exports = controller;"
Better for adding interrupts :)
I have installed this module, and its been working fine until I got to the model that had a multi-word name. For these multi-word names:
I'm able to delete, and able to create a record, but with no attributes or relationships
I'm unable to POST with attributes or PATCH/PUT any attributes
Are multiple word names supported / can they easily be? Thanks
Hi - and many thanks for this code. I'm loving Sails and Ember but I'm not experienced enough to think through and implement on my own all that you've done here.
I was trying something out for a new app, and this came up.
Ember:
console.log('Attempting to connect...'); let sailsSocket = io.sails; sailsSocket.useCORSRouteToGetCookie = false let connection = sailsSocket.connect('http://localhost:1337'); connection.get('/registrations', [], function (resData, jwres){ console.log(resData); });
But this was crashing Sails with a message:
Sails in terminal
TypeError: _.pluck is not a function at actionUtil.populateIndexes (/Users/leonidas/Sites/nautilus/nautilus-sails/node_modules/sails-ember-rest/templates/actions/find.js:50:48)
P.S.
I did a little searching, and found this:
So I went ahead and did the same in sails-ember-rest/templates/actions/find.js:50:48, i.e. changed
if (req._sails.hooks.pubsub && req.isSocket) { Model.subscribe(req, _.pluck(matchingRecords, Model.primaryKey)); ...
to
if (req._sails.hooks.pubsub && req.isSocket) { Model.subscribe(req, _.map(matchingRecords, Model.primaryKey)); ...
which seems to have solved the problem. Thought this might be useful.
I think this is caused because _kebabCase is not the same as camelCase. Still investigating.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.