{"id":23131262,"url":"https://github.com/emartech/boar-server","last_synced_at":"2026-02-02T17:18:33.160Z","repository":{"id":28202503,"uuid":"31704924","full_name":"emartech/boar-server","owner":"emartech","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-12T10:18:46.000Z","size":455,"stargazers_count":1,"open_issues_count":6,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-03T06:14:38.678Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emartech.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":"2015-03-05T09:02:26.000Z","updated_at":"2025-05-10T09:12:41.000Z","dependencies_parsed_at":"2024-01-16T21:56:01.949Z","dependency_job_id":"090722fc-cb2a-4ac8-8c4a-b949f2d549ee","html_url":"https://github.com/emartech/boar-server","commit_stats":{"total_commits":82,"total_committers":17,"mean_commits":4.823529411764706,"dds":0.6219512195121951,"last_synced_commit":"c966f3ce082907913a4fd97f4e2ab5b3743bd166"},"previous_names":["emartech/boar-stack"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/emartech/boar-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fboar-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fboar-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fboar-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fboar-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emartech","download_url":"https://codeload.github.com/emartech/boar-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fboar-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269683097,"owners_count":24458619,"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-10T02:00:08.965Z","response_time":71,"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-12-17T11:12:26.231Z","updated_at":"2026-02-02T17:18:28.139Z","avatar_url":"https://github.com/emartech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boar Server\n\n## Example usage for app\n\nput these lines in your server.js\n``` javascript\n  var koa = require('koa');\n  var path = require('path');\n  var koaApp = module.exports = koa();\n  var config = require('./config');\n  var App = require('boar-server').app;\n\n  var app = new App(koaApp);\n  app.connectToMongoose(config.mongooseUri);\n  app.addDynamicViewMiddleware(path.join(config.root, '/views'), config.env === 'development');\n  app.addStaticContentMiddleware(path.join(config.root, '/assets'));\n  app.addHookMiddleware();\n  app.loadControllers(path.join(config.root, 'controllers'));\n  app.loadModels(path.join(config.root, 'models'));\n\n  if (!module.parent) { app.listen(config.port); }\n```\n\n## Add middleware for your app\n``` javascript\n  var cors = require('koa-cors');\n  var app = new App(koaApp);\n  app.addMiddleware(cors());\n```\n\n## Graceful shutdown\nYou can stop the server from recieving new connections with `app.close()`. It returns a Promise that resolves when all existing connections are ended.\n``` javascript\n  var app = new App(koaApp);\n  app.listen(config.port);\n  process.on('SIGTERM', () =\u003e {\n    app.close().then(() =\u003e {\n      // additional cleaning (e.g. closing db connection)\n      process.exit(0);\n    })\n  })\n```\n\n## HTTPS support\nTo enable HTTPS support, simple create `SERVE_HTTPS` environment variable with value `true`.\nThe port for https will be the port of the application increased with 10000 (10k).\n\nIf you want to serve the requests with your own SSL certification, create `HTTPS_KEY` and `HTTPS_CERT`\nenvironment variables with path of the files as values.\n\n### Example\n```\nexport SERVE_HTTPS=true\nexport HTTPS_KEY=\"path/to/cert.key\"\nexport HTTPS_CERT=\"path/to/cert.crt\"\n\nnode server.js\n```\n\n## Build-in Middlewares\n\n### Cors Support ([koa-cors](https://github.com/evert0n/koa-cors))\n\n``` javascript\n  app.addCorsSupportMiddleware();\n```\n\n### Static Content ([koa-static](https://github.com/koajs/static))\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __path__ | `String` | Path to the static content's folder |\n\n``` javascript\n  app.addStaticContentMiddleware(path);\n```\n\n### Dynamic View\n\nThis middleware is a wrapper for [koa-pug](https://github.com/chrisyip/koa-pug).\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __path__ | `String` | Path to the pug files |\n\n``` javascript\n  app.addDynamicViewMiddleware(path);\n```\n\n### Method Override ([koa-methodoverwrite](https://github.com/koa-modules/methodoverride))\n\n``` javascript\n  app.addMethodOverrideMiddleware();\n```\n\n### Error Handler\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __path__ | `String` | Path to error page pug template |\n\n``` javascript\n  app.addErrorHandlerMiddleware(path);\n```\n\n### Body Parse ([koa-bodyparser](https://github.com/koajs/body-parser))\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __options__ | `Object` | [More info.](https://github.com/koajs/bodyparser#options) |\n\n``` javascript\n  app.addBodyParseMiddleware(options);\n```\n\n### Request Id ([koa-requestid](https://github.com/seegno/koa-requestid))\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __options__ | `Object` | _optional_ |\n| ↳header | `String` | The name of the header to read the id on the request, `false` to disable. |\n| ↳query  | `String` | The name of the header to read the id on the query string, `false` to disable. |\n| ↳expose | `String` | The name of the header to expose the id on the response, `false` to disable. |\n\n``` javascript\n  app.addRequestIdmiddleware(options);\n```\n\n### Enforce SSL ([koa-ssl](https://github.com/jclem/koa-ssl))\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __options__ | `Object` | [More info.](https://github.com/jclem/koa-ssl#use) |\n\n``` javascript\n  app.addEnforceSSLMiddleware();\n```\n\nIf your application is running behind reverse proxy (like Heroku) you should set the trustProxy configuration option to *true* in order to process the x-forwarded-proto header.\n\n``` javascript\n  var app = new App(koaApp);\n  app.addEnforceSSLMiddleware({ trustProxy: true });\n```\n\n__Note__: if you use this middleware EnforceSSL middleware should be the first you add.\n\n\n### Hook\n\n``` javascript\n  app.addHookMiddleware();\n```\n\n### Security\nProvides middlewares for setting up various security related HTTP headers.\n\n| Param | Type  | Description |\n| ----- | ----- | ----------- |\n| __options__ | `Object` |  |\n| ↳csp | `Object` | [More info.](https://github.com/helmetjs/csp) Learn more: [CSP quick reference](http://content-security-policy.com/) |\n| ↳hsts | `Object` | [More info.](https://github.com/helmetjs/hsts) Learn more: [OWASP HSTS page](https://www.owasp.org/index.php/HTTP_Strict_Transport_Security) |\n| ↳useXssFilter | `Boolean` | If `true`, [x-xss-protection](https://github.com/helmetjs/x-xss-protection) middleware will be included. Default: `true` |\n| ↳useNoSniff | `Boolean` |  If `true`, [dont-sniff-mimetype](https://github.com/helmetjs/dont-sniff-mimetype) middleware will be included. Default: `true` |\n\n``` javascript\n  app.addSecurityMiddlewares(options);\n```\n\n#### Default configuration\n``` javascript\n  {\n    csp: {\n      directives: {\n        defaultSrc: [\"'self'\"],\n        scriptSrc: [\"'self'\"],\n        styleSrc: [\"'self'\"],\n        imgSrc: [\"'self'\"],\n        frameAncestors: [\"'self'\"],\n        reportUri: 'about:blank'\n      },\n      reportOnly: true\n    },\n    hsts: {\n      maxAge: 30,\n      includeSubdomains: true,\n      preload: false\n    },\n    useXssFilter: true,\n    useNoSniff: true\n  }\n```\n\n\n## Libraries\n\n### Mask email address\n``` javascript\n  var maskEmailAddress = require('boar-server').lib.maskEmailAddress;\n  maskEmailAddress('test@gmail.com');\n```\n\n### Real ip address (in heroku)\n``` javascript\n  var realIpAddress = require('boar-server').lib.realIpAddress;\n  realIpAddress(request);\n```\n\n### ControllerFactory\n``` javascript\n  var ControllerFactory = require('boar-server').lib.controllerFactory;\n\n  module.exports = ControllerFactory.create(function(router) {\n    router.get('/', ControllerFactory.load('main/actions/get'));\n    router.get('/healthcheck', ControllerFactory.load('main/actions/healthcheck/get'));\n    router.get('/list', ControllerFactory.loadByAcceptType('main/actions/list/get'));\n  });\n```\n\n### ClearCollections\n\n***deprecated*** aliased to `dropCollections`\n\nUse the more descriptively named `dropCollections` instead.\n\n### DropCollections\n\n```javascript\n  var dropCollections = require('boar-server').lib.dropCollections(mongoose);\n  \n  dropCollections(); // returns a promise\n```\n\nThis will _drop_ all your collections.\n\n### TruncateCollections\n\n```javascript\n  var truncateCollections = require('boar-server').lib.truncateCollections(mongoose);\n\n  truncateCollections(); // returns a promise\n```\n\nThis will _truncate_ all your collections.\n\n### ClearGridfs\n\n### Database\n\nWrapper for mongoose connection.\n\n### ExceptionHandler\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femartech%2Fboar-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femartech%2Fboar-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femartech%2Fboar-server/lists"}