/docs -> /documents; documents router refactoring
This commit is contained in:
1 parent
5244beecf8
commit
c426e5a8d8
3 files changed
+8
-23
No files matched your search
+1
-1
@@ -28,7 +28,7 @@ export default [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Документы",
|
"text": "Документы",
|
||||||
"url": "/docs",
|
"url": "/documents",
|
||||||
"color": "yellow"
|
"color": "yellow"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
+7
-17
@@ -1,42 +1,32 @@
|
|||||||
/**
|
|
||||||
* Created by tmshv on 22/11/14.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import co from 'co';
|
import co from 'co';
|
||||||
import route from 'koa-route';
|
import route from 'koa-route';
|
||||||
import router from './';
|
import {index, json} from './';
|
||||||
import db from '../core/db';
|
import db from '../core/db';
|
||||||
|
|
||||||
export default function (app) {
|
export default function (app) {
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'/documents',
|
'/documents',
|
||||||
router.accepts({
|
json(function *() {
|
||||||
'text/html': router.index(),
|
|
||||||
'text/plain': router.index(),
|
|
||||||
'application/json': function *() {
|
|
||||||
let query = {};
|
let query = {};
|
||||||
this.body = yield db.c('documents')
|
this.body = yield db.c('documents')
|
||||||
.find(query)
|
.find(query)
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'/documents/:type',
|
'/documents/:type',
|
||||||
router.accepts({
|
json(function *(type) {
|
||||||
'text/html': router.index(),
|
|
||||||
'text/plain': router.index(),
|
|
||||||
'application/json': function *(type) {
|
|
||||||
this.body = yield db.c(type)
|
this.body = yield db.c(type)
|
||||||
.find()
|
.find()
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'/document/:doc',
|
||||||
|
index('../templates/document.html')
|
||||||
]
|
]
|
||||||
|
|
||||||
].forEach(item => {
|
].forEach(item => {
|
||||||
//let {path, fn} = item;
|
|
||||||
let [path, fn] = item;
|
let [path, fn] = item;
|
||||||
app.use(route.get(path, fn));
|
app.use(route.get(path, fn));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,11 +65,6 @@ app.use(function *(next) {
|
|||||||
|
|
||||||
app.use(route.get('/', routes.index()));
|
app.use(route.get('/', routes.index()));
|
||||||
app.use(route.get('/team', routes.index()));
|
app.use(route.get('/team', routes.index()));
|
||||||
app.use(route.get('/docs', routes.index()));
|
|
||||||
|
|
||||||
app.use(route.get('/document/:doc', routes.index(
|
|
||||||
path.join(__dirname, 'templates/document.html')
|
|
||||||
)));
|
|
||||||
|
|
||||||
sitemap(app);
|
sitemap(app);
|
||||||
schedule(app);
|
schedule(app);
|
||||||
|
|||||||
Reference in new issue
Block a user