How to Build a Cloud Diary with PasteBin Worker
Previously we implemented the online notepad PasteBin, which is used to host a piece of text for yourself.
Demo site: https://pastebin.icdyct.cloudns.asia/tieludasiliqiuweiyue
If you want to use it as your own diary, it would be a bit inconvenient.
For example, if you use this page as the main operation page, rather than writing elsewhere and pasting it over, this page doesn't let you write a bit, save it, write a bit more, and save again. When you click save, it prompts that the key already exists.
Another point is that when you want to modify a certain diary entry, you have to go to the display list to find it, which is a bit inconvenient.
Approach
First, when saving key-value to the database, do not check whether the key already exists (in the previous short link system, it was checked).
Second, add a small feature to read a specified key-value.
After clicking the Load button, read the value from the database and place the data into the original operation interface.
Subsequent operations can be used according to the previous system operation method.
Practice
Add a configuration item to worker.js: when overwrite_kv is set to true, it will not check whether the key exists when adding key-value.
Add a function in main.js to read the specified key-value.Adding a few page elements in index.html won't be elaborated on.
End
Github: https://github.com/crazypeace/url-Shorten-Worker/
Demo site: https://journal.crazypeace.workers.dev/journaljournal