{"version":3,"file":"articles-CEGx-TVa.js","sources":["../../../../../src/services/articles.ts"],"sourcesContent":["\"use server\";\n\nimport { currentUserId } from \"./server\";\nimport * as articleRepo from \"~/repos/article\";\nimport { ArticleUpdate, NewArticle } from \"~/types\";\n\nexport const fetch = async (id: string) => {\n return await articleRepo.find(id);\n};\n\nexport const create = async (val: Omit) => {\n const authorId = await currentUserId();\n if (!authorId) throw \"user not authed\";\n\n await articleRepo.create({ ...val, authorId });\n};\n\nexport const update = async (\n id: string,\n { title, abstract, content, publishedAt }: ArticleUpdate\n) => {\n const authorId = await currentUserId();\n if (!authorId) throw \"user not authed\";\n\n await articleRepo.update(\n id,\n {\n title,\n abstract,\n content,\n publishedAt,\n },\n authorId\n );\n};\n\nexport const destroy = async (id: string) => {\n const authorId = await currentUserId();\n if (!authorId) throw \"user not authed\";\n await articleRepo.destroy(id, authorId);\n};\n"],"names":["fetch","createServerReference","create","update"],"mappings":"+pBACAA,MAAAA,EAAAC,EAAA,IAAA,CAAA,EAAA,SAAA,OAAA,EACaC,EAASD,EAAmB,IAAA,CAAA,EAAA,SAAA,QAAA,EAC5BE,EAASF,EAAsB,IAAG,CAAA,EAAA,SAAA,QAAA,EACxBA,EAAsB,IAAM,CAAC,EAAA,SAAA,SAAA"}