Skip to content

Commit

Permalink
Use consistent string quotation in code and docs
Browse files Browse the repository at this point in the history
- Resolve task in Issue #54
- Use single-quotes everywhere except in interpolated strings
  • Loading branch information
kahmali committed May 13, 2015
1 parent 70d2fad commit 2f83a9b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ if Meteor.isServer
action: ->
post = Posts.findOne @urlParams.id
if post
status: "success", data: post
status: 'success', data: post
else
statusCode: 400
body: status: "fail", message: "Unable to add post"
body: status: 'fail', message: 'Unable to add post'
delete:
roleRequired: 'admin'
action: ->
if Posts.remove @urlParams.id
status: "success", data: message: "Item removed"
status: 'success', data: message: 'Item removed'
else
statusCode: 404
body: status: "fail", message: "Item not found"
body: status: 'fail', message: 'Item not found'
```

###### JavaScript:
Expand Down Expand Up @@ -139,23 +139,23 @@ if(Meteor.isServer) {
action: function () {
var post = Posts.findOne(this.urlParams.id);
if (post) {
return {status: "success", data: post};
return {status: 'success', data: post};
}
return {
statusCode: 400,
body: {status: "fail", message: "Unable to add post"}
body: {status: 'fail', message: 'Unable to add post'}
};
}
},
delete: {
roleRequired: 'admin',
action: function () {
if (Posts.remove(this.urlParams.id)) {
return {status: "success", data: {message: "Item removed"}};
return {status: 'success', data: {message: 'Item removed'}};
}
return {
statusCode: 404,
body: {status: "fail", message: "Item not found"}
body: {status: 'fail', message: 'Item not found'}
};
}
}
Expand Down
44 changes: 22 additions & 22 deletions lib/restivus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -140,48 +140,48 @@ class @Restivus
action: ->
entity = collection.findOne @urlParams.id
if entity
{status: "success", data: entity}
{status: 'success', data: entity}
else
statusCode: 404
body: {status: "fail", message: "Item not found"}
body: {status: 'fail', message: 'Item not found'}
put: (collection) ->
put:
action: ->
entityIsUpdated = collection.update @urlParams.id, @bodyParams
if entityIsUpdated
entity = collection.findOne @urlParams.id
{status: "success", data: entity}
{status: 'success', data: entity}
else
statusCode: 404
body: {status: "fail", message: "Item not found"}
body: {status: 'fail', message: 'Item not found'}
delete: (collection) ->
delete:
action: ->
if collection.remove @urlParams.id
{status: "success", data: message: "Item removed"}
{status: 'success', data: message: 'Item removed'}
else
statusCode: 404
body: {status: "fail", message: "Item not found"}
body: {status: 'fail', message: 'Item not found'}
post: (collection) ->
post:
action: ->
entityId = collection.insert @bodyParams
entity = collection.findOne entityId
if entity
statusCode: 201
body: {status: "success", data: entity}
body: {status: 'success', data: entity}
else
statusCode: 400
body: {status: "fail", message: "No item added"}
body: {status: 'fail', message: 'No item added'}
getAll: (collection) ->
get:
action: ->
entities = collection.find().fetch()
if entities
{status: "success", data: entities}
{status: 'success', data: entities}
else
statusCode: 404
body: {status: "fail", message: "Unable to retrieve items from collection"}
body: {status: 'fail', message: 'Unable to retrieve items from collection'}


###*
Expand All @@ -193,10 +193,10 @@ class @Restivus
action: ->
entity = collection.findOne @urlParams.id, fields: profile: 1
if entity
{status: "success", data: entity}
{status: 'success', data: entity}
else
statusCode: 404
body: {status: "fail", message: "User not found"}
body: {status: 'fail', message: 'User not found'}
put: (collection) ->
put:
action: ->
Expand All @@ -206,15 +206,15 @@ class @Restivus
{status: "success", data: entity}
else
statusCode: 404
body: {status: "fail", message: "User not found"}
body: {status: 'fail', message: 'User not found'}
delete: (collection) ->
delete:
action: ->
if collection.remove @urlParams.id
{status: "success", data: message: "User removed"}
{status: 'success', data: message: 'User removed'}
else
statusCode: 404
body: {status: "fail", message: "User not found"}
body: {status: 'fail', message: 'User not found'}
post: (collection) ->
post:
action: ->
Expand All @@ -223,19 +223,19 @@ class @Restivus
entity = collection.findOne entityId, fields: profile: 1
if entity
statusCode: 201
body: {status: "success", data: entity}
body: {status: 'success', data: entity}
else
statusCode: 400
{status: "fail", message: "No user added"}
{status: 'fail', message: 'No user added'}
getAll: (collection) ->
get:
action: ->
entities = collection.find({}, fields: profile: 1).fetch()
if entities
{status: "success", data: entities}
{status: 'success', data: entities}
else
statusCode: 404
body: {status: "fail", message: "Unable to retrieve users"}
body: {status: 'fail', message: 'Unable to retrieve users'}


###
Expand Down Expand Up @@ -264,7 +264,7 @@ class @Restivus
catch e
return {} =
statusCode: e.error
body: status: "error", message: e.reason
body: status: 'error', message: e.reason

# Get the authenticated user
# TODO: Consider returning the user in Auth.loginWithPassword(), instead of fetching it again here
Expand All @@ -278,7 +278,7 @@ class @Restivus
# Call the login hook with the authenticated user attached
self.config.onLoggedIn.call this

{status: "success", data: auth}
{status: 'success', data: auth}

###
Add a logout endpoint to the API
Expand All @@ -296,6 +296,6 @@ class @Restivus
# Call the logout hook with the logged out user attached
self.config.onLoggedOut.call this

{status: "success", data: message: 'You\'ve been logged out!'}
{status: 'success', data: message: 'You\'ve been logged out!'}

Restivus = new @Restivus
4 changes: 2 additions & 2 deletions lib/route.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ class @Route
endpoint.action.call endpointContext
else
statusCode: 403
body: {status: "error", message: "You do not have permission to do this."}
body: {status: 'error', message: 'You do not have permission to do this.'}
else
statusCode: 401
body: {status: "error", message: "You must be logged in to do this."}
body: {status: 'error', message: 'You must be logged in to do this.'}


###
Expand Down
4 changes: 2 additions & 2 deletions test/api_tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ Meteor.startup ->
Restivus.addRoute 'context/:test',
post: ->
test.equal @urlParams.test, '100'
test.equal @queryParams.test, "query"
test.equal @bodyParams.test, "body"
test.equal @queryParams.test, 'query'
test.equal @bodyParams.test, 'body'
test.isNotNull @request
test.isNotNull @response
test.isTrue _.isFunction @done
Expand Down

0 comments on commit 2f83a9b

Please sign in to comment.