{"id":16321584,"url":"https://github.com/hstarorg/rest-express","last_synced_at":"2025-09-07T02:36:02.283Z","repository":{"id":42423622,"uuid":"61922898","full_name":"hstarorg/rest-express","owner":"hstarorg","description":"A rest api framework based on express.","archived":false,"fork":false,"pushed_at":"2017-02-11T14:44:38.000Z","size":40,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-31T01:51:50.588Z","etag":null,"topics":["api","express","mysql","rest","sqlserver","validator"],"latest_commit_sha":null,"homepage":null,"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/hstarorg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-06-25T02:20:30.000Z","updated_at":"2021-11-09T11:12:39.000Z","dependencies_parsed_at":"2022-09-26T19:52:51.769Z","dependency_job_id":null,"html_url":"https://github.com/hstarorg/rest-express","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hstarorg/rest-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstarorg%2Frest-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstarorg%2Frest-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstarorg%2Frest-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstarorg%2Frest-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hstarorg","download_url":"https://codeload.github.com/hstarorg/rest-express/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstarorg%2Frest-express/sbom","scorecard":{"id":470996,"data":{"date":"2025-08-11","repo":{"name":"github.com/hstarorg/rest-express","commit":"23c5525c01fb7d54a2f7698f4281fa0696c3131a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T13:53:16.879Z","repository_id":42423622,"created_at":"2025-08-19T13:53:16.879Z","updated_at":"2025-08-19T13:53:16.879Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273988473,"owners_count":25203093,"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-09-07T02:00:09.463Z","response_time":67,"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":["api","express","mysql","rest","sqlserver","validator"],"created_at":"2024-10-10T22:48:16.257Z","updated_at":"2025-09-07T02:36:02.239Z","avatar_url":"https://github.com/hstarorg.png","language":"JavaScript","funding_links":[],"categories":["例子"],"sub_categories":[],"readme":"# rest-express [![Google Analytics](https://ga-beacon.appspot.com/UA-80998210-1/index)](https://github.com/hstarorg/rest-express)\nA rest api framework based on express.\n\n[![NPM Version](https://img.shields.io/npm/v/rest-express.svg?style=flat)](https://www.npmjs.org/package/rest-express)\n[![npm](https://img.shields.io/npm/dm/rest-express.svg?style=flat)](https://www.npmjs.org/package/rest-express)\n[![npm](https://img.shields.io/npm/dt/rest-express.svg?style=flat)](https://www.npmjs.org/package/rest-express)\n[![Build Status](https://travis-ci.org/hstarorg/rest-express.svg?branch=master)](https://travis-ci.org/hstarorg/rest-express)\n[![Coverage Status](https://coveralls.io/repos/hstarorg/rest-express/badge.svg?branch=master)](https://coveralls.io/r/hstarorg/rest-express?branch=master)\n[![Dependency Status](https://david-dm.org/hstarorg/rest-express.svg?style=flat)](https://david-dm.org/hstarorg/rest-express)\n[![License](http://img.shields.io/npm/l/rest-express.svg?style=flat)](https://raw.githubusercontent.com/hstarorg/rest-express/master/LICENSE)\n\n# How to use?\n\n``$ npm install rest-express --save``\n\n```javascript\nlet restExpress = require('rest-express');\nrestExpress.startServer(options)\n  .then((server) =\u003e {\n    let address = server.address();\n    console.log('Server started', address);\n  }, (err) =\u003e {\n    console.error(err);\n  });\n```\n# About Options\n\n```javascript\nlet options = {\n  port: 3000, //必须提供，服务端口\n  enableResponseTime: true, //是否启用响应时间记录（会在header中，设置X-Response-Time的值，单位毫秒）\n  responseTimeOptions: { //responseTime的参数配置，请参考：https://github.com/expressjs/response-time\n    digits: 4, //default 3\n    header: 'use-time',\n    suffix: false\n  },\n  enableLog: true, //是否启用日志\n  logFormat: 'combined', //设置日志格式\n  logOptions: { //日志插件相关参数，请参考：https://github.com/expressjs/morgan\n\n  },\n  enableCors: true, //是否启用Cors支持\n  corsOptions: { //Cors参数，请参考：https://github.com/expressjs/cors\n\n  },\n  urlParserOptions: {}, //转换url参数配置，请参考：https://github.com/expressjs/body-parser\n  jsonParserOptions: {}, //转换json参数配置，请参考：https://github.com/expressjs/body-parser\n  enableGzip: true, //是否启用Gzip支持\n  gzipOptions: {}, //gzip配置，请参考：https://github.com/expressjs/compression\n  enableHttps: false, //是否启用Https\n  httpsOptions: { //Https配置项，提供{key: '', cert: ''}\n    key: '',\n    cert: ''\n  },\n  onRoutesLoading: (app) =\u003e { //加载路由之前要执行的操作，参数app = express();\n    console.log('before load routes');\n  },\n  onRoutesLoaded: (app) =\u003e { //加载路由之后要执行的操作，参数app = express();\n    console.log('after load routes');\n  },\n  routesPath: path.join(__dirname, 'routes'), //路由目录，所有要加载的路由都放置在此处。\n  apiPrefix: '/' //全局Api前缀， 如： /api/v1\n};\n```\n\n**注意：其中 ``port`` 和 ``routesPath`` 为必填参数。**\n\n# How to write route?\n\n```javascript\n'use strict';\n\nlet router = new Router();\nlet testBiz = require('./../bizs/testBiz');\n\nrouter.get('/test', testBiz.test);\n\n//每个路由文件需要如下方式导出：\nmodule.exports = {\n  priority: 0, // 可选参数，默认0，优先级，越大越先加载\n  router: router, // 必须参数，router对象。\n  prefix: '/test/abc' // 可选参数，默认/，router前缀，会拼接在options.apiPrefix之后。\n};\n```\n\n# How to validate object?\n\n`rest-experss` 集成了 `Joi` 验证库，通过提供了一个全局的 `Validator` 对象，如果我们要验证，只需要如下调用：\n\n```javascript\nValidator.validate(req.body, schema [,options])\n  .then(() =\u003e {\n    // do some logic\n  })\n  .catch(next);\n```\n\n其中 `options` 的默认值为： `{ allowUnknown: true, abortEarly: false }`，可自行指定参数，参考：[Joi Api Docs](https://github.com/hapijs/joi/blob/v10.2.2/API.md)\n\n# How to use MSSQL?\n\n```javascript\nlet MSSQL = require('rest-express').MSSQL;\n\nlet config = {\n  user: 'xxx', // UserName\n  password: 'xxxx', // Password\n  server: '127.0.0.1', // Server Name(IP)\n  port: 1433, // Data Server Port \n  database: 'XXX', // Data base name\n  pool: { //线程池\n    max: 50, // 最大线程数\n    min: 0, // 最小线程数\n    idleTimeoutMillis: 30 * 1000 // 超时时间\n  }\n};\nlet db = new MSSQL(config);\n\ndb.executeNonQuery('update JayTestTable1 set password = @pwd', {pwd: '中文'})\n  .then((count) =\u003e {\n    console.log(count); //受影响的行数\n  });\ndb.executeScalar('select top 1 * from JayTestTable1 where id = 15')\n  .then((data) =\u003e {\n    console.log(data); //查询结果的第一行数据（建议查询语句只会有第一行数据）\n    //如果查询结果是一个简单数据，如查询count，那么data则直接是这个count值，不在是一个对象。\n  });\ndb.executeQuery('select * from JayTestTable1')\n  .then((rows) =\u003e {\n    console.log(rows); //数据集\n  });\ndb.executeProcedure('up_GetPersonalApiList', {userName: 'abc'}, {}) //存储过程名称、输入参数、输出参数\n  .then((result) =\u003e {\n    console.log(result.result); //执行结果\n    console.log(result.affectedRowCount); //受影响的行数\n    console.log(result.resultOutput); // 输出参数\n  });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhstarorg%2Frest-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhstarorg%2Frest-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhstarorg%2Frest-express/lists"}