return html with version
This commit is contained in:
parent
46a9041b97
commit
4a185304ae
@ -7,6 +7,7 @@ import TTLCache from '@isaacs/ttlcache';
|
|||||||
import '@dotenvx/dotenvx/config.js';
|
import '@dotenvx/dotenvx/config.js';
|
||||||
import { ApifyClient } from 'apify-client';
|
import { ApifyClient } from 'apify-client';
|
||||||
import { env } from './env.js';
|
import { env } from './env.js';
|
||||||
|
import packageJson from "./package.json" with { type: "json" };
|
||||||
|
|
||||||
const fastify = Fastify({ logger: true });
|
const fastify = Fastify({ logger: true });
|
||||||
|
|
||||||
@ -74,10 +75,22 @@ function buildFeed(username, tweets) {
|
|||||||
return feed.xml({ indent: true });
|
return feed.xml({ indent: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fastify.get("/", (request, reply) => {
|
||||||
|
return reply
|
||||||
|
.code(200)
|
||||||
|
.header("Content-Type", "text/html; charset=utf-8")
|
||||||
|
.send(`HELLO<br>THIS IS rssapp ${packageJson.version}<br>OK<br>try <a href="/projektmelody">/projektmelody</a>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
fastify.get("/:username", async (request, reply) => {
|
fastify.get("/:username", async (request, reply) => {
|
||||||
const { username } = request.params;
|
const { username } = request.params;
|
||||||
const key = username.toLowerCase();
|
const key = username.toLowerCase();
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
return reply.code(401).send({ error: "Username missing" });
|
||||||
|
}
|
||||||
|
|
||||||
if (!env.WHITELIST.has(key)) {
|
if (!env.WHITELIST.has(key)) {
|
||||||
return reply.code(403).send({ error: "Forbidden username" });
|
return reply.code(403).send({ error: "Forbidden username" });
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rssapp",
|
"name": "rssapp",
|
||||||
"version": "69.0.0",
|
"version": "69.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@ -19,4 +19,4 @@
|
|||||||
"rss": "^1.2.2",
|
"rss": "^1.2.2",
|
||||||
"zod": "^4.1.1"
|
"zod": "^4.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user