ghaiklor / generator-sails-rest-api Goto Github PK
View Code? Open in Web Editor NEWYeoman generator for scaffolding Sails REST API with predefined features
Home Page: http://ghaiklor.github.io/generator-sails-rest-api/
License: MIT License
Yeoman generator for scaffolding Sails REST API with predefined features
Home Page: http://ghaiklor.github.io/generator-sails-rest-api/
License: MIT License
I want to include customMiddleware
feature into sails.config.http
. Might be done today.
Which of those variants will be more accessible: snake_case
or camelCase
?
To make the API experience more pleasant for the average consumer, consider packaging up sets of conditions into easily accessible RESTful paths. For example, the recently closed tickets query above could be packaged up as GET /tickets/recently_closed
.
The signup
method defined in the AuthController creates the user with this function: User.create(req.allParams())
.
console.log(req.allParams())
reveals that the id is undefined.
Postgresql throws up the following error as a result:
Error (E_UNKNOWN) :: Encountered an unexpected error
error: null value in column "id" violates not-null constraint
Hi. I like what you have done here.
After npm install;sails lift I got the above error. The generated package.json seemed to be missing passport-twitter-token package.
I executed a npm install passport-twitter-token and all good.
Keep up the good work.
Cheers.
After generating the project twilio module not installed.
Can you provide an example client side call exhibiting general usage pattern?
When I attempt to generate a new project...I'm taken through the steps to create the project/DB etc... All of the files get created, some packages get installed...then error is thrown. Any ideas?
I tried with both Postgres and Mongo. I'm using 0.9
C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\index.js:101
Object.keys(deps).forEach(function (dep) {
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\index.js:101:14
at Array.forEach (native)
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\index.js:100:13
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\node_modules\async\lib\async.js:254:17
at done (C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\node_modules\async\lib\async.js:135:19)
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\node_modules\async\lib\async.js:32:16
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\node_modules\async\lib\async.js:251:21
at getDeps (C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\index.js:110:14)
at C:\Users\eric_swann\AppData\Roaming\npm\node_modules\generator-sails-rest-api\node_modules\dependency-check\index.js:95:5
When we are working with models declarations, we must follow JavaScript style guides. So any attribute will be named in camelCase. But when we send response, we must send in under_score style.
So my proposal it's replace camelCase attributes with under_score in responses.
Make npm script that cleaning up tmp folder
Right now I have issue with unused dependencies in package.json
. Need to find out the way to generate package.json
only with dependencies that we really need.
Some HTTP clients can only work with simple GET and POST requests. To increase accessibility to these limited clients, the API needs a way to override the HTTP method. Although there aren't any hard standards here, the popular convention is to accept a request header X-HTTP-Method-Override
with a string value containing one of PUT, PATCH or DELETE.
Need to override default blueprints, so each REST route can return more detailed description in header like X-Total
or X-Range
, etc...
Getting this error on lift:
Thu, 30 Apr 2015 06:07:37 GMT: verbose: sockets hook loaded successfully.
error: In model (user), invalid connection :: disk
error: Must contain an `adapter` key referencing the adapter to use.
This is caused by the fact that /config/etc/development.js
sets the default connection to "disk", but that connection is not defined anywhere.
Let me know how you want that fixed and I can send in a PR.
Sails just released new version of Sails and I want to upgrade it.
I want to create questions list where developer can check which services he wants to use in application.
And when developer has answered on questions, we are running sub-generators which copies files that he's need.
Sub-generators task - #13
api/services/social/Facebook.js:10
if (!(options || options.userId || options.accessToken)) {
^
TypeError: Cannot read property 'userId' of undefined
at new Facebook (api/services/social/Facebook.js:10:29)
at Object.<anonymous> (api/services/SocialService.js:3:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at node_modules/sails/node_modules/include-all/index.js:129:29
at Array.forEach (native)
I am making a $http request to v1/auth/facebook route
Have defined the baseUrl, appToken as variables in the same file (not in the code over here). Successfully implemented signup and signin using similiar methods. My understanding from reading the wiki is that I need to pass the access_token obtained from facebook as params, and so the code below.
var fbReq = function(aToken) {
return {
url: baseUrl + '/facebook',
headers: {
'application-token': appToken
},
method: 'POST',
params: {'access_token': aToken},
};
},
Then calling the req through a service method
service.authFb = function(bToken) {
console.log(fbReq(bToken));
$http(fbReq(bToken))
.then(function(response) {
q.resolve(response);
}, function(error){
console.log(error);
q.reject("There was a problem logging into api server");
});
return q.promise;
};
return service;
Or do I need to pass in the auth_token as a header??
beforeUpdate User model need to check new pass then only to hash pass again;
like this :
beforeUpdate: function(values, next) {
if (typeof values.newPassword != 'undefined' && values.newPassword !== '')
becouse we have problem with forgot pass:
user.password = CipherService.create('bcrypt', {content: newPassword}).hashSync();
Hi,
I had a test that ran "Ok" against 0.4.0 tag to /signup a user.
In this it passed a username and password in the body.
Post the 0.5.1 code drop this test is fails.
When I check the user DB after the signup "Created" the username and password are not present as fields so when I try to later /signin this fails with "Missing credentials".
Is this a feature (and if so how to I now signin) or perhaps a bug?
Cheers.
Right now when you enable pluralize
in config/blueprints.js
it will assign pluralized form to controllers like AuthController
. That's no good, so need to fix it, maybe with overriding config in controller.
When you make request to some collection, you should also can send q
parameter where set which text you should find in records. For example, GET /tickets?q=search_text&state=open
.
I should check all the code located under generator and template and check if everything is ok.
If yes, then I can move to Unstable stability level and continue working only with services
.
[x] api
folder
[x] config
folder
[x] doc
folder
[x] test
folder
JwtService not found in services
PUT /model/:id results in
{
"code": "OK",
"message": "Operation is successfully executed",
"data": {
...
}
}
PATCH /model/:id results in
{
"code": "E_NOT_FOUND",
"message": "The requested resource could not be found but may be available again in the future",
"data": {}
}
Need to think, where we can place questions list, so it will be easy maintainable.
@ghaiklor I was looking over the code and thinking about patching. What if we did something like, for example, taking the services and breaking them into discrete, published modules like sails-service-cipher
, sails-service-mailer
, and so on.
CipherService.js
would then become, simply:
module.exports = require('sails-service-cipher');
That would make it trivial to add new ciphers, mailers, payment gateways, etc and so on in the future without the generator code being affected. It would also make isolating tests much easier.
If you like that idea, we might be able to talk to Sails about auto-registering services like they do for hooks, or, we could create a custom user hook to do just that anyway.
What do you think?
Great feature if API can send X-Total-Count
in headers to represent how many records in database exists. Also send X-Range
to display pointers in current response. For instance, X-Total-Count: 20
and X-Range: 5-10
.
Could benefit to see an example of adding a single view.
else if (CipherService.create('bcrypt', {content: user.password}).compareHashSync(password))
NEED:
else if (!CipherService.create('bcrypt', {content: user.password}).compareHashSync(password))
socialFactory module not found
We can make logs more readable with json: false
in DailyRotate transport
I think that the best practice will be move error codes like E_BAD_REQUEST
or E_USER_EXISTS
to some config file or any global object.
I add boilerplate for tests here #11 and now need just fill them with test cases. Big task, so need make it in another branch and then merge it.
Extend custom responses with more HTTP codes and make more flexible system for extending default root object.
Unable to run the server. Installing the sails-disk package with npm still leads to the following error stack
error: Trying to use unknown adapter, "sails-disk", in model `user`.
error: Are you sure that adapter is installed in this Sails app?
error: If you wrote a custom adapter with identity="sails-disk", it should be in this app's adapters directory.
error: Otherwise, if you're trying to use an adapter named `sails-disk`, please run `npm install [email protected]`
node 0.12.1
For example we have initializing
section. We can move it to CommonJS module, so index.js
will be more easy to read and maintain.
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.