ππ» myapp25μμλ λΆμ€νΈνλ κ²½μ° λ΄ νλ‘μμκ² κΈμ μ λ¬νλ κΈ°λ₯μ ꡬνν©λλ€.
In myapp25, we are implementing a feature that delivers posts to your followers when you “boost” them.
π μ 체 νλ‘μ νΈ κ΅¬μ‘° / Overall Project Structure
myapp24/
βββ app/ (Next.js App Router)
β βββ .well-known/webfinger/route.ts -> webfinger
β βββ api/follow/route.ts -> Follow API(temporary)
β βββ api/announce/route.ts -> Boost(Announcement)
β βββ api/like/route.ts. -> Like API
β βββ api/posts/route.ts -> Writing API
β βββ api/timeline/route.ts -> Timeline API
β βββ users/[username]/
β β βββ statuses/[id]/route.ts -> Indivisual Post
β β βββ route.ts -> Acotr Information
β β βββ followers/route.ts -> Followers List
β β βββ following/route.ts -> Following List
β β βββ inbox/route.ts -> Inbox
β β βββ outbox/route.ts -> outbox
β βββ usersui/[username]/page.tsx -> Timeline UI
β βββ layout.tsx, page.tsx, globals.css
β βββ favicon.ico
βββ lib/
β βββ ap.ts -> Follow Accept
β βββ db.ts -> DB connection
βββ data/
β βββ keys/ -> private.pem, public.pem
βββ data.sqlite -> Database
βββ Caddyfile -> https
βββ package.json
π νλ‘μ νΈ μμ(myapp25)
Project Start (myapp25)
npx create-next-app@latest
π SQLiteμ€μΉ / Installing SQLite
cd ~/myapp25
npm install better-sqlite3
npm install -D @types/better-sqlite3
π DDNS,httpsμ€μ / DDNS,https settings
π λλ©μΈνμ©, @userid μ¬μ©νκΈ°
Allowing domains, using @userid
— next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* allow domain*/
allowedDevOrigins: ['aloy-horizon.duckdns.org', '*.duckdns.org'],
/* host.domain.org/@userid */
async rewrites() {
return [
{
source: '/@:username',
destination: '/usersui/:username',
},
]
}
};
export default nextConfig;
π λΆμ€νΈ λ³΄λΌ λ / When sending a boost
βοΈ myapp25/app/api/announce/route.ts
if (result.ok) {
db.prepare('INSERT INTO announces (id, username, object) VALUES (?, ?, ?)').run(result.announceDoc.id, username, apObjectId);
// β
myapp25 - νλ‘μμκ² λΆμ€νΈ λ°°λ¬ / Deliver Boosts to followers
const followers = db.prepare('SELECT inbox, actor FROM followers WHERE username = ?').all(username) as any[];
console.log(`π’ λΆμ€νΈ λ°°λ¬ μμ: ${followers.length}λͺ
μκ²`);
for (const f of followers) {
try {
// νλ‘μ inboxμ Announce κ·Έλλ‘ μ λ¬
// ap.tsμ sendAnnounce μ¬μ¬μ©
await sendAnnounce(f.inbox, apObjectId, username);
} catch (e) {
console.error(`λ°°λ¬ μ€ν¨ -> ${f.actor}`, e);
}
}
}
π λΆμ€νΈ λ°μ λ / When receiving a boost
βοΈ myapp25/app/users/[username]/inbox/route.ts
— λΆμ€νΈ λ°κΈ° / Receive boost
// β
myapp25 - λΆμ€νΈ λ°κΈ° / Receive Boost !
if (body.type === 'Announce') {
try {
const announceId = body.id;
const objectId = typeof body.object === 'string' ? body.object : body.object?.id;
console.log(`π [${username}] Announce λμ°©: ${actorId} -> ${objectId}`);
// 1. announces ν
μ΄λΈμ κΈ°λ‘
// Record in announces table
db.prepare('INSERT OR IGNORE INTO announces (id, username, object) VALUES (?,?,?)')
.run(announceId, username, objectId);
// 2. μκΈ λ΄μ© κ°μ Έμμ inbox_postsμ μ μ₯ (νμλΌμΈμ λ¨κ²)
// Retrieve the original post content and save it to inbox_posts (so it appears on the timeline)
try {
const noteRes = await fetch(objectId, {
headers: { Accept: 'application/activity+json' }
});
if (noteRes.ok) {
const note = await noteRes.json();
const longId = note.id || objectId;
const shortId = `${longId.split('/').pop()}_boost_${Date.now()}`; // λΆμ€νΈλ λ³λ id
const content = note.content || note.summary || '';
db.prepare(`
INSERT OR IGNORE INTO inbox_posts (id, actor, content, username, original_id, created_at)
VALUES (?, ?, ?, ?, ?, ?)
`).run(shortId, actorId, content, username, longId, body.published || new Date().toISOString());
console.log(`β
[${username}] λΆμ€νΈ inbox_posts μ μ₯ / Boost inbox_posts save: ${shortId}`);
}
} catch (fetchErr) {
console.log(`β μκΈ fetch μ€ν¨, content μμ΄ μ μ₯`, fetchErr);
// fetch μ€ν¨ν΄λ λΆμ€νΈ κΈ°λ‘μ λ¨κΉ / Boost records are saved even if fetch fails.
db.prepare(`
INSERT OR IGNORE INTO inbox_posts (id, actor, content, username, original_id, created_at)
VALUES (?, ?, ?, ?, ?, ?)
`).run(`boost_${Date.now()}`, actorId, `[Boost] ${objectId}`, username, objectId, new Date().toISOString());
}
console.log(`β
[${username}] announces μ μ₯ μλ£ / Announcements saved.: ${announceId}`);
} catch (e) {
console.error(`β Announce μ μ₯ μ€ν¨ / Failed to save Announce.`, e);
}
return new Response('', { status: 202 });
}
— λΆμ€νΈ μ·¨μλ°κΈ° / Cancel Boost(Undo Announce)
// β
myapp25 - Undo Announce (λΆμ€νΈ μ·¨μ λ°κΈ°)
if (body.type === 'Undo') {
// μμμ μ΄λ―Έ Follow, Like Undo μ²λ¦¬νμΌλκΉ μ¬κΈ°μλ Announce Undoλ§
const obj = body.object;
if (typeof obj === 'object' && obj.type === 'Announce') {
const announceId = obj.id;
const objectId = typeof obj.object === 'string' ? obj.object : obj.object?.id;
console.log(`β© [${username}] Undo Announce: ${actorId} -> ${objectId}`);
db.prepare('DELETE FROM announces WHERE id = ?').run(announceId);
// inbox_postsμμ λΆμ€νΈ κΈλ μμ (μ ν)
db.prepare('DELETE FROM inbox_posts WHERE original_id = ? AND actor = ?').run(objectId, actorId);
console.log(`π [${username}] λΆμ€νΈ μ·¨μ μ²λ¦¬ μλ£ / Boost processing cancellation complete.`);
return new Response('', { status: 202 });
}
}
π ν μ€νΈ / Test
# νλ‘μ° (following 1λ‘ μ¦κ°)
# Follow (following increased to 1)
curl -X POST https://aloy-horizon.duckdns.org/api/follow \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/users/mcnees"}'
# μΈνλ‘μ° (following 0μΌλ‘ κ°μ)
# Unfollow (following count reduced to 0)
curl -X DELETE https://aloy-horizon.duckdns.org/api/follow \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/users/mcnees"}'
# λΆμ€νΈ μ€ν / Boost
curl -X POST https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/@mcnees/117089019419350090"}'
# λΆμ€νΈ μ·¨μ / Cancle Boost
curl -X DELETE https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/@mcnees/117089019419350090"}'
βοΈ λ§μ€ν λ μλ²μ κΈ λΆμ€νΈνκΈ° / Boost a post on a Mastodon server
https://mastodon.social/@mcnees/117089019419350090
— νλ‘μ°,λΆμ€νΈμ€ν / Execute Follow and Boost
# λ§μ€ν λ μλ²μ νλ‘μ° μμ² / Follow request to a Mastodon server
myapp25 % curl -X POST https://aloy-horizon.duckdns.org/api/follow \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/users/mcnees"}'
{"ok":true,"inbox":"https://mastodon.social/users/mcnees/inbox","target":"https://mastodon.social/users/mcnees","username":"user1","result":"","follow":{"@context":"https://www.w3.org/ns/activitystreams","id":"https://aloy-horizon.duckdns.org/users/user1/follows/1787878537250","type":"Follow","actor":"https://aloy-horizon.duckdns.org/users/user1","object":"https://mastodon.social/users/mcnees"}}%
# λΆμ€νΈ μ€ν / Run Boost
myapp25 % curl -X POST https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://mastodon.social/@mcnees/117089019419350090"}'
{"ok":true,"result":{"ok":true,"status":202,"text":"","announceDoc":{"@context":"https://www.w3.org/ns/activitystreams","id":"https://aloy-horizon.duckdns.org/users/user1/announces/15aad35a-32de-4de0-b832-9134498b94d5","type":"Announce","actor":"https://aloy-horizon.duckdns.org/users/user1","object":"https://mastodon.social/users/mcnees/statuses/117089019419350090","published":"2026-08-28T00:56:17.391Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://aloy-horizon.duckdns.org/users/user1/followers","https://aloy-horizon.duckdns.org/users/user1"]}}}%
gimdaegyeong@gimdaegyeong-ui-MacBookAir myapp25 %

— λ΄ DBμ λΆμ€νΈ μ λ¬νμΈ / Check Boost delivery status in my DB
sqlite> select * from announces;
https://freelifemakers.com/users/user1/statuses/01M12WRSDN77HCBMPES6NH8A4Z|user1|https://freelifemakers.com/users/user1/statuses/01M10AHFHCKGF9BY5G4H50VSHG|2026-08-28 00:36:59
https://aloy-horizon.duckdns.org/users/user1/announces/9d4b9bc4-fa12-4073-b034-794c0dde40f8|user1|https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7|2026-08-28 00:46:46
https://aloy-horizon.duckdns.org/users/user1/announces/15aad35a-32de-4de0-b832-9134498b94d5|user1|https://mastodon.social/users/mcnees/statuses/117089019419350090|2026-08-28 00:56:17
sqlite>
βοΈ freelifemakers.comμμ λΆμ€νΈ ν κ²½μ°
If you boosted via freelifemakers.com

sqlite> select * from announces;
https://freelifemakers.com/users/user1/statuses/01M12WRSDN77HCBMPES6NH8A4Z|user1|https://freelifemakers.com/users/user1/statuses/01M10AHFHCKGF9BY5G4H50VSHG|2026-08-28 00:36:59
βοΈ aloy-horizon.duckdns.orgκ° freelifemakers.comμ λΆμ€νΈν κ²½μ°
If aloy-horizon.duckdns.org has boosted freelifemakers.com
# λΆμ€νΈ μ€ν / Boost
curl -X POST https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d
'{"username":"user1","target":"https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7"}'
# λΆμ€νΈ μ·¨μ / Cancle Boost
curl -X DELETE https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d
'{"username":"user1","target":"https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7"}'
myapp25 % curl -X POST https://aloy-horizon.duckdns.org/api/announce \
-H "Content-Type: application/json" \
-d '{"username":"user1","target":"https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7"}'
{"ok":true,"result":{"ok":true,"status":202,"text":"{\"status\":\"Accepted\"}","announceDoc":{"@context":"https://www.w3.org/ns/activitystreams","id":"https://aloy-horizon.duckdns.org/users/user1/announces/9d4b9bc4-fa12-4073-b034-794c0dde40f8","type":"Announce","actor":"https://aloy-horizon.duckdns.org/users/user1","object":"https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7","published":"2026-08-28T00:46:46.182Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://aloy-horizon.duckdns.org/users/user1/followers","https://aloy-horizon.duckdns.org/users/user1"]}}}%
sqlite> select * from announces;
https://freelifemakers.com/users/user1/statuses/01M12WRSDN77HCBMPES6NH8A4Z|user1|https://freelifemakers.com/users/user1/statuses/01M10AHFHCKGF9BY5G4H50VSHG|2026-08-28 00:36:59
https://aloy-horizon.duckdns.org/users/user1/announces/9d4b9bc4-fa12-4073-b034-794c0dde40f8|user1|https://freelifemakers.com/users/user1/statuses/01M12X859S7WNSJJD42NWZS8T7|2026-08-28 00:46:46
sqlite>
μν볡μ 8μ₯ 32μ / John 8:32
“κ·Έλ¦¬κ³ λν¬λ μ§λ¦¬λ₯Ό μκ² λ κ²μ΄λ©°, μ§λ¦¬κ° λν¬λ₯Ό μμ λ‘κ² ν κ²μ΄λ€.”
“Then you will know the truth ,and the truth will set you free”