Compare commits

..

No commits in common. "7312ab632c2954c6952de372b563b29a82f0151f" and "4a4813ae171e10b88687276b8e5b9c451f7f1f02" have entirely different histories.

3 changed files with 169 additions and 157 deletions

View File

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

View File

@ -111,10 +111,10 @@ async function seedPosts(qif: SqliteQueryInterface<SqliteDialect>) {
where: {
readableIdentifier: "blog",
},
}).then(
(project) =>
project ||
Project.create({
}).then((e) =>
e
? e
: Project.create({
name: "General Blog",
readableIdentifier: "blog",
})
@ -174,7 +174,9 @@ 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:posts.map((post:Post)=>{
return JSON.parse(JSON.stringify(post))
})};
return {result:JSON.parse(JSON.stringify(posts.map((e:Post)=>{
return inspect(e)
})))};
}
export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> {