Giter Site home page Giter Site logo

ghaiklor / generator-sails-rest-api Goto Github PK

View Code? Open in Web Editor NEW
334.0 334.0 54.0 2.61 MB

Yeoman generator for scaffolding Sails REST API with predefined features

Home Page: http://ghaiklor.github.io/generator-sails-rest-api/

License: MIT License

JavaScript 96.45% CSS 3.35% HTML 0.19% Dockerfile 0.01%
javascript nodejs rest-api sails scaffold scaffolding yeoman yeoman-generator

generator-sails-rest-api's Introduction

SWUbanner

generator-sails-rest-api's People

Contributors

braunreuthera avatar canabina avatar ghaiklor avatar gitter-badger avatar greenkeeper[bot] avatar greenkeeperio-bot avatar incocode avatar mikedevita avatar sercanov avatar snyk-bot avatar sylwit avatar troggy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator-sails-rest-api's Issues

Implement aliases for common queries

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.

Creating a user via signup throws a not null constraint error with postgresql

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

Error: Cannot find module 'passport-twitter-token'

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.

Twilio module

After generating the project twilio module not installed.

Failure after initial install of npm packages

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

Improve responses with underscore attributes

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.

Generate package.json based on answers

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.

Do we need overriding HTTP method?

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.

Override default blueprints

Need to override default blueprints, so each REST route can return more detailed description in header like X-Total or X-Range, etc...

Error: In model (user), invalid connection :: disk

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.

Feel free to choose which services you want include

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

Facebook userId is not found

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)

Posting to auth/facebook returns E_NOT_FOUND error (404)

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??

password lifecycle beforeUpdate

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();

User signup

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.

Implement pluralized form only for REST models

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.

Implement search on top of find blueprint

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.

Move from experimental to unstable stability level

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

No route to match the PATCH action verb

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": {}
}

Patching

@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?

Implement returning total count and range in headers

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.

passport service 'localStrategy'

else if (CipherService.create('bcrypt', {content: user.password}).compareHashSync(password))

NEED:

else if (!CipherService.create('bcrypt', {content: user.password}).compareHashSync(password))

Implement all tests

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.

Running node app.js fails with error: missing sails-disk adaptor

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

Move steps to CommonJS modules

For example we have initializing section. We can move it to CommonJS module, so index.js will be more easy to read and maintain.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.