From d01ec3fdcc2c71bdaeb1d55dc7e749dffeaee66d Mon Sep 17 00:00:00 2001 From: slynn1324 Date: Mon, 25 Jan 2021 09:58:48 -0600 Subject: [PATCH] added version --- server.js | 11 +++++------ version.txt | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 version.txt diff --git a/server.js b/server.js index 5c1be72..27e730c 100644 --- a/server.js +++ b/server.js @@ -2,7 +2,6 @@ const yargs = require('yargs'); const express = require('express'); const bodyParser = require('body-parser'); const betterSqlite3 = require('better-sqlite3'); -// const db = require('better-sqlite3') //, {verbose:console.log}); const http = require('http'); const https = require('https'); const sharp = require('sharp'); @@ -11,8 +10,6 @@ const path = require('path'); const fetch = require('node-fetch'); const crypto = require('crypto'); const cookieParser = require('cookie-parser'); -const { send } = require('process'); -const { SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION } = require('constants'); process.on('SIGINT', () => { console.info('ctrl+c detected, exiting tinypin'); @@ -26,6 +23,8 @@ process.on('SIGTERM', () => { process.exit(0); }); +let VERSION = require('fs').readFileSync('version.txt', 'utf8'); + const argv = yargs .option('slow', { alias: 's', @@ -60,6 +59,8 @@ const PORT = argv.port; console.log('tinypin starting...'); console.log(''); +console.log(`version: ${VERSION}`); +console.log(''); console.log('configuration:'); console.log(` port: ${PORT}`); console.log(` database path: ${DB_PATH}`); @@ -217,7 +218,6 @@ app.use ( async (req, res, next) => { // handle image serving, injecting the user id in the path to segregate users and control cross-user resource access app.use( (req, res, next) => { - if ( req.method == "GET" && req.originalUrl.startsWith("/images/") ){ let filepath = IMAGE_PATH + '/' + req.user.id + '/' + req.originalUrl; @@ -227,7 +227,6 @@ app.use( (req, res, next) => { } else { next(); } - }); app.use(express.static('static')); @@ -249,7 +248,7 @@ const SERVER_ERROR = {status: "error", error: "server error"}; app.get("/api/whoami", (req, res) => { - res.send({name: req.user.name}); + res.send({name: req.user.name, version: VERSION}); }); // list boards diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..c86c3f3 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +none \ No newline at end of file