Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate @Model and @Routable for default API #6

Closed
15 tasks done
etsuo opened this issue Nov 29, 2016 · 1 comment
Closed
15 tasks done

Integrate @Model and @Routable for default API #6

etsuo opened this issue Nov 29, 2016 · 1 comment

Comments

@etsuo
Copy link
Member

etsuo commented Nov 29, 2016

@Routable({
    baseUrl: 'use',
    model: User,
    suppressApi: ['delete']
})
class UserApi {
    @Route({
        method: 'get',
        model: UserVote
    })
    getSomethingElse() {
    }
}

The idea here is that @Routable will take a optional model property which can be any Class that's decorated with @Model. If a model is provided, by default, the @Routable class will support:

  • GET model
  • GET model/{id}
  • PUT model (with the change set being in the body and the change set requiring an id property)
  • PUT model
  • DELETE model

Since the @Routable optional suppressApi property has the string delete provided in its array, a route for DELETE model/ will not be created.

Alternatively, exposeApi also takes an array of strings, but it defaults to all APIs being suppressed except those explicitly exposed.

APIs include:

  • - get [GET /{:id}], returns an object
  • - get [GET /{:id}?filter={}], returns an object
  • - getAll [GET], return array of objects
    • basic functionality
    • ?where={}
    • ?fields={} // exclude / include certain fields
      • - fromDb strict mode support for projection
      • - toJson support for projection
    • ?skip=# // skip x results
    • ?limit=# // limit to x results
    • prevent NoSQL injection (moved to Create tests for noSql injection resistance #65)
  • - put [PUT /{:id}], takes a change set with id and updates a document
  • - post [POST], takes an object and creates the document
  • - delete [DELETE /{:id}, deletes a document
  • - mapJsonToDb static function on model
@etsuo
Copy link
Member Author

etsuo commented Dec 1, 2016

See also #13

@etsuo etsuo mentioned this issue Dec 10, 2016
15 tasks
@etsuo etsuo modified the milestone: 0.4.0 Dec 22, 2016
etsuo added a commit that referenced this issue Feb 18, 2017
@etsuo etsuo modified the milestones: 0.5.0, 0.4.0 Apr 1, 2017
@etsuo etsuo changed the title Automatic default CRUD api for @Routable class? Integrate @Model and @Routable for default API Apr 20, 2017
@etsuo etsuo self-assigned this Apr 20, 2017
etsuo added a commit that referenced this issue Apr 22, 2017
@etsuo etsuo removed the proposal label Apr 29, 2017
etsuo added a commit that referenced this issue May 2, 2017
etsuo added a commit that referenced this issue May 3, 2017
… also fixed issue with falsy properties not working right in some circumstances
This was referenced May 3, 2017
etsuo added a commit that referenced this issue May 6, 2017
…et converted from their json fields to db fields, which is handed off to MongoDB in the proper “dot” notation for accessing embedded documents. This renders #61 unnecessary.
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 6, 2017
etsuo added a commit that referenced this issue May 7, 2017
@etsuo etsuo closed this as completed May 7, 2017
etsuo added a commit that referenced this issue May 7, 2017
etsuo added a commit that referenced this issue Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant