add simple admin service
Build and deploy / deploy (push) Successful in 16s

This commit is contained in:
2026-05-18 02:48:47 +03:00
parent 10a83d39a2
commit 3a3b2bcfc0
84 changed files with 2134 additions and 5 deletions
@@ -0,0 +1,17 @@
import { httpError } from '../../shared/http/httpError.mjs';
import { sendJson } from '../../shared/http/sendJson.mjs';
import { readArticles, writeArticles } from './articleRepository.mjs';
export async function handleDeleteArticle(_request, response, slug) {
const articles = await readArticles();
const index = articles.findIndex((article) => article.slug === slug);
if (index === -1) {
throw httpError(404, `Article "${slug}" was not found`);
}
const [article] = articles.splice(index, 1);
await writeArticles(articles);
return sendJson(response, { article });
}