base
This commit is contained in:
commit
83e72e7ed6
|
@ -0,0 +1,9 @@
|
|||
node_modules
|
||||
.env
|
||||
package-lock.json
|
||||
|
||||
# code
|
||||
!*.js
|
||||
!*.pug
|
||||
!*.css
|
||||
!*.md
|
|
@ -0,0 +1,35 @@
|
|||
require('dotenv').config({});
|
||||
if (process.env.APP_DEBUG) {
|
||||
process.env.DEBUG = '*/*';
|
||||
}
|
||||
|
||||
const { APP_PORT } = process.env;
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
|
||||
const routes = require('./routes');
|
||||
const middleware = require('./middleware');
|
||||
|
||||
app.use(middleware);
|
||||
app.use(routes);
|
||||
app.use(express.static('public'));
|
||||
|
||||
app.set('view engine', 'pug');
|
||||
app.set('views', './views');
|
||||
|
||||
const server = app.listen(APP_PORT, () => {
|
||||
console.log('Running on port ' + APP_PORT);
|
||||
});
|
||||
|
||||
function graceful_exit() {
|
||||
console.log('Exiting...');
|
||||
server.closeAllConnections();
|
||||
server.close((err) => {
|
||||
if (err) console.error(err);
|
||||
process.exit(0);
|
||||
})
|
||||
}
|
||||
|
||||
process.on('SIGINT', graceful_exit);
|
||||
process.on('SIGTERM', graceful_exit);
|
|
@ -0,0 +1,4 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
module.exports = router;
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "blek-bin",
|
||||
"version": "0.0.1",
|
||||
"description": "A privacy-respecting, js-free alternative to pastebin",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"dev": "node index.js"
|
||||
},
|
||||
"author": "b1ek",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"express-async-handler": "^1.2.0",
|
||||
"pug": "^3.0.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
body {
|
||||
background-color: antiquewhite;
|
||||
font-family: monospace;
|
||||
}
|
||||
textarea {
|
||||
background-color: rgb(248, 241, 232);
|
||||
border: 1px solid #6c6f6c;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 2px #20402030;
|
||||
padding: 4px 8px
|
||||
}
|
||||
textarea:hover {
|
||||
box-shadow: 0 2px 4px #20402040;
|
||||
}
|
||||
|
||||
.data {
|
||||
width: 400px;
|
||||
height: 240px
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
router.use(require('./main'));
|
||||
|
||||
module.exports = router;
|
|
@ -0,0 +1,11 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const handler = require('express-async-handler');
|
||||
|
||||
async function index(req, res) {
|
||||
res.render('main', {maxlen: process.env.MAXLEN});
|
||||
}
|
||||
|
||||
router.get('/', handler(index));
|
||||
|
||||
module.exports = router;
|
|
@ -0,0 +1,8 @@
|
|||
extends template/main.pug
|
||||
|
||||
block content
|
||||
form(action='/upload' method='POST')
|
||||
p(align='center')
|
||||
textarea(name='text' class='data' placeholder='Put your text in here!' + (maxlen ? ` (Max length is ${maxlen} bytes)` : ''))
|
||||
br
|
||||
input(type='submit' value='Upload!')
|
|
@ -0,0 +1,17 @@
|
|||
block root
|
||||
|
||||
|
||||
doctype html
|
||||
html(lang='en_US')
|
||||
head
|
||||
title blek! Bin#{title ? title : ''}
|
||||
link(rel='stylesheet' href='/static/main.css')
|
||||
body
|
||||
h1(align='center') blek! Bin
|
||||
p(align='center')
|
||||
a(href='https://git.blek.codes/blek/bin') Source
|
||||
| |
|
||||
a(href='http://blek.codes/project/blek_bin') Project page
|
||||
hr
|
||||
block content
|
||||
|
Loading…
Reference in New Issue