Ayano is API platform for sharing links.
- User
- Admin
Features that we handing
- Authentication
- Submit link
- Update link
- Show link
- Delete link
- Listing Links
- Profile User
bundle install
bin/rails db:migrate
bin/rake db:seed
bin/rails server
username: pquest
password: kelapa
username: user#{1-50}
password: kelapa
We using JWT JSON token for authentication.
POST
/api/auth
{
"jwt": "your_token_here"
}
Then, using token for your request in headers following ref
Authorization: Bearer <token>
This feature for adding your link to database.
POST
/api/blogs
If your link is saved or success api will response your blog object.
{
"blog": {
"title": "Beberapa tips menulis CSS yang baik",
"url": "your.link.blog.moe/1.html"
}
}
if your link is not saved or having something expected errors.
{
"error": {
"code": 401,
"message": "You haven't authentication, please login before you request this"
}
}
Updating your link. Just user actor can use this feature, admin actor can't.
PUT or PATCH
/api/blogs/:id
If your blog has successfully updated, it will be response the updated blog object.
{
"blog": {
"title": "Pengantar CSS",
"url": "your.link.blog.moe/2.html"
}
}
If your request has expected error, it will response error message.
{
"error":{
"code": 404,
"message": "Your link not found, maybe it's been deleted"
}
}
I love API with simple response.
GET
/api/blog/:id
If response is success.
{
"blog": {
"title": "Pengantar CSS",
"url": "your.link.blog.moe/2.html"
}
}
If request has expected error.
{
"error":{
"code": 404,
"message": "Link not found"
}
}
GET
/api/blog/:id/user
If response is success.
{
"user":{
"username": "pquest"
}
}
Pretty cute, right?
User actor and admin actor can use this feature.
DELETE
/api/blog/:id
If your link was deleted, it will be return deleted object.
{
"blog": {
"title": "Pengantar CSS",
"url": "your.link.blog.moe/2.html"
}
}
If your link wasn't deleted, it will be return error message.
{
"error":{
"code": 403,
"message": "Sorry, you haven't permission to do this."
}
}
GET
/api/blogs?page=1
It will be return with pagination with ten items per page.
{
"blogs":[
{
"blog": {
"title": "Pengantar CSS",
"url": "your.link.blog.moe/2.html"
}
},
]
}
GET
/api/user/:id
Returning their information
{
"user":{
"username": "pquest"
}
}
GET
/api/user/:id/blogs
Returning their blogs
{
"blogs": [
{
"blog":{
"title": "Pengantar CSS",
"url": "your.link.blog.moe/2.html"
}
},
]
}
Ayano project use MIT license.
You will be free to download, reviews and also use the code for anyhing purposes.