{"id":25205106,"url":"https://github.com/weihomechen/blog-node","last_synced_at":"2025-07-25T05:37:49.540Z","repository":{"id":42108779,"uuid":"143272500","full_name":"weihomechen/blog-node","owner":"weihomechen","description":"一个博客全栈应用的node服务端，前端部分传送门 https://github.com/weihomechen/blog","archived":false,"fork":false,"pushed_at":"2023-01-05T03:14:13.000Z","size":1325,"stargazers_count":13,"open_issues_count":16,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T01:38:16.044Z","etag":null,"topics":["blog","eggjs","mysql","node","nodejs","react","web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weihomechen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-02T09:25:07.000Z","updated_at":"2021-10-20T10:51:35.000Z","dependencies_parsed_at":"2023-02-03T08:01:06.795Z","dependency_job_id":null,"html_url":"https://github.com/weihomechen/blog-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weihomechen/blog-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihomechen%2Fblog-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihomechen%2Fblog-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihomechen%2Fblog-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihomechen%2Fblog-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weihomechen","download_url":"https://codeload.github.com/weihomechen/blog-node/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihomechen%2Fblog-node/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266962231,"owners_count":24012994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blog","eggjs","mysql","node","nodejs","react","web"],"created_at":"2025-02-10T09:18:50.701Z","updated_at":"2025-07-25T05:37:49.515Z","avatar_url":"https://github.com/weihomechen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blog-node\n\n本项目是博客全栈应用的服务端部分\n\n[![Build Status](https://travis-ci.com/weihomechen/blog-node.svg?branch=master)](https://travis-ci.com/weihomechen/blog-node)\n\n## 前端部分\n\n### React实现\n\n[前端传送门](https://github.com/weihomechen/blog)\n\n在线地址：[rulifun.cn/blog](http://rulifun.cn/blog)\n\n### Vue实现(开发ing)\n\n[前端传送门](https://github.com/weihomechen/vue-blog)\n\n在线地址：[rulifun.cn/vue-blog](http://rulifun.cn/vue-blog)\n\n\n## 关于全栈博客\n\n该项目是一个web全栈应用，前后端分离，是笔者第一次进入服务端（node）领域的尝试。集成前端React（Vue），后端Node，数据库Mysql，缓存Redis，消息推送，文件上传，密码加密，数据存储，性能监控等功能或模块，涵盖开发、mock、proxy、生产部署、线上监控等流程，适合有一定基础的前端er入门node，体验下web全栈开发，如果能帮助到你再好不过了，希望顺手点个star哈😄。\n\n## Quick Start\n\n### 开始之前\n\n该项目使用了mysql，运行前请先装好mysql\n\n#### 安装包安装mysql\n\n[mysql下载地址](https://dev.mysql.com/downloads/mysql/)，下载后跟dmg安装方法一样，一路向下，记得保存最后弹出框中的密码（它是你mysql root账号的密码）。此时只是安装成功，但还需要额外的配置：\n\n* 进入系统偏好设置\n* 点击mysql\n* 开启mysql服务\n\n此时我们在命令行输入mysql -uroot -p命令会提示没有commod not found，我们还需要将mysql加入系统环境变量。\n\n```bash\n# (1).进入/usr/local/mysql/bin,查看此目录下是否有mysql。\n# (2).执行vi ~/.bash_profile, 在该文件中添加mysql/bin的目录，即在最后一行添加下面这句话：\n# PATH=$PATH:/usr/local/mysql/bin\n# 添加完成后，按esc，然后输入wq保存。\n# 最后在命令行输入\nsource ~/.bash_profile\n```\n\n如果使用第三方bash工具需要编辑相应的配置文件，比如`zsh`，需要编辑 `.zshrc` 文件:\n\n```bash\nvim ~/.zshrc;\n# 粘贴以下内容\nalias mysql='/usr/local/mysql/bin/mysql'\nalias mysqladmin='/usr/local/mysql/bin/mysqladmin'\n```\n\n现在就可以通过mysql -uroot -p登录mysql了，会让你输入密码。\n\n#### 命令行安装mysql\n\n如果没有安装homebrew先安装homebrew：\n\n```sh\n/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\n使用homebrew安装mysql：\n\n```\nbrew install mysql\n```\n\nlinux使用yum:\n\n```\nyum install mysql\n```\n\n#### 初始化数据库\n\n成功安装`mysql`后，在命令行执行下面这个命令自动初始化：\n\n```sh\n# cd到blog-node项目目录\nmysql -u[username] -p[password] \u003c ./dbsql/db.sql\n```\n\n`./db.sql`即为项目根目录下的`db.sql`文件在当前目录下的相对路径，以下同。\n\n如果是累计更新，需要执行到最新的sql文件（新旧按文件名中的日期排）；\n\n如果是第一次初始化，可以执行总的sql文件：\n\n```sh\nmysql -u[username] -p[password] \u003c ./dbsql/db-full.sql\n```\n\n### 开始使用\n\n安装依赖\n```\ncnpm i\n```\n\n本地开发\n```\nnpm start\n```\n\n如果没有报错，项目就会运行在 [127.0.0.1:7001](http://127.0.0.1:7001)\n\n## 目录结构\n\n```\n├── README.md\n├── app             // 后台部分\n│   ├── controller  // 处理业务逻辑\n│   ├── extend\n│   ├── io          // socket io\n│   ├── middleware  // 中间件\n│   ├── public      // 静态资源\n│   ├── router.js   // 服务端的路由\n│   ├── service     // 负责和数据库/其他服务器的交互\n│   ├── utils       // 工具\n│   └── view        // 页面模版\n├── config          // egg配置文件\n├── logs            // 运行日志\n├── node_modules\n├── package.json\n├── run\n├── test\n└── db.sql          // 数据库表设计\n```\n\n## 前端的结构和流程\n\n```\n.\n├── README.md\n├── config                  // 配置文件\n│   ├── config.js           // 构建配置\n│   ├── menu.config.js      // 菜单配置\n│   ├── plugin.config.js    // 插件配置\n│   ├── project.config.js   // 项目配置\n│   └── router.config.js    // 路由配置\n├── dist              \n├── lib\n│   └── iconFont.js\n├── package-lock.json\n├── package.json\n├── src\n│   ├── app.ts              // 入口文件\n│   ├── common              // 通用代码\n│   ├── components          // 无状态组件（原则上）\n│   ├── global.css          // 全局样式\n│   ├── layouts             // 布局\n│   ├── models              // 状态管理\n│   ├── pages               // 页面路由\n│   ├── services            // 和服务端的交互\n│   └── utils               // 工具函数\n├── tsconfig.json\n├── tslint.yml\n└── typings.d.ts\n```\n\n前端路由(router) --\u003e 渲染路由组件(routes) --\u003e 状态管理、与后台交互，发起请求(models) --\u003e 后台对应路由配置进行处理(app) --\u003e 返回结果 --\u003e 前端接收后处理(models) --\u003e 状态的变化反应到UI上\n\n## 后台流程\n```\n├── controller      // 后台路由对应的处理函数\n│   ├── article.js\n│   └── client.js\n├── extend\n│   └── helper.js\n├── middleware      // 中间件\n├── public\n├── router.js       // 后台路由映射\n├── service         // 后台和数据库交互逻辑\n│   └── article.js\n└── view\n```\n收到请求（router） --\u003e 根据路由映射调用处理函数（controller） --\u003e 与数据库交互（service） --\u003e 返回结果（controller）\n\n## 生产部署\n\n先安装[deploy-tool](https://github.com/weihomechen/deploy-tool)到本地\n\n```\nnpm i @ifun/deploy -g\n```\n\n[deploy-tool说明](https://github.com/weihomechen/deploy-tool/blob/master/README.md)\n\n```sh\n# 部署node项目\ndeploy app \u003cname\u003e\n\n# 示例\ndeploy app blog-node\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihomechen%2Fblog-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweihomechen%2Fblog-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihomechen%2Fblog-node/lists"}