{"id":16485116,"url":"https://github.com/single9/tejat","last_synced_at":"2025-09-08T12:37:34.851Z","repository":{"id":68154126,"uuid":"86420050","full_name":"single9/tejat","owner":"single9","description":"A Framework.","archived":false,"fork":false,"pushed_at":"2018-11-02T09:52:42.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T00:11:31.410Z","etag":null,"topics":[],"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/single9.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-28T05:50:22.000Z","updated_at":"2018-11-02T09:52:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"c48d336b-db47-48e9-998e-655d2088110e","html_url":"https://github.com/single9/tejat","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/single9/tejat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/single9%2Ftejat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/single9%2Ftejat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/single9%2Ftejat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/single9%2Ftejat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/single9","download_url":"https://codeload.github.com/single9/tejat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/single9%2Ftejat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271354995,"owners_count":24745212,"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-08-20T02:00:09.606Z","response_time":69,"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":[],"created_at":"2024-10-11T13:24:14.209Z","updated_at":"2025-08-20T17:26:29.585Z","avatar_url":"https://github.com/single9.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tejat\n=====\n\nA Server-side JavaScript Framework.\n\n簡介\n------------\n\n這一個專案目前仍在開發與設計當中，原本構思的內容是要將 MonogoDB 的一些操作方式從 JS 程式\n控制改成以 API 的方式操作，並且設計成一個可外掛式模組，如此一來就能讓我的一些專案可以根據\n需求很方便的直接掛上這個模組，然後快速擁有一個可以直接使用的 MonogoDB API，而不需要撰寫\n許多程式。\n\n簡單來說就是一個懶人 MongoDB API 框架。\n\n後來覺得這個框架似乎可以做到更多的事情，而且能簡化不少的程式撰寫，所以逐漸朝向一個網站伺服器\n框架的方向前進，只不過我還處在要採用 ES7 還是先用 ES6，目前是傾向 ES7。\n\n提醒一下路過不小心看到的路人們，這個框架許多部分還在開發，目前僅有 MongoDB API 的規劃功能。\n其他與網站有關的部分目前都還在開發中。\n\n然後還請各位路過的先進提供意見，我將萬分感謝。\n\n安裝\n-----\n\n    git clone https://github.com/single9/Tejat.git\n    cd Tejat\n    npm install\n\n\u003e Node 版本建議採用 7.x 以上\n\n使用\n-----\n\n啟動伺服器：\n\n    node index.js\n\n這個程式會在啟動時主動去搜尋 `modules` 資料夾中檔案，並根據檔案名稱新增一個路由到 Express\n之中。所以說，你只需要參考 `modules/test.js` 這個檔案就能夠快速的為不同的 collection 設\n記一個專屬於它的 API。\n\n**modules/test.js**\n\n```js\nconst Framework = require(\"../libs/framework\");\n\nvar test = new Framework({\n  // Your schema\n  schemas: {\n    hi: {\n      str: {\n        type: String,\n        unique: true\n      },\n      date: {\n        type: Date,\n        default: Date.now\n      }\n    }\n  },\n\n  // Your methods\n  methods: {\n    getClientIP: function (req, res, next) {\n      let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;\n      this.logger.info('Your IP address is', ip);\n      next();\n    },\n    test: function (req, res, next) {\n      res.json(\"Hello, World!\");\n      next();\n    },\n    sayGoodBye: function (req, res, next) {\n      this.logger.info('Bye~');\n      next();\n    },\n  },\n\n  // Before routes\n  beforeRoutes: [\n    {fnName: 'getClientIP'}\n  ],\n\n  // Main routes\n  routes: {\n    \"/hello\": [\n      {method: 'get', fnName: 'test'},\n    ]\n  },\n\n  // After routes\n  afterRoutes: [\n    {fnName: 'sayGoodBye'}\n  ],\n\n});\n\nmodule.exports = test;\n```\n\n### schemas\n\n這部分參考 moongose 關於 [Schema](http://mongoosejs.com/docs/guide.html) 的說明。\n\n    schemas: {\n      schema_name: {\n        schema_prop_1: {\n          ....\n        },\n        schema_prop_2: {\n          ....\n        }\n      },\n      ...\n    }\n\n### methods\n\n可自行增加額外所需的方法。\n\n    methods: {\n      function_name: function(arg) {\n        // Something todo.\n      },\n      ...\n    }\n\n\n### routes\n\n除框架內的基本路由外，亦可自行設定新的路由。\n\n    routes: {\n      \"/user\": [\n        {method: \"HTTP method\", fnName: \"method name\"}\n      ]\n    }\n\n此外，你還可以在路由進入之前或之後加 middleware。\n\n#### before\n\n    beforeRoutes: [\n      {path: 'path', fnName: 'method name'}\n    ],\n\n#### after\n\n    afterRoutes: [\n      {path: 'path', fnName: 'method name'}\n    ],\n\npath 不特別設定則如同 `app.route.use(middleware)`\n\n使用範例\n------\n\n### 新增\n\nPOST http://localhost:3000/test\n\n    {\n      \"schema\":\"hi\",\n      \"values\": {\n        \"str\": \"hello!\"\n      }\n    }\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": {\n        \"__v\": 0,\n        \"str\": \"hello!\",\n        \"_id\": \"58da0ada1577ce26c3d19832\",\n        \"date\": \"2017-03-28T07:03:54.709Z\"\n      }\n    }\n\n### 查詢\n\nGET http://localhost:3000/test/hi\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": [\n        {\n          \"_id\": \"58da0ada1577ce26c3d19832\",\n          \"str\": \"hello!\",\n          \"__v\": 0,\n          \"date\": \"2017-03-28T07:03:54.709Z\"\n        },\n        {\n          \"_id\": \"58da0b4d1577ce26c3d19833\",\n          \"str\": \"Yes\",\n          \"__v\": 0,\n          \"date\": \"2017-03-28T07:05:49.289Z\"\n        }\n      ]\n    }\n\nGET http://localhost:3000/test/hi?_id=58da0ada1577ce26c3d19832\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": [\n        {\n          \"_id\": \"58da0ada1577ce26c3d19832\",\n          \"str\": \"hello!\",\n          \"__v\": 0,\n          \"date\": \"2017-03-28T07:03:54.709Z\"\n        }\n      ]\n    }\n\nGET http://localhost:3000/test/hi?str=hello!\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": [\n        {\n          \"_id\": \"58da0ada1577ce26c3d19832\",\n          \"str\": \"hello!\",\n          \"__v\": 0,\n          \"date\": \"2017-03-28T07:03:54.709Z\"\n        }\n      ]\n    }\n\n\n### 修改\n\nPUT http://localhost:3000/test/\n\n    {\n      \"schema\":\"hi\",\n      \"id\": \"58da0ada1577ce26c3d19832\",\n      \"values\": {\n        \"str\": \"yeeeeee\"\n      }\n    }\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": {\n        \"n\": 0,\n        \"nModified\": 0,\n        \"ok\": 1\n      }\n    }\n\n### 刪除\n\nDELETE http://localhost:3000/test/\n\n    {\n      \"schema\":\"hi\",\n      \"id\": \"58da0ada1577ce26c3d19832\"\n    }\n\nRESPONSE\n\n    {\n      \"status\": true,\n      \"response\": {\n        \"n\": 1,\n        \"ok\": 1\n      }\n    }\n\n預設路由\n------\n\n{Module Name} = 模組名稱，範例為 test。\n\n### GET {Module Name}/{Schema Name}?{Querry String}\n\n查詢資料。\n\n**{Schema Name}**\n\n即你所命名的 Schema Name，範例有兩個，一為 hi，二為 alpha。\n\n**{Querry String}**\n\n根據你訂的 Schema 內容來增減。\n\n其他：\n\n- limit: 限制回傳數量","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingle9%2Ftejat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingle9%2Ftejat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingle9%2Ftejat/lists"}