Compare commits

..

2 Commits

Author SHA1 Message Date
7312ab632c refactoring 2024-07-18 16:14:34 +02:00
e0377aeb00 fixed issue 2024-07-18 15:48:05 +02:00
3 changed files with 157 additions and 169 deletions

View File

@ -141,19 +141,9 @@ export async function tryCreateAttachment(request: Request) {
export async function tryFetchAttachments(request: Request) {
await Post.sync();
const foundPosts = await Post.findAll({
include: [
{
association: Post.associations.user,
attributes: { exclude: ["password", "createdAt", "updatedAt"] },
},
{
association: Post.associations.postTags,
},
],
});
const foundAttachments = await Attachment.findAll();
return new Response(JSON.stringify(foundPosts), { status: 200 });
return new Response(JSON.stringify(foundAttachments), { status: 200 });
}
export async function GET(request: Request) {

View File

@ -111,10 +111,10 @@ async function seedPosts(qif: SqliteQueryInterface<SqliteDialect>) {
where: {
readableIdentifier: "blog",
},
}).then((e) =>
e
? e
: Project.create({
}).then(
(project) =>
project ||
Project.create({
name: "General Blog",
readableIdentifier: "blog",
})
@ -174,9 +174,7 @@ export async function GET(request: Request) {
return new Response(
JSON.stringify({
test: await queryInterface
.describeTable("Posts")
.then((t) => t),
test: await queryInterface.describeTable("Posts").then((t) => t),
}),
{
status: 200,

View File

@ -38,9 +38,9 @@ export async function getPostsWithBucketsAndProject(): Promise<ActionResult<GetP
{association: Post.associations.project}],
nest: false
});
return {result:JSON.parse(JSON.stringify(posts.map((e:Post)=>{
return inspect(e)
})))};
return {result:posts.map((post:Post)=>{
return JSON.parse(JSON.stringify(post))
})};
}
export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> {