For all request, the following is required in the header:
APITOKEN: "VERY SECRET KEY"
Endpoints | Method | Access | Description |
---|---|---|---|
/api/crypto/getPublicKey | GET | ALL | Gets public key to encrypt password |
/api/crypto/encrypt | POST | DEV | RSA encrypts a plaintext using public key |
/api/crypto/decrypt | POST | DEV | RSA decrypts a ciphertext using private key |
/api/crypto/hashPassword | POST | DEV | Hashes a password with salt |
/api/crypto/checkPassword | POST | DEV | Checks if a hashed password matches the hash |
/api/user/register | POST | ALL | Registers a new user |
/api/user/# | POST | ALL | Logs in a user |
/api/user/logout | POST | ALL | Logout a user |
/api/todo/getAll | GET | AUTH | Retrieves all todos |
/api/todo/getUndone | GET | Auth | Retrieves all undone todos |
/api/todo/getDone | GET | Auth | Retrieves all done todos |
/api/todo/createNew | POST | Auth | Creates a new todo |
/api/todo/get | GET | Auth | Retrives todo with the specified id |
/api/todo/delete | DELETE | Auth | Delete todo with the specified id |
/api/todo/markDone | PATCH | Auth | Mark todo with the specified id as done |
/api/todo/markUndone | PATCH | Auth | Mark todo with the specified id as undone |
/api/todo/update | PATCH | Auth | Updates description of todo with the specified id |
Gets public key to encrypt password
None
{
"publicKey": "Key is here"
}
None
RSA encrypts a plaintext using public key
{
"text": "Plaintext"
}
{
"ciphertext": "Ciphertext"
}
E0010: Request body format is wrong
RSA decrypts a ciphertext using private key
{
"text": "Ciphertext"
}
{
"plainText": "Plaintext"
}
E0010: Request body format is wrong
Hashes a password with salt
{
"password": "password"
}
{
"passwordHash": "passwordHash"
}
E0010: Request body format is wrong
Checks if a hashed password matches the hash
{ "password": "password", "passwordHash": "passwordHash" }
### Reponse:
```json
{
message: "Success"
}
E0010: Request body format is wrong E0300: Invalid password
Registers a new user
{
"name": "name",
"email": "email",
"password": "encrypted password"
}
{
"user": {
"name": "name",
"email": "email"
}
}
E0010: Request body format is wrong E0302: Email already exists
Logs in a user
{
"email": "email",
"password": "encrypted password"
}
{
"user": {
"name": "name",
"email": "email"
}
}
E0010: Request body format is wrong E0300: Invalid credentials
Logout a user
None
{
"message": "Goodbye"
}
Retrieves all todos
None
{
"data": [
{
"id": 7,
"task": "hello",
"done": false,
"create_at": "2022-06-12T08:38:28.810Z",
"updated_at": "2022-06-12T08:38:28.810Z"
}
]
}
None
Retrieves all undone todos
None
{
"data": [
{
"id": 7,
"task": "hello",
"done": false,
"create_at": "2022-06-12T08:38:28.810Z",
"updated_at": "2022-06-12T08:38:28.810Z"
}
]
}
None
Retrieves all done todos
None
{
"data": [
{
"id": 7,
"task": "hello",
"done": true,
"create_at": "2022-06-12T08:38:28.810Z",
"updated_at": "2022-06-12T08:38:28.810Z"
}
]
}
None
Creates a new todo
{
"task": "Your task goes here"
}
{ "data": { "task": "Your task goes here again", "id": 14, "done": false, "create_at": "2022-06-12T10:37:03.008Z", "updated_at": "2022-06-12T10:37:03.008Z" } }
E0010: Request body format is wrong
Retrives todo with the specified id
{
"id": "Task id goes here"
}
{ "data": { "id": 4, "task": "Updated task", "done": true, "create_at": "2022-06-12T08:08:37.361Z", "updated_at": "2022-06-12T08:08:37.361Z" } }
E0010: Request body format is wrong
Delete todo with the specified id
{
"id": "Task id goes here"
}
{
"message": "Deleted"
}
E0010: Request body format is wrong
Mark todo with the specified id as done
{
"id": "Task id goes here"
}
{
"data": {
"id": 4,
"task": "Your task goes here again too",
"done": true,
"create_at": "2022-06-12T08:08:37.361Z",
"updated_at": "2022-06-12T08:08:37.361Z"
}
}
E0010: Request body format is wrong
Mark todo with the specified id as undone
{
"id": "Task id goes here"
}
{
"data": {
"id": 4,
"task": "Your task goes here again too",
"done": false,
"create_at": "2022-06-12T08:08:37.361Z",
"updated_at": "2022-06-12T08:08:37.361Z"
}
}
E0010: Request body format is wrong
Updates description of todo with the specified id
{
"id": "Task id goes here",
"task": "Updated task goes here"
}
{
"data": {
"id": 4,
"task": "Your task goes here again too",
"done": false,
"create_at": "2022-06-12T08:08:37.361Z",
"updated_at": "2022-06-12T08:08:37.361Z"
}
}
E0010: Request body format is wrong