sillytavern 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -1
  2. package/server.js +5 -4
package/package.json CHANGED
@@ -31,10 +31,13 @@
31
31
  }
32
32
  },
33
33
  "name": "sillytavern",
34
- "version": "1.4.3",
34
+ "version": "1.4.5",
35
35
  "scripts": {
36
36
  "start": "node server.js"
37
37
  },
38
+ "bin": {
39
+ "sillytavern": "./server.js"
40
+ },
38
41
  "rules": {
39
42
  "no-path-concat": "off",
40
43
  "no-var": "off"
package/server.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  const express = require('express');
2
3
  const compression = require('compression');
3
4
  const app = express();
@@ -29,10 +30,10 @@ const ExifReader = require('exifreader');
29
30
  const exif = require('piexifjs');
30
31
  const webp = require('webp-converter');
31
32
 
32
- const config = require(path.join(process.cwd(), './config.conf'));
33
+ const config = require(path.join(__dirname, './config.conf'));
33
34
  const server_port = process.env.SILLY_TAVERN_PORT || config.port;
34
35
 
35
- const whitelistPath = path.join(process.cwd(), "./whitelist.txt");
36
+ const whitelistPath = path.join(__dirname, "./whitelist.txt");
36
37
  let whitelist = config.whitelist;
37
38
 
38
39
  if (fs.existsSync(whitelistPath)) {
@@ -211,7 +212,7 @@ app.use((req, res, next) => {
211
212
  app.use(express.static(__dirname + "/public", { refresh: true }));
212
213
 
213
214
  app.use('/backgrounds', (req, res) => {
214
- const filePath = decodeURIComponent(path.join(process.cwd(), 'public/backgrounds', req.url.replace(/%20/g, ' ')));
215
+ const filePath = decodeURIComponent(path.join(__dirname, 'public/backgrounds', req.url.replace(/%20/g, ' ')));
215
216
  fs.readFile(filePath, (err, data) => {
216
217
  if (err) {
217
218
  res.status(404).send('File not found');
@@ -223,7 +224,7 @@ app.use('/backgrounds', (req, res) => {
223
224
  });
224
225
 
225
226
  app.use('/characters', (req, res) => {
226
- const filePath = decodeURIComponent(path.join(process.cwd(), charactersPath, req.url.replace(/%20/g, ' ')));
227
+ const filePath = decodeURIComponent(path.join(__dirname, charactersPath, req.url.replace(/%20/g, ' ')));
227
228
  fs.readFile(filePath, (err, data) => {
228
229
  if (err) {
229
230
  res.status(404).send('File not found');