nemfile 1.0.4 → 1.0.6
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/package.json +2 -2
- package/server.js +10 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemfile",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Send files, screenshots and text between your phone, iPad and computer over local Wi-Fi \u2014 no cloud, no account, no app install. One command: npx nemfile.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file-transfer",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"cloudflared": "^0.7.3",
|
|
86
86
|
"express": "^4.18.2",
|
|
87
|
-
"multer": "^
|
|
87
|
+
"multer": "^2.5.0",
|
|
88
88
|
"qrcode": "^1.5.4"
|
|
89
89
|
}
|
|
90
90
|
}
|
package/server.js
CHANGED
|
@@ -42,16 +42,6 @@ function printBanner() {
|
|
|
42
42
|
console.log('');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
async function printQR(label, url) {
|
|
46
|
-
// Skip when not a real terminal — a log file or piped output can't scan a
|
|
47
|
-
// QR code anyway, and qrcode's own renderer doesn't check isTTY, so it
|
|
48
|
-
// would otherwise dump raw ANSI block-art escapes into the log.
|
|
49
|
-
if (!isTTY) return;
|
|
50
|
-
const qr = await QRCode.toString(url, { type: 'terminal', small: true });
|
|
51
|
-
console.log(` ${c.dim(label)}`);
|
|
52
|
-
console.log(qr.split('\n').map(l => ' ' + l).join('\n'));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
45
|
if (!fs.existsSync(UPLOADS_DIR)) fs.mkdirSync(UPLOADS_DIR);
|
|
56
46
|
|
|
57
47
|
const storage = multer.diskStorage({
|
|
@@ -978,7 +968,14 @@ app.listen(PORT, '0.0.0.0', async () => {
|
|
|
978
968
|
}
|
|
979
969
|
|
|
980
970
|
console.log('');
|
|
981
|
-
|
|
971
|
+
const label = s => c.dim(s.padEnd(10));
|
|
972
|
+
const blank = ' '.repeat(10);
|
|
973
|
+
const method = s => s.padEnd(5);
|
|
974
|
+
const path = s => s.padEnd(16);
|
|
975
|
+
|
|
976
|
+
console.log(' ' + label('Flags') + '--no-tunnel, -L'.padEnd(16) + 'LAN only, skip the public tunnel');
|
|
977
|
+
console.log(' ' + label('API') + method('GET') + path('/api/files') + 'list uploaded files as JSON');
|
|
978
|
+
console.log(' ' + blank + method('POST') + path('/upload') + 'upload a file (multipart field "image")');
|
|
982
979
|
|
|
983
980
|
if (NO_TUNNEL) {
|
|
984
981
|
console.log('\n Public tunnel disabled — LAN only.');
|
|
@@ -994,10 +991,9 @@ app.listen(PORT, '0.0.0.0', async () => {
|
|
|
994
991
|
// the gallery at once.
|
|
995
992
|
const tunnel = Tunnel.quick(`http://localhost:${PORT}`);
|
|
996
993
|
|
|
997
|
-
tunnel.once('url',
|
|
994
|
+
tunnel.once('url', url => {
|
|
998
995
|
publicUrl = url;
|
|
999
|
-
console.log(' Public: ' + publicUrl + ' ← use this outside LAN
|
|
1000
|
-
await printQR('Scan from anywhere (public):', url);
|
|
996
|
+
console.log(' Public: ' + publicUrl + ' ← use this outside LAN');
|
|
1001
997
|
printFooter();
|
|
1002
998
|
});
|
|
1003
999
|
tunnel.on('error', err => {
|