{"id":22635961,"url":"https://github.com/webduinoio/hashkey-middleware","last_synced_at":"2025-03-29T04:45:52.768Z","repository":{"id":37670127,"uuid":"506074691","full_name":"webduinoio/hashkey-middleware","owner":"webduinoio","description":"驗證使用權限的 Middleware","archived":false,"fork":false,"pushed_at":"2022-06-22T02:45:23.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T14:41:17.400Z","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/webduinoio.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":"2022-06-22T02:44:30.000Z","updated_at":"2022-06-22T02:47:41.000Z","dependencies_parsed_at":"2022-08-18T04:45:57.346Z","dependency_job_id":null,"html_url":"https://github.com/webduinoio/hashkey-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webduinoio%2Fhashkey-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webduinoio%2Fhashkey-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webduinoio%2Fhashkey-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webduinoio%2Fhashkey-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webduinoio","download_url":"https://codeload.github.com/webduinoio/hashkey-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140544,"owners_count":20729797,"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-12-09T03:17:30.292Z","updated_at":"2025-03-29T04:45:52.732Z","avatar_url":"https://github.com/webduinoio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"hashkey-middleware\n==================\n\n驗證使用權限的 Middleware。\n\nCLI Usage\n---------\n\n    node index.js [number|hashkey]\n\nHashkey\n---------\n\n- 用來使用 API 的鑰匙\n- 在生產環境中的有效時間為 15 分鐘\n- Package: [Hashids](https://www.npmjs.com/package/hashids)\n\n```js\nconst Hashids = require('hashids/cjs');\nconst hashSalt = process.env.SALT || 'my salt';\nconst idHashids = new Hashids(hashSalt, 32, '0123456789abcdef');\n\nfunction genHashId(id = 141236) {\n    const time = Date.now();    // Timestamp\n    const idHash = idHashids.encode([id, time]);  // encode id and time to fake hex\n    return idHash;\n}\n\n// 編碼\nconst idHash = genHashId();\n// 解碼\nconst decodedId = idHashids.decode(idHash);\n\nconsole.log('Original ID: %d', id);\nconsole.log('Encoded ID: %s', idHash);\nconsole.log('Decoded ID: %j', decodedId);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebduinoio%2Fhashkey-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebduinoio%2Fhashkey-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebduinoio%2Fhashkey-middleware/lists"}