+ documents router; other
This commit is contained in:
1 parent
56c1c9dffc
commit
fb0ae8148c
2 files changed
+49
-4
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Created by tmshv on 22/11/14.
|
||||
*/
|
||||
|
||||
import co from 'co';
|
||||
import route from 'koa-route';
|
||||
import router from './';
|
||||
import db from '../core/db';
|
||||
|
||||
export default function (app) {
|
||||
[
|
||||
[
|
||||
'/documents',
|
||||
router.accepts({
|
||||
'text/html': router.index(),
|
||||
'text/plain': router.index(),
|
||||
'application/json': function *() {
|
||||
let query = {};
|
||||
this.body = yield db.c('documents')
|
||||
.find(query)
|
||||
.toArray();
|
||||
}
|
||||
})
|
||||
],
|
||||
[
|
||||
'/documents/:type',
|
||||
router.accepts({
|
||||
'text/html': router.index(),
|
||||
'text/plain': router.index(),
|
||||
'application/json': function *(type) {
|
||||
this.body = yield db.c(type)
|
||||
.find()
|
||||
.toArray();
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
].forEach(item => {
|
||||
//let {path, fn} = item;
|
||||
let [path, fn] = item;
|
||||
app.use(route.get(path, fn));
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user