simplex/views/docs/v1.moon

121 lines
3.1 KiB
Plaintext
Raw Normal View History

2018-04-25 05:02:41 +00:00
import Widget from require "lapis.html"
class Docs_1 extends Widget
content: =>
task_list = ->
ul ->
li ->
a href: "#new", "/new"
text " { content: string }"
li ->
a href: "#get", "/get"
text " { id: integer, content: string }"
li ->
a href: "#do", "/do"
text " { id: integer, content: string }"
li ->
a href: "#undo", "/undo"
text " { id: integer, content: string }"
li ->
a href: "#delete", "/delete"
text " { id: integer, content: string }"
li ->
a href: "#list", "/list"
text " { count: integer, done: boolean, page: integer, order: 'asc'/'desc' }"
li ->
a href: "#random", "/random"
text " { count: integer, done: boolean }"
style -> raw "h3 { font-family: monospace; }"
ol style: "font-family: monospace;", ->
li ->
a href: "#auth", "Authorization"
li ->
a href: "#tasks", "Tasks"
task_list!
li ->
a href: "#keys", "API Keys"
ul ->
li ->
a href: "#new-key", "/key/new"
li ->
a href: "#delete-key", "/key/delete"
text " { id: integer, key: string }"
a name: "auth"
h2 "Authorization"
p "Authorization is done using a session cookie on the web interface, or an API key sent along with API requests."
p ->
text "API keys can be sent in an Authorization header or as an "
code "api_key"
text " field in JSON."
blockquote ->
code "Authorization: JDJiJDEyJFRPaG0wOW16VXhoUTd3dElB"
blockquote ->
code '{ "api_key": "JDJiJDEyJFRPaG0wOW16VXhoUTd3dElB" }'
p ->
text "Grab an API key from "
a href: @url_for("index"), "the web interface"
text " to get started. You can also delete existing API keys there."
a name: "tasks"
h2 "Tasks"
p ->
text "Version 1 of this API is extremely simple. POST "
code '{ "content": "this is a todo item" }'
text " with valid authorization to "
code "/new"
text " to add tasks. The next four endpoints ("
code "/get"
text ","
code "/do"
text ","
code "/undo"
text ","
code "/delete"
text ") all use the same input to complete their operations (an "
code "id"
text " integer or "
code "content"
text " boolean)."
p ->
code "/list"
text " and "
code "/random"
text " are a little more complex, and explained further below."
task_list!
a name: "new"
h3 "/new"
a name: "get"
a name: "do"
a name: "undo"
a name: "delete"
a name: "list"
a name: "random"
a name: "keys"
h2 "API Keys"
a name: "new-key"
a name: "delete-key"
-- /list { count: #, done: bool, page: #, order: asc/desc } (if done not specified, returns all,
-- default count is 50, default page is 1, default order is latest first
-- /random { count: #, done: bool } (both args optional, defaults count 1, done false)