mirror of
https://github.com/slynn1324/tinypin
synced 2026-05-03 17:40:28 +00:00
merge
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
*.db
|
||||
*.psd
|
||||
*.crx
|
||||
*.pem
|
||||
.gitignore
|
||||
.git
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
FROM node:alpine3.12
|
||||
|
||||
COPY . /tinypin
|
||||
|
||||
WORKDIR /tinypin
|
||||
|
||||
RUN apk add build-base python3 && npm install --verbose && apk del build-base python3
|
||||
|
||||
RUN npm install
|
||||
|
||||
ENTRYPOINT ["sh", "-c" , "node server.js -i /data/images -d /data/tinypin.db"]
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
docker build -t tinypin .
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
#-e TINYPIN_SLOW=2000
|
||||
docker run -d --name tinypin -p 3001:3000 -v "$(pwd)/data:/data" --restart=unless-stopped tinypin
|
||||
@@ -10,6 +10,17 @@ const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
console.info('ctrl+c detected, exiting tinypin');
|
||||
console.info('goodbye.');
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
console.info('sigterm detected, exiting tinypin');
|
||||
console.info('goodbye.');
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
const argv = yargs
|
||||
.option('slow', {
|
||||
@@ -49,8 +60,10 @@ console.log('configuration:');
|
||||
console.log(` port: ${PORT}`);
|
||||
console.log(` database path: ${DB_PATH}`);
|
||||
console.log(` image path: ${IMAGE_PATH}`)
|
||||
if ( argv.slow ){
|
||||
console.log(` slow mode delay: ${argv.slow}`);
|
||||
|
||||
const SLOW = argv.slow || parseInt(process.env.TINYPIN_SLOW);
|
||||
if ( SLOW ){
|
||||
console.log(` slow mode delay: ${SLOW}`);
|
||||
}
|
||||
console.log('');
|
||||
|
||||
@@ -59,18 +72,18 @@ const db = betterSqlite3(DB_PATH);
|
||||
// express config
|
||||
const app = express();
|
||||
app.use(express.static('static'));
|
||||
app.use(express.static('images'));
|
||||
app.use(express.static(IMAGE_PATH));
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
app.use(bodyParser.json());
|
||||
app.set('json spaces', 2);
|
||||
|
||||
//emulate slow down
|
||||
if ( argv.slow ){
|
||||
if ( SLOW ){
|
||||
app.use( (req,res,next) => {
|
||||
console.log("slow...");
|
||||
setTimeout(() => {
|
||||
next();
|
||||
}, 2000);
|
||||
}, SLOW);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -413,4 +426,4 @@ function getThumbnailImagePath(pinId){
|
||||
let dir = `${IMAGE_PATH}/thumbnails/${paddedId[11]}/${paddedId[10]}/${paddedId[9]}/${paddedId[8]}`;
|
||||
let file = `${dir}/${paddedId}.jpg`;
|
||||
return {dir: dir, file: file};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user