Spaces:
Running
Running
Update apps/storylines.js
Browse files- apps/storylines.js +19 -0
apps/storylines.js
CHANGED
|
@@ -221,6 +221,25 @@ router.get('/stories', async (req, res) => {
|
|
| 221 |
}
|
| 222 |
});
|
| 223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 225 |
// GET /storyline/stories/:story_id/chapters
|
| 226 |
// Fetch chapters for a story (public)
|
|
|
|
| 221 |
}
|
| 222 |
});
|
| 223 |
|
| 224 |
+
|
| 225 |
+
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 226 |
+
// ADMIN: GET /storyline/admin/stories
|
| 227 |
+
// Fetch ALL stories including drafts
|
| 228 |
+
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 229 |
+
router.get('/admin/stories', adminOnly, async (req, res) => {
|
| 230 |
+
try {
|
| 231 |
+
const { data, error } = await supabase
|
| 232 |
+
.from('storylines')
|
| 233 |
+
.select('id, title, description, cover_image, genre, published, created_at, updated_at')
|
| 234 |
+
.order('created_at', { ascending: false });
|
| 235 |
+
|
| 236 |
+
if (error) throw error;
|
| 237 |
+
res.json({ success: true, data });
|
| 238 |
+
} catch (err) {
|
| 239 |
+
res.status(500).json({ success: false, error: err.message });
|
| 240 |
+
}
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
// βββββββββββββββββββββββββββββββββββββββββββββ
|
| 244 |
// GET /storyline/stories/:story_id/chapters
|
| 245 |
// Fetch chapters for a story (public)
|