Code Monkey home page Code Monkey logo

egg-cnode's People

Contributors

alsotang avatar atian25 avatar debiancc avatar fengmk2 avatar forl avatar iyuq avatar jacksontian avatar lqs469 avatar nanzm avatar ngot avatar npmmirror avatar pseudocowboy avatar rickyes avatar sinchang avatar thonatos avatar xgheaven avatar xiaomuzhu avatar yeungkc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egg-cnode's Issues

首页topics数量问题

现在的 cnodejs.org 每页显示是40个帖子,新版这边为什么改成20个了?
40个帖子比较能够对齐右边栏,20个的时候左侧有较大空白区域。

目前存在的登录问题

  1. https://cnodejs.org/signin 登录页面随便输入账号名密码,点击登录没有任何反映
  2. github在https://github.com/settings/profile 如果没有展示public email的话,登录会直接500,没有正确提示。并且当 email 和 用户名重复时,也需要有明确提示。参见 app.js 中的 githubHandler
  3. 找回密码收不到邮件

已经修复的问题,新用户 accessToken 的生成逻辑完善。空白 accessToken 用户通过 bin/generate_access_token.js 来补充。

鉴于以上问题都挺严重的,建议回滚老版本。

问题2的github登录问题,我尝试了几个方式,都没法拿到 githubHandler 中的错误信息,导致外层没数据作出正确响应。这个 passport 库的封装挺神奇的。本来 passport.js 是为 express 那套中间件所写,eggjs在上面包了一层逻辑,不过对于错误的抛出应该给出更明确的指导。

线上项目 egg-passport-github 总是提示redirect_uri_mismatch

  • Node Version:
    8.9.4-alpine
  • Egg Version:
    ^2.2.1
  • Plugin Name:
    egg-passport-github
  • Plugin Version:
    ^1.0.0
  • Platform:
    ubuntu
  • Mini Showcase Repository:
    egg-passport-github作如下配置:
  config.passportGithub = {
    key: process.env.EGG_PASSPORT_GITHUB_CLIENT_ID,
    secret: process.env.EGG_PASSPORT_GITHUB_CLIENT_SECRET,
    callbackURL: 'https://eosdevs.io/passport/github/callback',
  };

这里保证keysecret没有问题, callbackURL在github中配置如下:
image
https://eosdevs.io/passport/github/callback,
但是线上项目https://eosdevs.io的使用github登陆总是提示redirect_uri_mismatch
经过抓包发现,
image
期望能得到解答。

关于Search 搜索

关于搜索alsotang大神坚持谷歌最好,但是国内翻墙不方便,能否加个 百度的 ,检测到被墙切换到百度。实现双站切换。当然如果练习node,最好做个本站搜索 如何分词什么的 。
exports.index = function (req, res, next) {
var q = req.query.q;
q = encodeURIComponent(q);
q1='+q+'&q2=&q3=&q4=&rn=10&lm=0&ct=0&ft=&q5=&q6=plmclub.org&tn=baiduadv');
res.redirect('https://cnodejs/cse/search?q='+q+'&s=6701441402440425312&nsid=0');

};

[TODO] egg-validate 集成

// old
const title = validator.trim(ctx.body.title);
const tab = validator.trim(ctx.body.tab);
const content = validator.trim(ctx.body.t_content);

let editError;
if (title === '') {
  editError = '标题不能是空的。';
} else if (title.length < 5 || title.length > 100) {
  editError = '标题字数太多或太少。';
} else if (content === '') {
  editError = '内容不可为空';
}

// egg-validate
const RULE_CREATE = {
  title: {
    type: 'string',
    required: true,
    max: 100,
    min: 5,
  },
  content: {
    type: 'string',
    required: true,
  },
};

class TemplateController extends Controller {
  async create() {
    const { ctx } = this;
    ctx.logger.debug(ctx.request.body);
    ctx.validate(RULE_CREATE, ctx.request.body);
    // ...
  }
}

反馈一个用户登录的问题

我的cnodejs账号是直接通过github登录的,之前因为清理github的项目问题,直接把github账号删除了,然后重新建立了一个新的github账号,名称跟以前一样,但是现在登录cnodejs的时候,没办法关联上了,就登录不了用户了。

Docker Hub 自动构建

项目中已经集成了 Dockerfile,是否考虑加上自动构建?

  • node 模块发布通常使用 npm 方式
  • cnode 作为 web 应用,在 dockerfile 基础上可以考虑使用镜像发布
  • shields.io 包含 docker 相关 badges

Docker Automated build Docker Stars Docker pulls

关于 loader 的疑问

为什么clone下项目,运行npm run start 的时候 ,页面 js 和 css 没有加载进来,是我缺少了什么步骤吗 (npm run dev 没问题 页面是正常的 ,已经运行了 npm run assets 同时生成了 assets.json ,代码方面只修改了 redis mongo 配置 )

前端 eslint

目前前端代码(app/public) 部分是 ignore 了。

要开启下,在 app/public/.eslintrc 里面继承 eslint-config-egg 定制一些规则即可

本地开发说明

  • 提供 dockerfile 用于本地 test-local 测试
  • 修改 README 补充本地开发调试指南

迁移总结

gist $ ./cloc-git https://github.com/cnodejs/nodeclub.git

     194 text files.
     194 unique files.                                          
      12 files ignored.

github.com/AlDanial/cloc v 1.76  T=1.09 s (170.3 files/s, 66779.9 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
JavaScript                     125           6577          10539          34314
CSS                             11           2528            101          14147
HTML                            43            300              9           2266
LESS                             1            220             12           1085
Markdown                         2             30              0            238
JSON                             1              0              0             69
make                             1             13              1             47
YAML                             1              8              0             21
-------------------------------------------------------------------------------
SUM:                           185           9676          10662          52187
-------------------------------------------------------------------------------
gist $ ./cloc-git https://github.com/cnodejs/egg-cnode.git


     154 text files.
     154 unique files.                                          
      12 files ignored.

github.com/AlDanial/cloc v 1.76  T=1.08 s (133.7 files/s, 64530.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
JavaScript                      87           6306          10269          32023
CSS                             11           2528            101          14147
HTML                            38            259              9           2185
LESS                             1            221             12           1088
Markdown                         2             45              0            115
YAML                             3              7              6             94
JSON                             1              0              0             67
Dockerfile                       1              8              1              8
-------------------------------------------------------------------------------
SUM:                           144           9374          10398          49727
-------------------------------------------------------------------------------

Summary:

  • 文件数减少 41,减少 22%
  • 代码行数减少 2460 行,减少 4.7%
  • 测试代码减少 980 行,减少 39%,覆盖率高于原项目。

关于站内搜索的feature

cnode的egg公测帖子上有一个关于添加站内搜索的反馈
大家看是否要支持一下这个需求?
我的想法是分三个主要搜索选项:

  • 谷歌
  • 百度
  • 本地数据
    • 搜索用户名
    • 搜索帖子名

里面可能涉及新页面设计, 风格上当然保持和原有一致.
大家觉得怎么样?

使用docker-compose 启动失败 MongoError

环境:

  1. 操作系统: CentOS Linux release 7.2.1511 (Core)
  2. docker: Docker version 18.03.0-ce, build 0520e24
  3. docker-compose: docker-compose version 1.20.1, build 5d8c71b

描述

修改docker-compose.yml

开启 redis 和mongo 默认端口设置 6379 和 27017

     redis:
    image: redis:3.2-alpine
    command: redis-server --appendonly yes --requirepass egg_cnode
    volumes:
      - egg-redis:/data
    networks:
      - docker_cnode
    ports:
      - 6379:6379

  mongodb:
    image: mongo:3.2
    restart: always
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=mongodb
      - MONGO_INITDB_DATABASE=egg_cnode
    volumes:
      - egg-mongo:/data/db
      - ./init.d/mongo:/docker-entrypoint-initdb.d
    networks:
      - docker_cnode
    ports:
      - 27017:27017

执行 docker-compose up -d 命令

[root@VM_0_11_centos egg-cnode]# docker-compose up -d
Creating network "eggcnode_docker_cnode" with driver "bridge"
Creating volume "eggcnode_egg-mongo" with default driver
Creating volume "eggcnode_egg-redis" with default driver
Creating eggcnode_mongodb_1 ... done
Creating eggcnode_redis_1   ... done
Creating eggcnode_cnode_1   ... done

查看容器eggcnode_cnode_1 日志

2018-04-08 07:07:18,978 INFO 42 [egg:core:ready_stat] end ready task /usr/src/app/node_modules/egg-core/lib/egg.js:319:10, remain ["/usr/src/app/node_modules/egg-watcher/app.js:15:7","/usr/src/app/node_modules/egg-redis/lib/redis.js:48:7","/usr/src/app/node_modules/egg-mongoose/lib/mongoose.js:74:7"]
2018-04-08 07:07:18,985 ERROR 42 [egg-mongoose] mongodb://egg_cnode:egg_cnode@mongodb:27017/egg_cnode disconnected
2018-04-08 07:07:18,987 INFO 42 [egg-redis] connect success on redis://:egg_cnode@redis:6379/0
2018-04-08 07:07:18,991 ERROR 42 nodejs.MongoError: [egg-mongoose]failed to connect to server [mongodb:27017] on first connect [MongoError: connect ECONNREFUSED 172.19.0.2:27017]
    at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:336:35)
    at emitOne (events.js:116:13)
    at Pool.emit (events.js:211:7)
    at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:280:12)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:189:49)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

name: 'MongoError'
message: '[egg-mongoose]failed to connect to server [mongodb:27017] on first connect [MongoError: connect ECONNREFUSED 172.19.0.2:27017]'
pid: 42
hostname: ee66c1c8cd4f

排查

链接mongodb数据库进行测试

[root@VM_0_11_centos egg-cnode]# mongo 172.19.0.2:27017/egg_cnode -u egg_cnode -p egg_cnode
MongoDB shell version: 3.2.19
connecting to: 172.19.0.2:27017/egg_cnode
> show collections
egg_cnode
> db.egg_cnode.find({})
{ "_id" : ObjectId("5ac9bfa4cdf6538a02662544"), "egg_cnode" : "egg-cnode" }

在centos 中可以正常访问 172.19.0.2:27017/egg_cnode 库

备注

本人 docker 和 docker-compose 知识有限,目前使用遇到如上问题,还望大神帮忙答疑解惑

npm run assets 出现错误

环境:centos:7.2

[email protected] assets /root/egg-cnode
loader app/view app/

Scaned. 3 asset(s) will be build.
Building... /public/editor.min.js
processing... /public/libs/editor/editor.js ..build .. use 3692ms.
processing... /public/libs/webuploader/webuploader.withoutimage.js ..build .. use 1519ms.
processing... /public/libs/editor/ext.js ..build .. use 53ms.
✔ Done. Build time 5271 ms.
Building... /public/stylesheets/index.min.css
processing... /public/libs/bootstrap/css/bootstrap.css ..build .. use 436ms.
processing... /public/stylesheets/common.css ..build .. use 4ms.
processing... /public/stylesheets/style.less ..build .. use 142ms.
processing... /public/stylesheets/responsive.css ..build .. use 36ms.
processing... /public/stylesheets/jquery.atwho.css ..build .. use 2ms.
processing... /public/libs/editor/editor.css ..build .. use 45ms.
processing... /public/libs/webuploader/webuploader.css ..build .. use 1ms.
processing... /public/libs/code-prettify/prettify.css ..build .. use 15ms.
processing... /public/libs/font-awesome/css/font-awesome.css ..build .. use 25ms.
✔ Done. Build time 709 ms.
Building... /public/index.min.js
processing... /public/libs/jquery-2.1.0.js ..build .. use 1827ms.
processing... /public/libs/lodash.compat.js ..build .. use 1291ms.
processing... /public/libs/jquery-ujs.js ..build .. use 82ms.
processing... /public/libs/bootstrap/js/bootstrap.js ..build .. use 339ms.
processing... /public/libs/jquery.caret.js ..build .. use 83ms.
processing... /public/libs/jquery.atwho.js ..build .. use 202ms.
processing... /public/libs/markdownit.js ..build .. use 1057ms.
processing... /public/libs/code-prettify/prettify.js ..build .. use 159ms.
processing... /public/libs/qrcode.js ..build .. use 430ms.
processing... /public/javascripts/main.js ..build .. use 11ms.
processing... /public/javascripts/responsive.js ..build .. use 23ms.
✔ Done. Build time 5516 ms.
🏁 Compile static assets done. Build time 11506 ms.
assets.json is here: /root/egg-cnode/app/assets.json
fs.js:124
throw new ERR_INVALID_CALLBACK();
^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:124:9)
at Object.fs.writeFile (fs.js:1244:14)
at Object. (/root/egg-cnode/node_modules/loader-builder/bin/builder:49:4)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:575:3)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] assets: loader app/view app/
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] assets script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-05-06T01_40_37_539Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.