Make all articles public

This commit is contained in:
Jennie Robinson Faber 2025-11-15 13:52:12 +00:00
parent 555b200ec7
commit ef432e3f74
23 changed files with 53 additions and 52 deletions

View file

@ -1,36 +1,36 @@
import { Article } from '../../models/Article'
import { requireAuth } from '../../utils/auth'
import { Article } from "../../models/Article";
import { requireAuth } from "../../utils/auth";
export default defineEventHandler(async (event) => {
// Require authentication
const user = await requireAuth(event)
const user = await requireAuth(event);
// Check if user can create articles
if (!user.permissions.canEdit) {
throw createError({
statusCode: 403,
statusMessage: 'You do not have permission to create articles'
})
statusMessage: "You do not have permission to create articles",
});
}
// Get request body
const body = await readBody(event)
const body = await readBody(event);
// Validate required fields
if (!body.title || !body.slug || !body.content) {
throw createError({
statusCode: 400,
statusMessage: 'Title, slug, and content are required'
})
statusMessage: "Title, slug, and content are required",
});
}
// Check if slug already exists
const existing = await Article.findOne({ slug: body.slug })
const existing = await Article.findOne({ slug: body.slug });
if (existing) {
throw createError({
statusCode: 409,
statusMessage: 'An article with this slug already exists'
})
statusMessage: "An article with this slug already exists",
});
}
// Create article
@ -38,34 +38,35 @@ export default defineEventHandler(async (event) => {
const article = await Article.create({
slug: body.slug,
title: body.title,
description: body.description || '',
description: body.description || "",
content: body.content,
category: body.category || 'general',
category: body.category || "general",
tags: body.tags || [],
accessLevel: body.accessLevel || 'member',
accessLevel: body.accessLevel || "public",
cohorts: body.cohorts || [],
author: user.userId,
status: body.status || 'draft',
publishedAt: body.status === 'published' ? new Date() : null,
revisions: [{
content: body.content,
author: user.userId,
message: 'Initial creation',
createdAt: new Date()
}]
})
status: body.status || "draft",
publishedAt: body.status === "published" ? new Date() : null,
revisions: [
{
content: body.content,
author: user.userId,
message: "Initial creation",
createdAt: new Date(),
},
],
});
return {
success: true,
slug: article.slug,
message: 'Article created successfully'
}
message: "Article created successfully",
};
} catch (error) {
console.error('Error creating article:', error)
console.error("Error creating article:", error);
throw createError({
statusCode: 500,
statusMessage: 'Failed to create article'
})
statusMessage: "Failed to create article",
});
}
})
});

View file

@ -3,7 +3,7 @@ title: Actionable Steam Metrics
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.227Z'
---

View file

@ -3,7 +3,7 @@ title: Actionable Values
description: ''
category: studio-development
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.621Z'
---

View file

@ -3,7 +3,7 @@ title: Business Planning
description: A business plan is a critical document for impact-oriented studios.
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.221Z'
---

View file

@ -3,7 +3,7 @@ title: Canada Council Funding
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.229Z'
---

View file

@ -3,7 +3,7 @@ title: CMF Quick Tips
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.229Z'
---

View file

@ -3,7 +3,7 @@ title: Co-op Structure
description: ''
category: studio-development
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.623Z'
---

View file

@ -3,7 +3,7 @@ title: Decisions and Conflict
description: ''
category: studio-development
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.624Z'
---

View file

@ -3,7 +3,7 @@ title: Expo Tips
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.230Z'
---

View file

@ -3,7 +3,7 @@ title: Financial modelling
description: Introduction to financial modelling for game development cooperatives
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Jennie
publishedAt: 2025-11-10T10:42:09.224Z
---

View file

@ -3,7 +3,7 @@ title: Game Discovery Toolkit
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.227Z'
---

View file

@ -5,7 +5,7 @@ description: >-
indie game studio.
category: impact
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.627Z'
---

View file

@ -3,7 +3,7 @@ title: Market Analysis
description: Market Analysis
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.226Z'
---

View file

@ -3,7 +3,7 @@ title: Pitching to Publishers
description: Pitching to Publishers
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.228Z'
---

View file

@ -3,7 +3,7 @@ title: Process Development
description: ''
category: studio-development
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.624Z'
---

View file

@ -3,7 +3,7 @@ title: Publisher Contract Review
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.229Z'
---

View file

@ -3,7 +3,7 @@ title: Results Flow
description: A step-by-step guide to creating a results flow for your indie game studio.
category: impact
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.626Z'
---

View file

@ -3,7 +3,7 @@ title: Schedule
description: ''
category: programs
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.231Z'
---

View file

@ -3,7 +3,7 @@ title: Self-Assessment
description: ''
category: programs
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.231Z'
---

View file

@ -3,7 +3,7 @@ title: Stages of Coop Development
description: ''
category: programs
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.232Z'
---

View file

@ -3,7 +3,7 @@ title: Structures for Impact
description: ''
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.223Z'
---

View file

@ -3,7 +3,7 @@ title: Telling Your Story
description: ''
category: studio-development
tags: []
accessLevel: member
accessLevel: public
author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.625Z'
---

View file

@ -3,7 +3,7 @@ title: TikTok Meeting Notes
description: 'TikTok Marketing Meeting: July 3, 2023'
category: strategy
tags: []
accessLevel: member
accessLevel: public
author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.230Z'
---