Closed YoungerMax closed 11 months ago
In v2, make note saving incremental
We should use a shorter hash instead of a full-length UUID 4. We could truncate the length of the UUID 4 to about 6-8 characters.
The possibility of hash collision can be avoided by implementing a fail-safe that checks if the newly truncated id matches an id that already exists, and then just re-generate it.
Objects
Date
All dates are UTC ISO 8601 dates
Example:
2023-06-19T01:17:05.565Z
IDs
All IDs are UUID 4
Example:
90da6511-685e-4538-a2cf-19c112616c8f
User
Example:
history
explanationstudentTypeSurveyResponse
would store what they responded withNote
metadata.path
is the parent folder path to the note. It is an array so that any characters can go in the folder names. This solves the problem of not being able to put/
in folder or file names and may fix potential bugs.3. Computers / 3.5 folder inside a folder / 3.5.2 Example name
where3.5.2 Example name
is the file, and3. Computers
and3.5 folder inside a folder
are parent foldersFolder
Authentication
authenticate
which contains a secure random string (token)authenticate
against a database to get userEndpoints
GET /
Authentication accepted, but not required No request body accepted at all. Return
400 Bad Request
if a body is given.Description
Get server status, server information, user information
Return
If not authenticated:
200 OK
, body:If authenticated:
200 OK
, body:If server error:
500 Internal Server Error
, no bodyPOST /items/list
Must be authenticated.
Description
Because the notes/folders are being implemented by a file system, this endpoint lists notes in a path
Request Body
Return
200 OK
, body: a JSON array ofNote
that belong to the authenticated user and are inside the path given in the request body.400 Bad Request
, no body500 Internal Server Error
, no bodyDELETE /items/delete
Must be authenticated. Deny request bodies with
400 Bad Request
.Description
Delete resources (notes or folders) by ID
Query Params
4f91ef86-70ae-42ef-b156-81566bd4230b
, anID
of a noteReturn
204 No Content
, no body400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no bodyPOST /items/create/note
Must be authenticated.
Description
This endpoint creates a note and returns the created note
Request Body
Return
201 Created
, body is theNote
that was created400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no bodyPOST /items/create/studyguide
Must be authenticated.
Description
This endpoint creates a study guide and returns it. Important: study guides are notes, just auto-generated on the server.
Request Body
Return
201 Created
, body is theNote
that was created (but is really a study guide)400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no bodyPOST /items/create/folder
Must be authenticated.
Description
This endpoint creates a folder and returns the created folder
Request Body
Return
201 Created
, body is theFolder
that was created400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no bodyPOST /items/update/metadata
Must be authenticated.
Description
Update a resource's (folder/note) metadata (path/name) by ID
Query Params
ID
of resource (note or folder)POST /items/update/metadata?id=4f91ef86-70ae-42ef-b156-81566bd4230b
: update resource with id of4f91ef86-70ae-42ef-b156-81566bd4230b
Request Body
Example:
4f91ef86-70ae-42ef-b156-81566bd4230b
to the root and change name toNew Folder Name
lastEdited
of this folder on the server!Return
204 No Content
, no bodyid
does not exist:400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no bodyPUT /items/update/blocks
Must be authenticated.
Description
Update the contents (blocks) in a note by its ID
Query Params
ID
of note onlyPUT /items/update/blocks?id=4f91ef86-70ae-42ef-b156-81566bd4230b
: update note blocks with id of4f91ef86-70ae-42ef-b156-81566bd4230b
Request Body
Return
204 No Content
, no bodyid
does not exist:400 Bad Request
, no body500 Internal Server Error
, no body401 Unauthorized
, no body