Created
January 10, 2015 22:25
-
-
Save shlomiassaf/0e110530883f14910082 to your computer and use it in GitHub Desktop.
resty-stone creating a new Post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The body of the POST call to http://localhost:3000/api/posts */ | |
{ | |
"title": "This is a new post!", | |
"publishedDate": "2015-01-01T22:00:00.000Z", | |
"content": { | |
"brief": "Lets write a simple brief", | |
"extended": "<p>Maybe some extended info with html tags</p>" | |
} | |
} | |
/* The result: */ | |
{ | |
"success": true, | |
"resultType": "resourceLink", | |
"modelType": "notSet", | |
"result": { | |
"id": "this-is-a-new-post", | |
"url": "http://localhost:3000/api/posts/this-is-a-new-post" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
REST Metadata for Post, in this case ANYONE can post, even guests. | |
*/ | |
var keystone = require('keystone'), | |
Post = keystone.list('Post') | |
module.exports.default = { | |
/* | |
A comma delimited list of allowed http methods for this list. | |
Defaults to empty list. | |
*/ | |
"httpMethods": "get post", | |
/* | |
A comma delimited list of allowed http methods for this list that acts on a group. | |
A group is an action taken on a list of List (e.g: not accessing a direct instance via defaultKey) | |
Set true to inherit from httpMethods. | |
WARNING: It is recommended to set this value explicitly (e.g: don`t set true) to prevent catastrophic results. | |
For protection, setting httpGroupMethods: TRUE will not drill down to inheriting profiles, the inherited value will be the | |
actual httpMethods value of the parent profile and not a reflection of httpMethods of the child profile. | |
Defaults to empty list. | |
*/ | |
"httpGroupMethods": "get", | |
/* | |
defaultKey: The column used to search a single list instance with. (e.g: hello-world in www.site.com/api/post/hello-world) | |
If not set defaults to the value of list.autokey.path, if list does`nt contain an autokey then _id is taken. | |
To disable single item access, set to false. | |
*/ | |
"defaultKey": "slug", | |
/* | |
A filter that acts as a safe-guard to all user queries, except direct id queries (using defaultKey). | |
This filter is added to each query. If keys in permanentFilter exist in a query, permanentFilter will override them. | |
Example: To return only 'published' posts for GET requests set: 'state:published' | |
The filter is declared using KeystoneJS 'queryfilter' library/ see: https://github.com/keystonejs/queryfilter | |
Defaults to undefined | |
*/ | |
"permanentFilter": "state:published", | |
"columns": { | |
"visible": [ | |
"title", | |
"publishedDate", | |
"slug", | |
"author", | |
"content:postContent", // see customTypeHandlers.postContent | |
"categories", | |
"tags" | |
], | |
"no_filter": [ | |
"state", | |
"slug", | |
"_id" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment