diff --git a/src/activity.ts b/src/activity.ts index edc221e..2856f2c 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -1,6 +1,6 @@ import { readFileSync } from "node:fs"; import markdownit from "markdown-it"; -import { Article, buildCanonicalUrl, getById as getArticleById } from "./article.js"; +import { Article, buildCanonicalUrl, getArticleById } from "./article.js"; import { User, getByActor } from "./user.js"; import { fillRoute, reverseRoute } from "./router.js"; import { streamToString, hashDigest } from "./util.js"; diff --git a/src/article.ts b/src/article.ts index 4660dfc..a062e1b 100644 --- a/src/article.ts +++ b/src/article.ts @@ -17,28 +17,28 @@ export const zArticle = z.object({ export type Article = z.infer; -export const getBySlug = async (slug: string): Promise
=> { +export const getArticleBySlug = async (slug: string): Promise
=> { return db
("articles") .where("slug", slug) .first() .then((rec) => !!rec ? fixDates
(rec) : null) }; -export const getById = async (articleId: number): Promise
=> { +export const getArticleById = async (articleId: number): Promise
=> { return db
("articles") .where("id", articleId) .first() .then((rec) => !!rec ? fixDates
(rec) : null) }; -export const getByUserId = async (userId: number): Promise => +export const getArticlesByUserId = async (userId: number): Promise => db
("articles") .where("users_id", userId) .orderBy("created_at", "desc") .then((articles) => articles.map((a) => fixDates
(a))) ; -export const insert = async (userId: number, slug: string, title: string): Promise
=> { +export const insertArticle = async (userId: number, slug: string, title: string): Promise
=> { const data: Record = { users_id: userId, slug, @@ -56,7 +56,7 @@ export const insert = async (userId: number, slug: string, title: string): Promi } as Article)) }; -export const getAll = async (count: number, lastId = Number.MAX_SAFE_INTEGER) => +export const getAllArticles = async (count: number, lastId = Number.MAX_SAFE_INTEGER) => db
("articles") .where("id", "<", lastId) .orderBy("created_at", "desc") diff --git a/src/command.ts b/src/command.ts index 710995f..cf92e03 100644 --- a/src/command.ts +++ b/src/command.ts @@ -2,7 +2,7 @@ import fs from "node:fs"; import markdownit from 'markdown-it' import { slugRegex } from "./article.js"; import { newUser, getUserByNickname, getFollowerInboxes, keyIdFromNickname } from "./user.js"; -import { insert as insertArticle } from "./article.js"; +import { insertArticle } from "./article.js"; import { add as addToOutbox } from "./outbox.js"; import { createArticleActivity, sendAll } from "./activity.js"; import { fillRoute } from "./router.js"; diff --git a/src/index.ts b/src/index.ts index 2ad0a17..8230328 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import bodyParser from "body-parser"; import { toCollection as getOutbox } from "./outbox.js"; import { getUserById, getUserNicknameById, getUserByNickname, User } from "./user.js"; import { Routes } from "./router.js"; -import { getBySlug as getArticleBySlug, getById, getByUserId, getAll as getAllArticles } from "./article.js"; +import { getArticleBySlug, getArticleById, getArticlesByUserId, getAllArticles } from "./article.js"; import { userToPerson, TYPE as ACTIVITYPUB_TYPE, handleInboxPost, createArticleObject, CONTEXT, createArticleActivity } from "./activity.js"; import { handleFollowerGet } from "./follower.js"; import { handleWebfingerGet } from "./net.js"; @@ -48,7 +48,7 @@ app.post(Routes.inbox, handleInboxPost); app.get(Routes.followers, handleFollowerGet); app.get(Routes.object, async (req, res) => { - const article = await getById(parseInt(req.params.id)); + const article = await getArticleById(parseInt(req.params.id)); if (article) { console.log("Request headers for object route:", req.headers); @@ -91,7 +91,7 @@ app.get(Routes.activity, async (req, res) => { res.status(501).end(); } else { - const article = await getById(id); + const article = await getArticleById(id); if (article) { console.log("Request headers for activity route:", req.headers); @@ -164,7 +164,7 @@ app.get(Routes.actor, async (req, res) => { } else if (req.accepts("html")) { console.log(`returning actor: ${nickname} as html`); - const posts = (await getByUserId(actor.id)).map((a) => `
  • ${escapeHtml(a.title)}
  • `).join(""); + const posts = (await getArticlesByUserId(actor.id)).map((a) => `
  • ${escapeHtml(a.title)}
  • `).join(""); const body = ` diff --git a/src/outbox.ts b/src/outbox.ts index 66824a4..747aa87 100644 --- a/src/outbox.ts +++ b/src/outbox.ts @@ -2,7 +2,7 @@ import db from "./db.js"; import { z } from "zod"; import { getUserByNickname } from "./user.js"; import { fillRoute } from "./router.js"; -import { getByUserId as getArticlesByUserId, getById as getArticleById, Article } from "./article.js"; +import { getArticleById, Article } from "./article.js"; import { createArticleActivity, deleteArticleActivity } from "./activity.js"; import { orderedCollection } from "./collection.js";