@zmx0142857/file-share 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # file-share
2
2
 
3
- ## Quick start
3
+ Start a simple file share server with one command:
4
4
 
5
5
  $ npx @zmx0142857/file-share
6
+ 🚀 server running at http://192.168.?.?:3001
7
+
8
+ Open browser and visit!
@@ -1,3 +1,4 @@
1
+ const indexHtml = `
1
2
  <!DOCTYPE html>
2
3
  <html lang="zh">
3
4
  <head>
@@ -152,3 +153,5 @@
152
153
  </script>
153
154
  </body>
154
155
  </html>
156
+ `
157
+ export default indexHtml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zmx0142857/file-share",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=16.0.0"
package/serve.js CHANGED
@@ -3,6 +3,8 @@ import cors from 'cors'
3
3
  import fileUpload from 'express-fileupload'
4
4
  import fs from 'fs'
5
5
  import path from 'path'
6
+ import indexHtml from './index.js'
7
+ import os from 'os'
6
8
 
7
9
  const app = express()
8
10
  app.use(cors())
@@ -47,8 +49,9 @@ app.post('/upload', (req, res) => {
47
49
  res.json({ code: 200, msg: 'ok', data })
48
50
  })
49
51
 
50
- app.get('/', (req, res) => res.send(fs.readFileSync('index.html', 'utf-8')))
52
+ app.get('/', (req, res) => res.send(indexHtml))
51
53
 
52
54
  const argv = process.argv.slice(2)
53
55
  const port = argv[0] || 3001
54
- app.listen(port, () => console.log(`server is running at port http://localhost:${port}`))
56
+ const ip = Object.values(os.networkInterfaces()).flat().find(v => v.family === 'IPv4').address
57
+ app.listen(port, () => console.log(`🚀 server running at http://${ip}:${port}`))