{"id":21561894,"url":"https://github.com/easonzero/itoneserver","last_synced_at":"2025-03-18T04:47:39.235Z","repository":{"id":112072397,"uuid":"77932354","full_name":"Easonzero/ItoneServer","owner":"Easonzero","description":"A  server of resource platform by express","archived":false,"fork":false,"pushed_at":"2017-01-08T15:17:57.000Z","size":43571,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T11:32:01.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Easonzero.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-03T16:09:38.000Z","updated_at":"2017-01-03T16:10:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5b1545c-6eef-463a-9b03-0008314980d2","html_url":"https://github.com/Easonzero/ItoneServer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FItoneServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FItoneServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FItoneServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FItoneServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Easonzero","download_url":"https://codeload.github.com/Easonzero/ItoneServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244159990,"owners_count":20408019,"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":[],"created_at":"2024-11-24T09:29:10.830Z","updated_at":"2025-03-18T04:47:39.214Z","avatar_url":"https://github.com/Easonzero.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ItoneServer\nA  server of resource platform by express\n本项目是通过express框架构建的一个资源平台服务器\n\n## 项目结构\n\n- bin\t\t\texpress生成的文件夹，存放一些框架初始化的代码，不用管\n- common\t\tcommon文件夹存放的是项目一些需要全局初始化的代码，比如任务和异常\n- controllers\t\tcontrollers文件夹存放的控制器，处理具体的业务逻辑\n- interface\t\tinterface文件夹是无用的文件夹，本打算是为校园接口设计的模块，暂时没需求就放置了。\n- node_modules\t\tnode第三方模块文件夹\n- proxy\t\t\tproxy文件夹存放的是代理，用来隔离controller和数据库的交互。\n- public\t\tpublic文件夹存放的是静态文件，比如图书，图片，html，js，css等\n- routes\t\troutes文件夹存放的是路由文件，这个文件夹下的文件会被根目录的routes.js文件所调用，所有请求会通过路由被分发到不同的controller执行相应的业务逻辑\n- task\t\t\ttask文件夹存放的是任务文件，定时执行一些业务逻辑\n- test\t\t\ttest文件夹存放的是测试文件，测试文件在其子文件夹controllers中。\n- utils\t\t\tutils文件夹存放的是一些静态工具文件，包括日期格式化工具，下载工具，短信工具和数据库工具\n- views\t\t\texpress生成的文件夹，存放的是模板文件，由于前端人员估计不会jade等node常用模板语言，这个文件夹没什么意义\n\n## 项目架构简述\n\n整个架构基于分层架构，项目大致由4类中间件组成，每一类中间件即是一层，分别是：\n* 过滤器，在routes中的中间件，对所有请求进行过滤，可以用来进行权限控制的事务，并对请求进行分发。\n* 控制器，在controllers中的中间件，对具体的请求进行业务处理，调用不同的代理执行相应的业务需求。\n* 代理，在proxy中的中间件，连接数据库，对数据库进行增删改查的操作，并对上层返回相应数据。\n* 底层接口及静态数据，该层是可以被复用的底层服务接口或者静态数据，包括数据库接口，短信对接接口，全局变量等。\n**添加一条api的流程\n* 在proxy中添加代理，处理该api涉及的数据库访问操作。\n* 在controllers中添加控制器，调用此前创建的代理，处理该api涉及的业务逻辑。\n* 将api的url分为两部分，即‘host:port/(1)/(2)’，增加的api如果在(1)部分是新的，那么需要在routes文件夹中添加路由，并将这个路由在根目录的routes文件中声明。增加的api如果在(2)部分是新的，那么只需要修改routes文件夹中相应的路由即可。\n\nps.由此可见，routes文件夹下的各个路由可以看做是项目的api汇总。\n\n## 测试\n\n测试基于mocha框架，可以自动化的测试所有api，test文件夹下有 /controllers，/sup，mocha.opts, test.js。其中test.js是测试入口文件，会调用controllers文件夹下的所有测试文件，/controllers文件夹中是对api的具体测试文件，模拟http请求，并输出返回的结果。模拟http请求的操作我进行了封装，放在了sup文件夹，使用方式参照那些测试用例的使用方式即可。\n\n写好测试用例之后只需要在根目录使用mocha命令即可。\n\n## 部署\n\n部署采用pm2进行管理\n* 将config文件中的数据库参数切换至远程服务器的数据库参数（即密码为wangyi601466673的那组参数）。\n* 通过git提交到coding\n* 通过ssh连接到远程服务器\n* 远程先后使用如下命令\n1. git pull origin master，如果结果有合并异常，说明有log文件被上传，建议建立.gitignore文件，用来防止log等文件的提交\n2. pm2 restart 0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasonzero%2Fitoneserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasonzero%2Fitoneserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasonzero%2Fitoneserver/lists"}