mbkauthe 2.0.1 → 2.1.0
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.
- package/lib/main.js +16 -5
- package/lib/pool.js +2 -2
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -15,6 +15,7 @@ import passport from 'passport';
|
|
|
15
15
|
import GitHubStrategy from 'passport-github2';
|
|
16
16
|
|
|
17
17
|
import { createRequire } from "module";
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
18
19
|
import fs from "fs";
|
|
19
20
|
import path from "path";
|
|
20
21
|
|
|
@@ -31,8 +32,22 @@ router.use(express.json());
|
|
|
31
32
|
router.use(express.urlencoded({ extended: true }));
|
|
32
33
|
router.use(cookieParser());
|
|
33
34
|
|
|
35
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
|
|
34
37
|
router.get('/mbkauthe/main.js', (req, res) => {
|
|
35
|
-
res.sendFile(path.join(
|
|
38
|
+
res.sendFile(path.join(__dirname, '..', 'public', 'main.js'));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
router.get("/mbkauthe/bg.avif", (req, res) => {
|
|
42
|
+
const imgPath = path.join(__dirname, "..", "public", "bg.avif");
|
|
43
|
+
res.setHeader('Content-Type', 'image/avif');
|
|
44
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
45
|
+
const stream = fs.createReadStream(imgPath);
|
|
46
|
+
stream.on('error', (err) => {
|
|
47
|
+
console.error('[mbkauthe] Error streaming bg.avif:', err);
|
|
48
|
+
res.status(404).send('Image not found');
|
|
49
|
+
});
|
|
50
|
+
stream.pipe(res);
|
|
36
51
|
});
|
|
37
52
|
|
|
38
53
|
// CSRF protection middleware
|
|
@@ -535,10 +550,6 @@ async function getLatestVersion() {
|
|
|
535
550
|
}
|
|
536
551
|
}
|
|
537
552
|
|
|
538
|
-
router.get("/mbkauthe/bg.avif", (req, res) => {
|
|
539
|
-
res.sendFile("bg.avif", { root: path.join(process.cwd(), "public") });
|
|
540
|
-
});
|
|
541
|
-
|
|
542
553
|
router.get(["/mbkauthe/info", "/mbkauthe/i"], LoginLimit, async (req, res) => {
|
|
543
554
|
let latestVersion;
|
|
544
555
|
const parameters = req.query;
|
package/lib/pool.js
CHANGED
|
@@ -36,9 +36,9 @@ const poolConfig = {
|
|
|
36
36
|
// - keep max small to avoid exhausting DB connections
|
|
37
37
|
// - reduce idle time so connections are returned sooner
|
|
38
38
|
// - set a short connection timeout to fail fast
|
|
39
|
-
max:
|
|
39
|
+
max: 10,
|
|
40
40
|
idleTimeoutMillis: 10000,
|
|
41
|
-
connectionTimeoutMillis:
|
|
41
|
+
connectionTimeoutMillis: 25000,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export const dblogin = new Pool(poolConfig);
|