router.js 3.58 KB
/**
 * router of sub app channel
 * @author: Bi Kai<kai.bi@yoho.cn>
 * @date: 2016/05/09
 */

'use strict';

const express = require('express');
const cRoot = './controllers';
const star = require(cRoot + '/star');
const homeController = require(`${cRoot}/index`);
const plusstar = require(cRoot + '/plusstar');
const rewrite = require('../../doraemon/middleware/rewrite');

const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
const detail = require(cRoot + '/detail');
const plustar = require(cRoot + '/plustar');
const rss = require(cRoot + '/rss');
const brand = require(cRoot + '/brand-list');

const router = express.Router(); // eslint-disable-line

router.get('/star', star.index); // 星潮教室首页
router.get('/star/getIndexHtml', star.getIndexHtml); // 星潮教室首页
router.get('/star/detail', star.detail); // 明星文章专区
router.get('/star/detailList', star.detailList); // 明星文章专区文章Ajax请求
router.get('/star/special', star.special); // 星潮教室星专题
router.get('/star/collocation', star.collocation); // 星潮教室星搭配
router.get('/star/collocation/list', star.collocationList); // 星潮教室星搭配文章请求

router.post('/star/setFavorite', star.setFavorite); // 收藏文章
router.get('/', homeController.index); // 逛首页
// router.get(/^\/((boys)|(girls)|(kids)|(lifestyle)-[^\/]+)/, rewrite.resolve, homeController.index); // 逛首页 SEO优化

router.get('/plusstar', rewrite.channel, plusstar.indexRedirect); // 潮流优选
router.get(/^\/(.*?)-plusstar/, rewrite.resolve, plusstar.index); // 潮流优选 SEO优化
router.post('/plusstar/userSkn', plusstar.userSkn); // 用户推荐skn
router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
router.get('/', index.index); // 逛首页
router.get('/tags/index', index.tag); // 逛标签页

router.get('/author/index', rewrite.channel, index.editorRedirect); // 编辑简介
router.get(/^\/author-([^\/]+)/, rewrite.resolve, index.editor); // 编辑简介 SEO优化

router.get('/index/page', index.pageData); // 逛列表页面的资讯分页

router.post('/opt/praiseArticle', opt.praiseArticle); // 资讯文章点赞 (H5里显示点赞)
router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H5里显示收藏)
router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏

router.get('/info/index', rewrite.channel, detail.indexRedirect); // 逛详情页
router.get(/^\/info\/(.*?)\.html/, rewrite.resolve, detail.index); // 逛详情页 SEO优化

router.get('/:id.html', detail.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/info/mini', detail.mini); // 逛mini内容页
router.get('/info/foryoho', detail.foryoho); // 逛foryoho内容页

router.get('/plustar', plustar.getListData); // 国际优选列表页
router.get('/plustar/brandinfo', plustar.getDetailData); // 国际优选详情页
router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据

router.get('/rss/new', (req, res, next) => rss.rss(req, res, next, '')); // 订阅资讯
router.get('/rss/new-gmt', (req, res, next) => rss.rss(req, res, next, 'gmt')); // 订阅资讯
router.get(/^\/rss(\/\w+)?(\/\w+)?/, rss.index); // 订阅资讯

router.get('/info/listData', index.listDynamicData);
router.get('/info/detailData', index.detailDynamicData);

router.get('/plusstar/cate', brand.index);
router.get('/plusstar/brandList', brand.brandList);

module.exports = router;