Skip to content

Commit

Permalink
use proper publish date
Browse files Browse the repository at this point in the history
  • Loading branch information
spcbfr committed Mar 26, 2024
1 parent e3a3d2f commit b3bd02c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dayjs from "dayjs";
const Note = defineTable({
columns: {
content: column.text(),
published: column.number({ default: dayjs().unix() }),
published: column.number(),
},
});

Expand Down
5 changes: 3 additions & 2 deletions src/pages/api/micropub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ export async function POST({ request, site, url }: APIContext) {

if (hasOwnProperty(indieToken, "me") && indieToken.me === site?.toString()) {
// TODO: Create note here
const now = dayjs().unix();

console.log("hello world");
if (contentType === "application/x-www-form-urlencoded") {
if (!hasOwnProperty(formBodyObject, "content")) return Respond(422);

const records = await db
.insert(Note)
.values({ content: formBodyObject.content })
.values({ content: formBodyObject.content, published: now })
.returning();

return Respond(201, "Created", {
Expand All @@ -95,7 +96,7 @@ export async function POST({ request, site, url }: APIContext) {
if (typeof body.properties.content[0] === "string") {
const records = await db
.insert(Note)
.values({ content: body.properties.content[0] })
.values({ content: body.properties.content[0], published: now })
.returning();

return Respond(201, "Created", {
Expand Down

0 comments on commit b3bd02c

Please sign in to comment.