Created
June 29, 2017 15:27
-
-
Save ndugger/f6b39a62d56b20ac3809d75652f21153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import router from 'redshirt'; | |
| import { admin, body } from '../middleware'; | |
| import { db, json, slugify } from '../util'; | |
| router.group('/forums/categories') | |
| .get('/', async () => { | |
| return json(await db.forums.categories.all()); | |
| }) | |
| .post('/', [ admin, body ], async request => { | |
| const category = JSON.parse(request.body.toString()); | |
| const slug = slugify(category.title); | |
| const created = await db.forums.categories.create({ ...category, slug }); | |
| return json(created); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment