π§ This is work in progress
API server for tiny bookmarking service
- node 14.x
Install dependencies:
npm install
Create empty database:
npm run sync
Start dev server:
KEY="secret-key" npm run dev
Production:
KEY="secret-key" npm start
This doc assume that your server running on https://dev.piny.link. The request examples uses httpie
.
Emoji key:
- π Public endpoint
- π Requires authorisation
Headers:
Content-Type: application/json
β default body typeAuthorization: Bearer XXX
β replaceXXX
withtoken
from/login
response (π restricted endpoints only)
POST /signup
user: string
β user name (unique)pass: string
β user password (no restrictions)email: string
β user email (unique)
http --json POST 'https://dev.piny.link/signup' \
'Content-Type':'application/json' \
user="foo" \
pass="1234" \
email="[email protected]"
{
"message": "π Welcome, please /login"
}
POST /login
user: string
β user namepass: string
β user password
http --json POST 'https://dev.piny.link/login' \
'Content-Type':'application/json' \
pass="1234" \
user="foo"
{
"token": "XXX",
}
GET /logout
http GET 'https://dev.piny.link/logout' \
'Authorization':'Bearer XXX'
{
"message": "π Bye"
}
GET /:user
user: string
β user name
http GET 'https://dev.piny.link/:user' \
'Authorization':'Bearer XXX'
{
"id": "YYY",
"name": "foo",
"email": "[email protected]"
}
GET /:user?/bookmarks
user?: string
β user name (if omitted, get bookmarks of current user)
http GET 'https://dev.piny.link/:user/bookmarks' \
'Authorization':'Bearer XXX'
[
{
"id": "ff7b3bb2-5fad-4924-81a6-5bedc3ded3dd",
"title": "KayWay",
"description": "Illustration portfolio by Ekaterina Grishina",
"state": "active",
"privacy": "public",
"link": {
"id": "a6f7584f-c1a5-42e8-bd98-e1bb003fc219",
"url": "https://kayway.me/"
},
"tags": [
{
"id": "2c00e362-30fc-4dba-89ed-24c0a3d11ab4",
"name": "illustrator"
},
{
"id": "823e8339-2296-4972-aeed-951df1826228",
"name": "portfolio"
}
],
"createdAt": "2020-08-02T00:34:45.000Z",
"updatedAt": "2020-08-02T00:34:45.000Z"
},
...
]
GET /:user/tags
user: string
β user name
http GET 'https://dev.piny.link/:user/tags' \
'Authorization':'Bearer XXX'
[
{
"id": "2c00e362-30fc-4dba-89ed-24c0a3d11ab4",
"name": "illustrator"
},
{
"id": "823e8339-2296-4972-aeed-951df1826228",
"name": "portfolio"
}
]
POST /bookmarks
url: string
β bookmark urltitle?: string
β bookmark title (optional)description?: string
β bookmark description (optional)privacy: 'public'
β access to bookmark (only'public'
supported at the moment)tags?: string[]
β list of tags that should be assigned to the bookmark, will be added to the user tags (optional)
http --json POST 'https://dev.piny.link/bookmarks' \
'Authorization':'Bearer XXX' \
'Content-Type':'application/json' \
title="KayWay" \
description="Illustration portfolio by Ekaterina Grishina" \
url="https://kayway.me" \
privacy="public" \
tags:="[
\"illustrator\",
\"portfolio\"
]"
{
"message": "β¨ Created"
}
PATCH /bookmarks/:id
id: string
β bookmark id
url?: string
β bookmark url (optional)title?: string
β bookmark title (optional)description?: string
β bookmark description (optional)privacy?: 'public'
β access to bookmark (only'public'
supported at the moment) (optional)tags?: string[]
β list of tags that should be assigned to the bookmark, will be added to the user tags (optional)
http --json PATCH 'https://dev.piny.link/bookmarks/:id' \
'Authorization':'Bearer XXX' \
'Content-Type':'application/json' \
title="KayWay" \
description="Illustration portfolio by Ekaterina Grishina" \
tags:="[
\"illustrator\",
\"portfolio\"
]"
{
"message": "πΎ Saved"
}
DELETE /bookmarks/:id
id: string
β bookmark id
http DELETE 'https://dev.piny.link/bookmarks/:id' \
'Authorization':'Bearer XXX'
{
"message": "π Removed"
}
Β© Ivan Grishin