c1d80cc / anbot.mjs
diff --git a/anbot.mjs b/anbot.mjs
index d5086fa..1be809d 100644
--- a/anbot.mjs
+++ b/anbot.mjs
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process'
-import { existsSync, realpathSync } from 'node:fs'
+import { existsSync, readFileSync, realpathSync } from 'node:fs'
import { createServer } from 'node:http'
import { basename, dirname, isAbsolute, relative, resolve, sep } from 'node:path'
import { parseArgs } from 'node:util'
@@ -14,6 +14,8 @@ import { receivePush } from './receive.mjs'
import { publishPost, readFeed } from './social-store.mjs'
import { blobPage, commitPage, feedPage, indexPage, notFoundPage, treePage } from './webui.mjs'
+const feedScript = readFileSync(new URL('./feed-live.js', import.meta.url))
+
const help = `Usage:
node anbot.mjs publish --data DIR --source CHECKOUT --branch BRANCH [--name NAME] [--host HOST] [--port PORT]
node anbot.mjs serve --data DIR [--host HOST] [--port PORT] [--push-allowlist FILE] [--push-origin ORIGIN]
@@ -162,6 +164,12 @@ async function runServer(root, identity, host, port, baseUrl, allowlist, pushOri
const server = createServer(async (request, response) => {
const [pathname, query = ''] = request.url.split('?', 2)
if (request.method === 'GET') {
+ if (pathname === '/feed-live.js') {
+ response.writeHead(200, {
+ 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'no-cache'
+ }).end(feedScript)
+ return
+ }
if (pathname === '/feed') {
try {
await serveFeed(root, identity, query, response)
Git ยท Social feed