{"id":16977121,"url":"https://github.com/rickyes/polix","last_synced_at":"2026-04-10T12:31:28.117Z","repository":{"id":57326925,"uuid":"123915102","full_name":"rickyes/polix","owner":"rickyes","description":"This repo is deprecated, please move to https://github.com/polixjs/polix","archived":false,"fork":false,"pushed_at":"2018-07-13T13:25:30.000Z","size":117,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T13:12:27.773Z","etag":null,"topics":["babel","docker","docker-compose","dockerfile","eslint","gulp","koa2","nodejs","ts","webframework"],"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/rickyes.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":null,"support":null}},"created_at":"2018-03-05T12:18:18.000Z","updated_at":"2019-03-11T12:28:17.000Z","dependencies_parsed_at":"2022-09-21T02:01:30.792Z","dependency_job_id":null,"html_url":"https://github.com/rickyes/polix","commit_stats":null,"previous_names":["zhoumingque/polix"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rickyes/polix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickyes%2Fpolix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickyes%2Fpolix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickyes%2Fpolix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickyes%2Fpolix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickyes","download_url":"https://codeload.github.com/rickyes/polix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickyes%2Fpolix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31642682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["babel","docker","docker-compose","dockerfile","eslint","gulp","koa2","nodejs","ts","webframework"],"created_at":"2024-10-14T01:28:05.843Z","updated_at":"2026-04-10T12:31:28.089Z","avatar_url":"https://github.com/rickyes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polix\n\n\nNode.js Web Framework\n\n[![Build Status](https://travis-ci.org/zhoumingque/polix.svg?branch=master)](https://travis-ci.org/zhoumingque/polix)\n[![npm](https://img.shields.io/npm/v/npm.svg)](https://www.npmjs.com/package/polix)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://www.npmjs.com/package/polix)\n\n`polix`是基于`koa v2.5.0`的`IOC`框架,和平常的`Node.js Web Framework`相比，它无需另外绑定路由集合，开发简单，依照`java`的著名依赖注入框架`spring`来制作，让开发者专注于逻辑。`polix`采用多服务多进程架构来保证服务的稳定和快速响应能力，每个`controller`都是一个独立的服务，各服务之间采用`RPC`来通信，这一点借鉴了`pomelo`的架构，不同的是，`polix`采用的是`google`的`gRPC`实现服务通信。`polix`的中间件和`koa v2.x`的中间件保持兼容。`polix`提供`Dockerfile`+`docker-compose.yml`方案进行部署，默认使用的`ORM`是`sequelize`(后续会提供`polix-orm`)。开发者可以选择ES6/7/8 或者 TypeScript来进行开发。\n\n\u003e 以上部分功能尚在开发阶段，敬请关注！\n\n## Install \n\n[![NPM](https://nodei.co/npm/polix.png?compact=true)](https://nodei.co/npm/polix/)\n\n```bash\n$ npm i polix --save\n```\n\n## Getting Started\n```bash\n$ npm i polix-cli -g\n$ pol init example \u0026\u0026 cd example\n$ make build \u0026\u0026 make dev\n```\n\n## Service\n\u003e 在`service`文件夹下添加`user.js`\n\n```javascript\nconst { Service } = require('polix');\n\nclass UserService extends Service {\n  constructor(){\n    super();\n    this._name = {};\n  }\n\n  async addUser(userId,name){\n    this._name[userId] = name;\n    return this;\n  }\n\n  async getUser(userId){\n    return this._name[userId];\n  }\n}\n\nmodule.exports = UserService;\n```\n\n## Controller\n\u003e 在`controller`文件夹下添加`user.js`\n\n```javascript\nconst { Controller, GET, POST, DEL, PUT  } = require('polix');\n\nclass UserController extends Controller {\n  \n  // POST /user/add\bUser\n  @POST\n  async addUser(param, ctx){\n    await this.service.user.addUser(param.userId,param.name);\n    ctx.body = {\n      result: 'ok'\n    };\n  }\n\n  // GET /user/getUser\n  @GET\n  async getUser(param, ctx){\n    let user = await this.service.user.getUser(param.userId);\n    ctx.body = {\n      user\n    };\n  }\n\n  // GET /user/info\n  @GET('info')\n  async getInfo(param, ctx){\n    ctx.body = {\n      v: 'v1.0'\n    }\n  }\n\n  // PUT /user/updateUser\n  @PUT\n  async updateUser(param, ctx){\n    ctx.body = {\n      status: true\n    }\n  }\n\n  // DEL /user/delUser\n  @DEL\n  async delUser(param, ctx){\n    ctx.body = {\n      status: true\n    };\n  }\n\n  // GET /user/status/:userId\n  @GET('status/:userId')\n  async getStatus(param, ctx){\n    ctx.body = {\n      status: true,\n      userId: param.userId\n    };\n  }\n\n}\n\nmodule.exports = UserController;\n```\n\n## middware\n`polix`的中间件与koa 2.x 的中间件保持兼容  \n框架默认加载`koa-body`中间件，如需另外添加中间件则新建`middware`文件夹（与`controller`文件夹平级）  \n添加跨域中间件 ，新建`cors.js`:  \n```javascript\n# cors.js\n\nconst cors = require('koa2-cors');\nmodule.exports = function(){\n  return cors({\n    origin: function(ctx) {\n      return '*';\n    },\n    exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],\n    maxAge: 5,\n    credentials: true,\n    allowMethods: ['GET', 'POST', 'DELETE'],\n    allowHeaders: ['Content-Type', 'Authorization', 'Accept']\n  });\n}\n```\n该文件夹下必须存在`index.js`文件作为总输出中间件文件,加载时根据导出对象的顺序进行绑定中间件\n\n```javascript\n# index.js\n\nconst cors = require('./cors');\n\nmodule.exports = {\n    cors // 必须是函数 ,绑定方式为：app.use(cors())\n}\n```\n\n## Start\n\n```bash\n$ make build \u0026\u0026 make dev\n```\n\n## Author\nPolix © [Ricky 泽阳](https://github.com/zhoumingque), Released under the MIT License.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickyes%2Fpolix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickyes%2Fpolix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickyes%2Fpolix/lists"}