{"id":18974647,"url":"https://github.com/asd-xiv/blocks","last_synced_at":"2026-03-09T11:05:01.246Z","repository":{"id":39878263,"uuid":"157214779","full_name":"asd-xiv/blocks","owner":"asd-xiv","description":"REST API framework for Node.js","archived":false,"fork":false,"pushed_at":"2022-10-01T10:23:44.000Z","size":1749,"stargazers_count":1,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-01T18:21:00.628Z","etag":null,"topics":["api","framework","nodejs","rest","server"],"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/asd-xiv.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":"2018-11-12T13:05:02.000Z","updated_at":"2022-05-19T07:00:00.000Z","dependencies_parsed_at":"2022-09-05T08:31:23.679Z","dependency_job_id":null,"html_url":"https://github.com/asd-xiv/blocks","commit_stats":null,"previous_names":["mutant-ws/blocks"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/asd-xiv/blocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asd-xiv%2Fblocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asd-xiv%2Fblocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asd-xiv%2Fblocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asd-xiv%2Fblocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asd-xiv","download_url":"https://codeload.github.com/asd-xiv/blocks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asd-xiv%2Fblocks/sbom","scorecard":{"id":211152,"data":{"date":"2025-08-11","repo":{"name":"github.com/asd-xiv/blocks","commit":"baab8b9e01c9d1470a860e3a22e86c57f239ee48"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 1/30 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":"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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: npmCommand not pinned by hash: .githooks/post-checkout:11","Warn: npmCommand not pinned by hash: .githooks/post-merge:11","Info:   0 out of   2 npmCommand dependencies pinned"],"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":"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":"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"}},{"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"26 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33","Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959","Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-f9xv-q969-pqx4"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T00:47:22.898Z","repository_id":39878263,"created_at":"2025-08-17T00:47:22.898Z","updated_at":"2025-08-17T00:47:22.898Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30291855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"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":["api","framework","nodejs","rest","server"],"created_at":"2024-11-08T15:15:40.315Z","updated_at":"2026-03-09T11:05:01.220Z","avatar_url":"https://github.com/asd-xiv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable first-line-h1 line-length --\u003e\n\n[![CircleCI](https://circleci.com/gh/asd-xiv/blocks.svg?style=svg)](https://circleci.com/gh/asd-xiv/blocks)\n[![npm package version](https://badge.fury.io/js/%40asd14%2Fblocks.svg)](https://badge.fury.io/js/%40asd14%2Fblocks)\n[![Coverage Status](https://coveralls.io/repos/github/asd-xiv/blocks/badge.svg)](https://coveralls.io/github/asd-xiv/blocks)\n\n# blocks\n\n\u003e REST API framework for Node.js\n\n![Request-Response cycle](docs/bin/req-res-cycle.svg \"Request-Response cycle\")\n\n---\n\n\u003c!-- vim-markdown-toc GFM --\u003e\n\n- [Features](#features)\n  - [Validate input](#validate-input)\n  - [Permissions](#permissions)\n  - [Plugin / Dependency Injection](#plugin--dependency-injection)\n  - [Promises](#promises)\n  - [Other](#other)\n- [Install](#install)\n- [Example](#example)\n- [Configuration](#configuration)\n- [Routes](#routes)\n  - [Default \"/ping\"](#default-ping)\n  - [Definition](#definition)\n  - [JSON schemas](#json-schemas)\n  - [Data formats](#data-formats)\n- [Plugins](#plugins)\n  - [Custom plugin](#custom-plugin)\n- [Develop](#develop)\n- [Changelog](#changelog)\n\n\u003c!-- vim-markdown-toc --\u003e\n\n## Features\n\n### Validate input\n\n\u003e Pass request data (headers, body, query parameters, URL parameters) through\n\u003e custom JSON Schemas defined for each route. Make sure no unwanted data gets\n\u003e in, de-clutter the route logic and make the API behave more consistent.  \n\u003e If validation fails, an automatic `409 Conflict` response will be sent.\n\n### Permissions\n\n\u003e Function outside of main route logic. If it returns false, an automatic\n\u003e `403 Forbidden` response will be sent.\n\n### Plugin / Dependency Injection\n\n\u003e Separate 3rd party systems logic or splitting code for better\n\u003e [SOC](https://en.wikipedia.org/wiki/Separation_of_concerns)\n\n### Promises\n\n\u003e `async/await` in Plugins and Routes\n\n### Other\n\n- File upload and form parsing for `multipart/form-data` -\n  [`busboy`](https://github.com/mscdex/busboy)\n- Middleware support of existing package -\n  [`connect`](https://github.com/senchalabs/connect)\n- JSON Web Token - [`jsonwebtoken`](https://github.com/auth0/node-jsonwebtoken)\n- Query string parsing - [`qs`](https://github.com/ljharb/qs)\n- Route parameter parsing -\n  [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp)\n- Cross-origin resource sharing - [`cors`](https://github.com/expressjs/cors)\n- Secure your API with various HTTP headers -\n  [`helmet`](https://github.com/helmetjs/helmet)\n\n## Install\n\n```bash\nnpm install @asd14/blocks\n```\n\n## Example\n\n`src/index.js`\n\n```js\nimport http from \"node:http\"\nimport glob from \"glob\"\nimport { block } from \"@asd14/blocks\"\n\nconst [middleware] = await block({\n  plugins: glob.sync(\"./plugins/*.js\", { absolute: true }),\n  routes: glob.sync(\"./**/*.route.js\", { absolute: true }),\n})\n\nhttp\n  .createServer(middleware)\n  .listen(process.env.PORT)\n  .on(\"error\", error =\u003e {\n    console.log(\"Server error\", error)\n  })\n  .on(\"listening\", () =\u003e {\n    console.log(`Server started on port ${process.env.PORT}`)\n  })\n\n```\n\n## Configuration\n\n`blocks` uses a set of `process.env` variables for configuration. See\n[`_env`](_env) file for all available options and defaults.\n\nUse [`dotenv`](https://github.com/motdotla/dotenv) for easy local development.\n\n## Routes\n\n### Default \"/ping\"\n\n`GET: /ping`\n\n```js\n{\n  \"name\": \"@asd14/blocks\",\n  \"ping\": \"pong\",\n  \"aliveFor\": {\n    \"days\": 2, \"hours\": 1, \"minutes\": 47, \"seconds\": 46\n  }\n}\n```\n\n### Definition\n\n`src/something.route.js`\n\n```js\nimport schema from \"./something.schema.js\"\n\nexport default {\n  method: \"GET\",\n  path: \"/something/:id\",\n\n  /**\n   * Check \"req.query\", \"req.header\", \"req.params\" and \"req.body\"\n   * against a JSON Schema. If check fails, respond with 409,\n   * otherwise continue to \".authenticate\".\n   */\n  schema,\n\n  /**\n   * Check for valid JWT.\n   *\n   * @param {object} plugins\n   *\n   * @returns {(object) =\u003e Promise\u003cboolean\u003e}\n   * If false, responds with 401, otherwise continue to \".authorize\".\n   */\n  authenticate: (/* plugins */) =\u003e (/* req */) =\u003e true,\n\n  /**\n   * Check if is allowed to access underlying resource.\n   *\n   * @param {object} plugins\n   *\n   * @returns {(object) =\u003e Promise\u003cboolean\u003e}\n   * If false, respond with 403, otherwise continue to \".action\".\n   */\n  authorize: (/* plugins */) =\u003e (/* req */) =\u003e true,\n\n  /**\n   * Route/Controller logic\n   *\n   * @param {object} plugins\n   *\n   * @returns {(object) =\u003e Promise\u003c*\u003e} 500 if throws, 201 if POST, 200 otherwise\n   */\n  action: (/* plugins */) =\u003e req =\u003e {\n    return {\n      message: req.ctx.params.id,\n    }\n  },\n}\n```\n\n### JSON schemas\n\nInput validation is the first step in the processing pipeline. It's meant to\nvalidate that incoming data corresponds with what the route expects in order to\ndo it's job properly. See [`ajv`](https://github.com/epoberezkin/ajv) and\n[JSON Schema docs](https://json-schema.org) for more on data validation.\n\nSchemas can contain only 4 (optional) keys. Each key must be a\n[ajv](https://github.com/epoberezkin/ajv) compatible object.\n\n- `headers` validates `req.headers`\n- `params` validates `req.ctx.params` parsed from URL with\n  [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp)\n- `query`: validates `req.ctx.query` parsed from URL with\n  [`qs`](https://github.com/ljharb/qs)\n- `body` validates `req.ctx.body` parsed from `req` with `JSON.parse`\n\nSee [`src/plugins/route-default.schema.js`](src/plugins/route-default.schema.js)\nfor default values.\n\n`src/something.schema.js`\n\n```js\nexport default {\n  headers: {\n    type: \"object\",\n    required: [\"authorization\"],\n    properties: {\n      authorization: {\n        type: \"string\",\n      },\n    },\n  },\n\n  params: {\n    type: \"object\",\n    additionalProperties: false,\n    required: [\"id\"],\n    properties: {\n      id: {\n        type: \"string\",\n        pattern: \"^[a-z0-9-]+$\",\n        maxLength: 25,\n        minLength: 25,\n      },\n    },\n  },\n\n  query: {\n    type: \"object\",\n    additionalProperties: false,\n    properties: {\n      offset: {\n        type: \"integer\",\n        minimum: 0,\n        default: 0,\n      },\n      limit: {\n        type: \"integer\",\n        minimum: 1,\n        maximum: 100,\n        default: 20,\n      },\n    },\n  },\n}\n```\n\n### Data formats\n\n- _date_: full-date according to\n  [RFC3339](http://tools.ietf.org/html/rfc3339#section-5.6)\n- _time_: time with optional time-zone\n- _date-time_: date-time from the same source (time-zone is mandatory)\n- _duration_: duration from\n  [RFC3339](https://tools.ietf.org/html/rfc3339#appendix-A)\n- _uri_: full URI\n- _email_: email address\n- _ipv4_: IP address v4\n- _ipv6_: IP address v6\n- _regex_: tests whether a string is a valid regular expression by passing it to\n  RegExp constructor\n- _uuid_: Universally Unique IDentifier according to\n  [RFC4122](http://tools.ietf.org/html/rfc4122)\n\n```js\n{\n  \"params\": {\n    \"type\": \"object\",\n    \"additionalProperties\": false,\n    \"properties\": {\n      \"id\": {\n        \"type\": \"string\",\n        \"format\": \"uuid\"\n      }\n    }\n  },\n\n  \"query\": {\n    \"type\": \"object\",\n    \"additionalProperties\": false,\n    \"properties\": {\n      \"email\": {\n        \"type\": \"string\",\n        \"format\": \"email\"\n      }\n    }\n  },\n\n  \"body\": {\n    \"type\": \"object\",\n    \"additionalProperties\": false,\n    \"properties\": {\n      \"thumbnailURL\": {\n        \"type\": \"string\",\n        \"format\": \"uri\"\n      },\n      \"createdAt\": {\n        \"type\": \"string\",\n        \"format\": \"date-time\"\n      }\n    }\n  }\n}\n```\n\n## Plugins\n\nSeparate code interfacing with 3rd party libraries or services.\n[pluginus](https://github.com/asd-xiv/pluginus) dependency injection library is\nused.\n\nPlugins are accessible in other plugins, middleware and routes.\n\n### Custom plugin\n\nA plugin consists of a constructor function and a list of other plugins that is\ndependent on.\n\nWhatever the `create` function returns will be considered as the plugin's\ncontent and is what will be exposed to the routes, middleware and other plugins.\n\n`src/plugins/database.js`\n\n```js\nimport Sequelize from \"sequelize\"\n\nexport default {\n  /**\n   * Array of plugins to wait for before running `create`.\n   * Name is constructed from the filename by removing the extension and\n   * turning it into CammelCase.\n   *\n   * Ex. \"test__name--BEM.plugin.js\" =\u003e \"TestNameBemPlugin\"\n   */\n  depend: [\"Lorem\"],\n\n  /**\n   * Constructor, return value will be considered the plugin's content exposed\n   * to routes, middleware and other plugins.\n   *\n   * @returns  {Promise\u003cany\u003e}  Plugin content\n   */\n  create: =\u003e Lorem =\u003e {\n    console.log(\"Checking DB connection\")\n\n    // Database connection, model loading etc\n    ...\n    return {\n      Todos: ...,\n      Comments: ...,\n    }\n  }\n}\n```\n\n## Develop\n\n```bash\ngit clone git@github.com:asd-xiv/blocks.git \u0026\u0026 \\\n  cd blocks \u0026\u0026 \\\n  npm run setup\n```\n\nRun all `*.test.js` in `tests` folder\n\n```bash\nnpm test\n```\n\nWatch `src` and `tests` folders and re-run tests\n\n```bash\nnpm run tdd\n```\n\n## Changelog\n\nSee the [releases section](https://github.com/asd-xiv/blocks/releases) for\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasd-xiv%2Fblocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasd-xiv%2Fblocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasd-xiv%2Fblocks/lists"}