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

View file

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

View file

@ -3,7 +3,7 @@ title: Actionable Values
description: '' description: ''
category: studio-development category: studio-development
tags: [] tags: []
accessLevel: member accessLevel: public
author: Weird Ghosts author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.621Z' 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. description: A business plan is a critical document for impact-oriented studios.
category: strategy category: strategy
tags: [] tags: []
accessLevel: member accessLevel: public
author: Baby Ghosts author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.221Z' publishedAt: '2025-11-10T10:42:09.221Z'
--- ---

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ title: Expo Tips
description: '' description: ''
category: strategy category: strategy
tags: [] tags: []
accessLevel: member accessLevel: public
author: Baby Ghosts author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.230Z' 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 description: Introduction to financial modelling for game development cooperatives
category: strategy category: strategy
tags: [] tags: []
accessLevel: member accessLevel: public
author: Jennie author: Jennie
publishedAt: 2025-11-10T10:42:09.224Z publishedAt: 2025-11-10T10:42:09.224Z
--- ---

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ title: Publisher Contract Review
description: '' description: ''
category: strategy category: strategy
tags: [] tags: []
accessLevel: member accessLevel: public
author: Baby Ghosts author: Baby Ghosts
publishedAt: '2025-11-10T10:42:09.229Z' 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. description: A step-by-step guide to creating a results flow for your indie game studio.
category: impact category: impact
tags: [] tags: []
accessLevel: member accessLevel: public
author: Weird Ghosts author: Weird Ghosts
publishedAt: '2025-11-10T10:52:42.626Z' publishedAt: '2025-11-10T10:52:42.626Z'
--- ---

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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