This is a web application for keeping track of your notes
BE AWARE! This application is very insecure (hardcoded secret for jwt and no authentication for MongoDB (and I think we all know why that's bad)), so don't use it in production.
If it's not ready for prod, then why'd you make it? To keep myself busy during some extraordinary boring school days.
docker-compose up
Well, I'm lazy, so here's how I use this with curl:
If there is an error, you will get back a non-200 response code, and a JSON object like this:
{
"error" : "..."
}
curl -X POST localhost:3000/auth/sign_up -d username=bob -d password=irock
{
"token" : "rock.paper.stick"
}
curl -X POST localhost:3000/auth/sign_in -d username=bob -d password=irock
{
"token" : "rock.paper.stick"
}
returns all notes belonging to you
curl -X GET localhost:3000/note -H "Bearer: $token"
[
{
"_index" : "notes",
"_type" : "note",
"_id" : "AVqpz0I394F1ANZzyHP6",
"_score" : 0.2876821,
"_source" : {
"title" : "Testing",
"body" : "Testing",
"username" : "bob"
}
}
]
create a new note
curl -X POST localhost:3000/note -H "Bearer: $token" -d title='...' -d body='...'
{
"ok" : "New post created"
}
update a note, requires you to send in both title and body
curl -X PUT "localhost:3000/note/$id" -H "Bearer: $token" -d title='...' -d body='...'
{
"ok" : "Note was edited"
}
delete a note
curl -X DELETE "localhost:3000/note/$id" -H "Bearer $token"
{
"ok" : "Note was deleted"
}
get a note
curl -X GET "localhost:3000/note/$id" -H "Bearer: $token"
[
{
"_id" : "AVqpz0I394F1ANZzyHP6",
"_score" : 1,
"_index" : "notes",
"_type" : "note",
"_source" : {
"title" : "Testing",
"username" : "bob",
"body" : "Testing"
}
}
]
get all notes containing the query in either title or body
curl -X GET "localhost:3000/note/search?query=$query" -H "Bearer: $token"
[
{
"_source" : {
"body" : "Testing",
"title" : "Testing",
"username" : "bob"
},
"_index" : "notes",
"_id" : "AVqpz0I394F1ANZzyHP6",
"_type" : "note",
"_score" : 0.8630463
}
]