paste.id
is an encrypted paste storage server built using JS
This is the server/api repository. If you are looking for the client repository click here
paste.id is a very very very basic server built using NodeJS. To install paste.id clone this repository and run:
npm install .
Once npm runs through successfully add a .env file within the root directory which contains your mySQL credentials as well as the port we're running on:
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASS=root
MYSQL_DB=pasteid
PORT=3002
Running paste.id server is as easy as executing a few npm scripts.
If you are curious what scripts can be launched take a look at package.json
.
Once your .env
file is ready and your npm dependencies are installed,
just execute node migrate.js
to create the necessary database tables.
To run paste.id server in development mode run:
npm run start-dev
This command will automatically start nodemon which will continously watch for file changes and reload paste.id server accordingly.
Running on production requires an intermediate step where you build and compile your application.
npm run build # only on code change
npm run production
I'm using forever
which will start your app and restart it automatically if it should crash.
paste.id server has only a handful of production dependencies these being:
- mysql (node module)
- dotenv
- express
Since the main logic is happening on paste.id frontend I can explain this server with just a few words:
Basically this server has 2 endpoints:
POST /storage
which will accept acontent
property and store it in a mySQL DBGET /:id
will output a JSON payload which contains acontent
property which itself contains the message you stored before.
So all in all, paste.id server is just a stupid simple text storage over HTTP. The encryption layer is provided by the paste.id frontend application.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
Contribution is generally appreciated. Here are a few things you can do to extend paste.id server:
- Add unit tests
- Replace mySQL in pasteRepository.js with an ORM so we can hook up other DBs
- Extract the DB storage mechanism in a different class so we later add storage to textfiles as well by injecting the required
StorageMechanism
- Add better error handling
- Add support to "verify" a pgp encrypted paste without outputting the content by accepting a public key via variable.
- Add scripts to auto-remove logfiles etc.
- Add expiration to pastes.
- Add option to generate a more "random" ID rather than using the SQL autoincrement ID.