- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
import 'babel-polyfill'
import os from 'os'
import path from 'path'
import Koa from 'koa'
import cors from 'kcors'
import Router from 'koa-router'
import koaBody from 'koa-body'
import session from 'koa-session2'
import sessionStore from './middleware/datastore-session'
import * as render from './routes/render'
import * as api from './routes/api'
const serve = require('koa-static')
const app = new Koa()
const router = new Router()
const koabody = new koaBody({
multipart: true,
formidable: {uploadDir: os.tmpdir()}
})
const s = new sessionStore()
app
.use(cors())
.use(router.routes())
.use(session({
}))
.use(serve(__dirname + '/client-public'))
router
//.get('/', render.home.home)
.get('/foo', render.home.foo)
/*.get('/login', render.login.login)
.get('/dashboard', render.dashboard.home)
.get('/api/user/bars', api.user.getUserBars)
.get('/api/user/:id', session({}), api.user.getUserInfo)
.get('/api/user/bar/:id', api.user.getUserBar)
.post('/api/register', koabody, api.user.create)
.post('/api/login', koabody, api.user.login)*/
//.get('/[0-9]+', api.bar.serveBar)
app.listen(8080)