diff --git a/src/models/menu.js b/src/models/menu.js index 6b2d4ef5..808cfa45 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -28,7 +28,7 @@ export default [ }, { "text": "Документы", - "url": "/docs", + "url": "/documents", "color": "yellow" } ] \ No newline at end of file diff --git a/src/routes/documents.js b/src/routes/documents.js index 2489a617..4ac26da9 100644 --- a/src/routes/documents.js +++ b/src/routes/documents.js @@ -1,42 +1,32 @@ -/** - * Created by tmshv on 22/11/14. - */ - import co from 'co'; import route from 'koa-route'; -import router from './'; +import {index, json} 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(); - } + 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(); - } + json(function *(type) { + this.body = yield db.c(type) + .find() + .toArray(); }) + ], + [ + '/document/:doc', + index('../templates/document.html') ] - ].forEach(item => { - //let {path, fn} = item; let [path, fn] = item; app.use(route.get(path, fn)); }); diff --git a/src/server.js b/src/server.js index 88e49ea0..b75f9fec 100644 --- a/src/server.js +++ b/src/server.js @@ -65,11 +65,6 @@ app.use(function *(next) { app.use(route.get('/', 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); schedule(app);