{"id":25102859,"url":"https://github.com/xxxsf/react-ssr","last_synced_at":"2025-04-13T09:50:47.619Z","repository":{"id":10224969,"uuid":"64915836","full_name":"xxxsf/react-ssr","owner":"xxxsf","description":"React 服务端渲染(SSR)，react + redux + koa2 + sequelize + mysql全栈项目(Full Stack)","archived":false,"fork":false,"pushed_at":"2023-02-24T21:48:27.000Z","size":11538,"stargazers_count":218,"open_issues_count":6,"forks_count":50,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-02-07T20:01:53.962Z","etag":null,"topics":["koa2","mysql","nodejs","pm2","react","redux","ssr"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xxxsf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-04T08:09:41.000Z","updated_at":"2025-01-19T12:12:17.000Z","dependencies_parsed_at":"2024-09-11T20:58:33.644Z","dependency_job_id":"3cc09a12-453f-4d06-a1c8-5d9e23826ffc","html_url":"https://github.com/xxxsf/react-ssr","commit_stats":null,"previous_names":["xxxsf/react-ssr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxxsf%2Freact-ssr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxxsf%2Freact-ssr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxxsf%2Freact-ssr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxxsf%2Freact-ssr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xxxsf","download_url":"https://codeload.github.com/xxxsf/react-ssr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695299,"owners_count":21146952,"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","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":["koa2","mysql","nodejs","pm2","react","redux","ssr"],"created_at":"2025-02-07T21:14:16.858Z","updated_at":"2025-04-13T09:50:47.599Z","avatar_url":"https://github.com/xxxsf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React 服务端渲染\n\n## 使用\n\n### 1、启动前端工程:\n前端开发目录为：client/\n```\nnpm i\nnpm start\n// 浏览器打开 http://localhost:8000/\n```\n\n### 2、启动服务端：\n客户端开发及部署在根目录\n\n```\nnpm i pm2 -g\nnpm i\nnpm start\n// 浏览器打开 http://localhost:3000/\n```\n\n### 3、启动 Mysql：\n- 先搭建 mysql 环境：官网下载mysql\n- 安装一个 mysql 的可视化工具，我选择的是：Navicat Premium\n\n启动mysql后，打开 mysql 可视化工具 Navicat Premium，\n- 连接数据库，账号密码在 `server/config/db.json`\n- 建表，本仓库提供了一份数据可以将 `mysql/user.sql` 直接导入\n\n\nDone!\n\n\n\n### 数据库如何操作？\n\n建立连接\nSequelize会在初始化时设置一个连接池，这样你应该为每个数据库创建一个实例：\n```\nvar sequelize = new Sequelize('database', 'username', 'password', {\n  host: 'localhost',\n  dialect: 'mysql'|'mariadb'|'sqlite'|'postgres'|'mssql',\n  pool: {\n    max: 5,\n    min: 0,\n    idle: 10000\n  },\n\n  // 仅 SQLite 适用\n  storage: 'path/to/database.sqlite'\n});\n\n// 或者可以简单的使用一个连接 uri\nvar sequelize = new Sequelize('postgres://user:pass@example.com:5432/dbname');\n```\n\n\n\n## 查看服务器日志\n```\npm2 log\n```\n\n## 项目结构\n```\n├── client 前端目录\n|\n├── mysql 数据库（第一次使用可以直接导入到本地）\n|\n├── public 服务器静态资源\n|\n└── server 后端目录\n    ├── auth 权限验证 存放用户验证部分\n    ├── config 数据库 配置文件 Sequelize（可以对多种数据库进行操作）\n    ├── controllers 后端控制层 C 层的代码存放目录\n    ├── models 操作 数据库 代码逻辑\n    ├── routes 后端路由\n    └── view 后端页面\n```\n\n### ps:\n- server/models\nModel相当于数据库中表，有时它也会被称为“模型”或“工厂”。`Model`不能通过构造函数创建，而只能通过`sequlize.define`方法来定义或通过`sequlize.import`导入。通过`define`定义一个`Model`，就相当于定义了一种模型与数据表之间的映射关系，通过模型可以实现对表记录的增、删、改、查等操作。\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxxsf%2Freact-ssr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxxxsf%2Freact-ssr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxxsf%2Freact-ssr/lists"}