From 7d9f642b128877116fe81435564c56e6f71b9289 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 26 May 2017 01:39:05 +0300 Subject: [PATCH] home routes refactoring --- src/routes/home.js | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/routes/home.js b/src/routes/home.js index 57b85017..34398f18 100644 --- a/src/routes/home.js +++ b/src/routes/home.js @@ -1,39 +1,9 @@ const React = require('react') const Article = require('../components/Article') const {get} = require('koa-route') -const {c} = require('../core/db') const getArticleListComponent = require('./articles').getArticleListComponent const {render} = require('../lib/render') const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash -const timestamp = require('../lib/date').timestamp -const {sortBy} = require('../utils/sort') - -const sortArticleByDate = sortBy( - i => timestamp(new Date(i.date)) -) - -const articleUrl = article => `/article/${article.id}` - -async function findArticlesNin(nin, skip, limit, sort) { - return c('articles') - .find({ - _id: {$nin: nin} - }) - .sort(sort) - .skip(skip) - .limit(limit) - .toArray() -} - -async function findPinned(page) { - const now = new Date() - return page !== 1 - ? [] - : await c('articles') - .find({until: {$gte: now}}) - .sort({date: -1}) - .toArray() -} function getMeta(article) { return {