Skip to content

Instantly share code, notes, and snippets.

@lukrizal
Created September 2, 2015 05:24
Show Gist options
  • Save lukrizal/3921c198495ae51320c4 to your computer and use it in GitHub Desktop.
Save lukrizal/3921c198495ae51320c4 to your computer and use it in GitHub Desktop.
some things that programmer usually trying to solve
> just use the "resource" concept.
> make use of hashed_id rather than exposing the real id.
> throw exceptions rather than doing manual error returns.
> always use general usage, "result", "code", "data" as first level indeces of the response.
> always use general query words for distinguishing special actions or request.
> "action" to state what action to be done other than the main action verbs(update(PUT), destroy(DELETE), create(POST), show(GET), list(GET).
> always use jsonp
> be general(in layman's term) in describing messages. if specific description is needed better represent it with a error/message code that linked on a exclusive page only accessible by authorized person that needs it.
> use events/queuing rather than executing directly the process on each request.
> use websockets as much as possible for polling.
> authentication must be coded accordingly to its level of purposes. straight forward authentication for less-secure end points.
> use nouns in describing an end point. example, api/ver1/dog - it means API for a Dog resource.
> don't use GET method if the request will result for a change in data. for special cases, use only POST.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment