Giter Club home page Giter Club logo

nutty's Introduction

Nutty

A simple HTTP paste server - Contributions Welcome!

Nutty is a self-hostable paste server, allowing you to easily upload and share text files instantly.

Features

  • A simple HTTP interface
  • A simple Web interface (WIP)
  • Public and private pastes
  • Low memory footprint

Installation

  1. Make sure you have Deno installed on your system. If not, you can install it by following the instructions on the Deno website.
  2. Clone the repository by running git clone https://github.com/JLCarveth/nutty.git.
  3. Change into the cloned directory by running cd nutty.
  4. Run the paste.ts file with Deno by running deno run -A --unstable paste.ts.

A simple systemd service can also be setup to handle stopping/starting Nutty:

[Unit]
Description=File pasting API

[Service]
ExecStart=/home/jlcarveth/.deno/bin/deno run -A --unstable paste.ts
Restart=always
User=jlcarveth
Group=jlcarveth
WorkingDirectory=/opt/paste
EnvironmentFile=/opt/paste/.env
StandardOutput=/var/log/paste/out.log
StandardError=/var/log/paste/error.log

[Install]
WantedBy=multi-user.target

Environment

Nutty depends on a couple of environment variables to be established before running.

Variable Name Description Example Values
TARGET_DIR The directory where pastes will be stored. /opt/paste/data
BASE_URL The base URL at which the API can be accessed. https://paste.mysite.com/api
SECRET_KEY Used for signing JWTs. A secret key can be generated with openssl rand -base64 32 GDZ1FzBF18dtAk2enanqqxskVf5hptmPjy/pcBm384M=
PORT The port to listen to. Default is 5335 5335
PUBLIC_PASTES Whether to allow users to create pastes without an access token. 1,0,true,false
DEBUG Logs incoming requests for debugging purposes. 1,0,true,false
DOMAIN The domain used for the HTTP cookie paste.jlcarveth.dev

Usage

There is a simple client bash script which provides a simple example of using Nutty.

export TOKEN=$(curl https://paste.jlcarveth.dev/api/login -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"notmypassword"}')
export EMAIL="[email protected]" # Email is used for signing PGP messages
uuid=$(cat file.txt | bash client.sh)

If the client runs successfully, a UUID associated with the new paste is returned. This paste can then be retrieved with a simple GET request:

curl $API_URL/$UUID -H "X-Access-Token: $TOKEN"

nutty's People

Contributors

jlcarveth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nutty's Issues

GET-/api/paste crashes when the given user has no pastes yet

error: Uncaught NotFound: No such file or directory (os error 2): readdir '/opt/paste/data/9dd2f532-34bd-4819-93eb-73ce4caddfba'
  for await (const filename of Deno.readDir(`${TARGET_DIR}/${uuid}`)) {
                   ^
    at eventLoopTick (ext:core/01_core.js:166:11)
    at async Object.[Symbol.asyncIterator] (ext:deno_fs/30_fs.js:147:19)
    at async Object.handler (file:///opt/paste/paste.ts:343:20)
    at async Object.respondWith (ext:deno_http/01_http.js:197:14)
deno_http/01_http.js:197:14)

TODO: Resolve this by checking for the existence of the directory before reading it.

Unsupported scheme "node" for module "node:crypto"

Reproducing:

deno run -A --unstable paste.ts

result:

error: Unsupported scheme "node" for module "node:crypto". Supported schemes: [
    "data",
    "blob",
    "file",
    "http",
    "https",
]
    at file:///./auth.ts:14:41

Incomplete GET-/paste/:uuid Route

Does not handle cases where a token is provided, so private pastes accessed through the GET-/paste/:uuid route simply return "OK" instead of the expected web page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.