1
0
Fork 0
mirror of https://github.com/Jackzmc/PasteLite.git synced 2026-02-03 21:06:30 -06:00
PasteLite/static/index.html
2025-08-06 10:54:55 -05:00

160 lines
No EOL
6.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PasteLite</title>
<style>
td, th {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #04AA6D;
color: white;
}
tr:nth-child(even){background-color: #f2f2f2;}
</style>
</head>
<body>
<h1>PasteLite</h1>
<p>Thank you for using <a href="https://github.com/Jackzmc/PasteLite">PasteLite</a>, you can customize this homepage by editing: <pre>static/index.html</pre> in the project's root directory
<h2>API Routes</h2>
<table>
<thead>
<tr>
<th>Route</th>
<th>Description</th>
<th>Query Parameters</th>
<th>Return value</th>
</tr>
</thead>
<tbody>
<tr>
<td><b>POST</b><br><code>/paste</code></td>
<td>Creates a new paste with type determined by content-type <br><br>*URL only included if PASTE_URL_PREFIX is set</td>
<td><ul>
<li><b>expires</b> <em>(optional)</em> - Time in seconds for the paste to expire, if not set, falls back to the host's default which is 1 day if unchanged. Set to '0' to never expire (unless host has set a maximum)</li>
<li><b>textOnly</b> <em>(optional)</em> - Will not return json but plain text of <code>%id%\n%deletetoken%\n%url%*</code></li>
</ul></td>
<td><pre>{<br> name,<br> url, *<br> expires,<br> type,<br> deleteToken<br>}</pre></td>
</tr>
<tr>
<td><b>GET</b>
<br><code>/:name</code>
<br><code>/:name.html</code>
</td>
<td>Display a paste in html with syntax highlighting</td>
<td><ul>
<li><b>theme</b> (optional) - Set to 'light' for light mode, default is dark mode</li>
</ul></td>
<td>HTML site</td>
</tr>
<tr>
<td><b>GET</b>
<br><code>/:name/raw</code>
<br><code>/:name.txt</code>
</td>
<td>Returns the paste content as <pre>text/plain</pre></td>
<td><em>None</em></td>
<td>text/plain content</td>
</tr>
<tr>
<td><b>GET</b>
<br><code>/:name/json</code>
<br><code>/:name.json</code>
</td>
<td>Returns the paste content as JSON, or 404 if unavailable (not JSON)</td>
<td><em>None</em></td>
<td>application/json content</td>
</tr>
<tr>
<td><b>GET</b>
<br><code>/:name/meta</code>
<br><code>/:name.meta.json</code>
</td>
<td>Returns metadata about paste in JSON</td>
<td><em>None</em></td>
<td>
<pre>{<br> name, <br> content, <br> type, <br> expires <br>}</pre>
</td>
</tr>
<tr>
<td><b>DELETE</b><br><pre>/:name/deleteToken</pre></td>
<td>Deletes the paste if delete token matches</td>
<td><em>None</em></td>
<td>204 on success</td>
</tr>
</tbody>
</table>
<h3>Response Headers</h3>
<p>All the GET routes also return the following headers:</p>
<ul>
<li>PASTE_EXPIRES - the unix timestamp of paste expiration</li>
<li>PASTE_MIME - the mime type of paste</li>
</ul>
<ul>
<li>PASTE_DELETE_TOKEN - on POST this is provided with the same delete token</li>
</ul>
<hr>
<h2>Configuring</h2>
<p>Configuration is done using environmental variables, either you can set these using export or ENV_VAR=value node ..., or you can create a .env file in the project root with each line being a variable</p>
<p>Here is all the possible configurations:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Default</th>
</tr>
<tbody>
<tr>
<td>WEB_PORT</td>
<td>The port to run the server on</td>
<td>8080</td>
</tr>
<tr>
<td>PASTE_DEFAULT_EXPIRES</td>
<td>The default time in seconds that a paste will expire, unless overwritten</td>
<td>86400 (1 day)</td>
</tr>
<tr>
<td>PASTE_MAX_EXPIRES</td>
<td>If set, clamps the expires time to this value</td>
<td><em>not set</em></td>
</tr>
<tr>
<td>PASTE_ALLOWED_MIMES</td>
<td>A comma-separated list of mime types to allow, in addition to text/*</td>
<td><em>application/json</em></td>
</tr>
<tr>
<td>PASTE_ID_ALPHABET</td>
<td>The characters chosen for a paste's unique id</td>
<td>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</td>
</tr>
<tr>
<td>PASTE_ID_LENGTH</td>
<td>How long a paste's id should be</td>
<td>12</td>
</tr>
<tr>
<td>PASTE_URL_PREFIX</td>
<td>If set, a 'url' field added to creation with this</td>
<td><em>not set</em></td>
</tr>
<tr>
<td>BODY_LIMIT</td>
<td>Fastify's max request body size</td>
<td>1048576 (1MiB)</td>
</tr>
<tr>
<td>PASTE_CLEANUP_INTERVAL</td>
<td>How often to check for pastes to be cleaned up in seconds. It is not the actual paste expiration.</td>
<td>3600</td>
</tr>
</tbody>
</table>
</body>
</html>