- Added new routes for server discovery and key rotation, including challenge issuance and confirmation processes. - Introduced database schema for managing server registrations and rotation challenges. - Implemented encryption and decryption utilities for secure communication between servers. - Updated package dependencies and added new client and server plugins for social features. - Enhanced user management with additional fields and relations in the database schema.
25 lines
No EOL
682 B
TypeScript
25 lines
No EOL
682 B
TypeScript
import { createAuthEndpoint, getSessionFromCtx } from "better-auth/api";
|
|
import { z } from "zod";
|
|
import { postContentSchema } from "../social";
|
|
|
|
export const createPost = createAuthEndpoint("/social/posts", {
|
|
method: "POST",
|
|
body: postContentSchema,
|
|
}, async (context) => {
|
|
const content = context.body;
|
|
const user = getSessionFromCtx(context)
|
|
|
|
if (!user) {
|
|
return context.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
console.log(content);
|
|
return context.json({ message: "Hello, world!" }, { status: 200 });
|
|
});
|
|
|
|
export const getPost = createAuthEndpoint("/social/posts/:id", {
|
|
method: "GET",
|
|
params: z.object({
|
|
id: z.string(),
|
|
}),
|
|
}, async (context) => { }) |