const router = require('koa-router')()
const project = require('project')
const koaBody = require('koa-body')()
const path = require('path')
const serve = require('koa-static')(path.resolve(''))

// router.redirect('/', 'index.html');
router.get('/', function * () {
  this.redirect('index.html')
})

router.get('/projects/:project/src/:file', function * () {
  yield serve
})

router.post('/projects/:project/src/:file', koaBody, function * () {
  this.body = yield project.uploadInline(this.params.project, this.params.file, this.request.body.content)
  this.status = 202
})

router.get('/projects', function * () {
  this.body = yield project.listProjects(this.params.project)
})

router.get('/projects/:project', function * () {
  this.body = yield project.listInlines(this.params.project)
})

export default router

const router = require('koa-router')()
const project = require('project')
const koaBody = require('koa-body')({
  jsonLimit: '10mb'
})
const path = require('path')
const serve = require('koa-static')(path.resolve(''))

// router.redirect('/', 'index.html');
router.get('/', function * () {
  this.redirect('index.html')
})

router.get('/projects/:project/src/:file', function * () {
  yield serve
})

router.post('/projects/:project/src/:file', koaBody, function * () {
  this.body = yield project.uploadInline(this.params.project, this.params.file, this.request.body.content)
  this.status = 202
})

router.get('/projects', function * () {
  this.body = yield project.listProjects(this.params.project)
})

router.get('/projects/:project', function * () {
  this.body = yield project.listInlines(this.params.project)
})

export default router

increase upload file size limit