build timestamp
Massimo Melina committed
Dec 22, 2021 at 23:43 UTC
cce4b1191ee938477d234206f83c53cd636fa064
5 files changed
+16
-13
package-lock.json
+2
-2
@@ -1,12 +1,12 @@
1
{
2
"name": "hfs",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
"lockfileVersion": 2,
5
"requires": true,
6
"packages": {
7
"": {
8
"name": "hfs",
9
- "version": "0.2.0",
9
+ "version": "0.3.0",
10
"license": "GPL-3.0",
11
"dependencies": {
12
"@koa/router": "^10.1.1",
package.json
+1
-1
@@ -12,7 +12,7 @@
12
"scripts": {
13
"watch-server": "nodemon --ignore tests/ --watch src -e ts,tsx --exec ts-node src/index.ts vfs.yaml",
14
"start": "node dist",
15
- "build": "tsc && cp package*.json *.yaml dist && cd dist && npm ci --production",
15
+ "build": "node timestamp && tsc && cp package*.json *.yaml dist && cd dist && npm ci --production",
16
"test": "mocha -r ts-node/register 'tests/**/*.ts'"
17
},
18
"dependencies": {
src/index.ts
+7
-3
@@ -12,6 +12,8 @@ import compress from 'koa-compress'
12
13
const PORT = argv.port || 80
14
15
+const BUILD_TIMESTAMP = ""
16
+
17
const srv = new Koa()
18
srv.use(async (ctx, next) => {
19
// log all requests
@@ -43,9 +45,11 @@ srv.use(async (ctx, next) => {
45
if (!node)
46
return await next()
47
const { source } = node
46
- if (!source || await isDirectory(source)) // this folder was requested without the trailing /
47
- return path.endsWith('/') ? await serveFrontend(ctx,next)
48
- : ctx.redirect(ctx.path+'/')
48
+ if (!source || await isDirectory(source)) { // this folder was requested without the trailing /
49
+ ctx.set({ server:'HFS '+BUILD_TIMESTAMP })
50
+ return path.endsWith('/') ? await serveFrontend(ctx, next)
51
+ : ctx.redirect(ctx.path + '/')
52
+ }
53
if (source)
54
return source.includes('//') ? mount(path,proxy(source,{}))(ctx,next)
55
: serveFile(source)(ctx,next)
timestamp.js
new
+3
@@ -0,0 +1,3 @@
1
+const fs = require('fs')
2
+const FN = 'src/index.ts'
3
+fs.writeFileSync(FN, fs.readFileSync(FN,'utf8').replace(/(BUILD_TIMESTAMP = ")(.*)"/, '$1'+new Date().toISOString()+'"'))
todo.md
+3
-7
@@ -1,20 +1,16 @@
1
# To do
2
-- node.link
2
- vfs: serve an html for a folder?
3
- "default" property for vfsNode?
5
-- interruption of long requests if client aborted (searching/listing)
4
- log file
5
- throttle speed
6
- frontend: dialogs
9
-- frontend
10
- - don't depend on cdn
7
+- frontend: don't depend on cdn
8
- webdav?
12
-- streamable zip archives
13
- - no compression
14
- - resumable?
9
+- streamable zip archives (no compression, resumable?)
10
- vfs: ability to remove/hide/rename files deep in a source
11
- let user change password
12
- user should be able to inherit from another a group (another user)
13
+- administration interface
14
- login without passing clear text password?
15
we could use asymmetric encryption, possibly on a hashed password, that means
16
we should store a hash2(hash1(password+salt1)), where hash1 is applied on both client