Textcache is an alternative to Pastebin which allows for sharing of text snippets (with the option of password protection) in a safe manner. The text shared is end-to-end encrypted using AES encryption - check that out at AES wiki. This repository has the backend code styled with Spring Boot framework. The server is hosted at Server. A redis instance is also connected via internal URL hosted on render.
-
Fetch encrypted paste JSON from frontend and put it into redis (TTL = 900s).
POST /api/pastes/new Content-Type: application/json
-
Send the same paste JSON with an automated path URL (where frontend will display the cache).
GET /api/pastes/{hash} Content-type: application/json
Following is how the encrypted json looks like (the data is encrypted so no privacy issue!)
{
"encryptedContent" : "nJ0xYEAV+Dcpk9io5bBZS6lwopoj8YIpn7C/SPvBo/QNgHKLT7lBEXIZOnvXnC"
"iv" : "8d26b321261ee530d0be5dd389108995"
"protected" : true
"hash" : "xy12se"
}
To build & run the project, u must have Java JDK installed on your favourite IDE (I recommend Intellij). Although u don't need to setup spring boot project from scratch u can check out the general setup at spring initializer.
Follow the below steps to run the project locally & subsequently build it too (not required for deployment tho)
# clone the project to get local folder
git clone https://github.com/vercetti322/textcache-backend.git
After cloning, open the project in your IDE and let it resolve the pom.xml for maven dependencies (if it does not do it, then run
mvn install
in root directory of the project). After that you can build the project to get a .jar
file.
mvn build
Just head on to vercel and create a free tier account (mention that you are hobbyist student) until u get an empty dashboard. Follow the below steps to deploy:
- Click on the "Add new" and select the option for "Project"
- On the import git repository, select your react project (we have used vite here, but no issue with CRA), and simply click "Deploy"
-
Also, mention any environment variables (not in our case, i mentioned the base url of hosted server directly).
-
Wait for some time untill the project builds and u get a live link!
-
Make sure u have a vercel.json which tells vercel to route back any dynamic routes (as in our case) to
index.html
. -
If u get an
npm run build error (exit 1)
error then 99% u theindex.html
is not able to ref themain.jsx
. Other errors like capitalization of components, directory not havingpackage.json
, etc. might also be the cause.