{"id":19256462,"url":"https://github.com/paroi-tech/media-engine","last_synced_at":"2025-11-14T06:32:31.832Z","repository":{"id":38975492,"uuid":"130349889","full_name":"paroi-tech/media-engine","owner":"paroi-tech","description":"A backend library to upload and store files in SQLite, then to serve them.","archived":true,"fork":false,"pushed_at":"2022-06-22T04:22:38.000Z","size":230,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T15:55:08.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paroi-tech.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}},"created_at":"2018-04-20T10:52:45.000Z","updated_at":"2025-07-23T04:18:37.000Z","dependencies_parsed_at":"2022-09-19T15:20:22.984Z","dependency_job_id":null,"html_url":"https://github.com/paroi-tech/media-engine","commit_stats":null,"previous_names":["tomko-team/media-engine"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paroi-tech/media-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Fmedia-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Fmedia-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Fmedia-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Fmedia-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paroi-tech","download_url":"https://codeload.github.com/paroi-tech/media-engine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Fmedia-engine/sbom","scorecard":{"id":720678,"data":{"date":"2025-08-11","repo":{"name":"github.com/paroi-tech/media-engine","commit":"0096f3259c4458bfca147c1a7fa7a4970d7140ce"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"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 0/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":"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":"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":"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":"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":"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: Creative Commons Zero v1.0 Universal: 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":"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"}},{"name":"Vulnerabilities","score":0,"reason":"27 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-44fp-w29j-9vj5","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-gp95-ppv5-3jc5","Warn: Project is vulnerable to: GHSA-54xq-cgqr-rpm3","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-wpg7-2c88-r8xv","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-pq67-2wwv-3xjx","Warn: Project is vulnerable to: GHSA-8cj5-5rvv-wf4v","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq"],"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-22T11:14:39.473Z","repository_id":38975492,"created_at":"2025-08-22T11:14:39.474Z","updated_at":"2025-08-22T11:14:39.474Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284353051,"owners_count":26990132,"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-11-14T02:00:06.101Z","response_time":56,"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-11-09T19:05:49.621Z","updated_at":"2025-11-14T06:32:31.811Z","avatar_url":"https://github.com/paroi-tech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @paroi/media-engine\n\nA backend library to upload and store files in SQLite, then to serve them.\n\n## How to create a `MediaStorage`\n\nThe `MediaStorage` stores the files in a relational database. It resizes images in the configured dimensions.\n\nOpen a connection with [LADC](https://www.npmjs.com/package/ladc) using the [adapter for SQLite](https://www.npmjs.com/package/@ladc/sqlite3-adapter) and the [integration](https://www.npmjs.com/package/@ladc/sql-bricks-modifier) with the query builder SQL Bricks:\n\n```sh\nnpm install @paroi/media-engine ladc @ladc/sqlite3-adapter @ladc/sql-bricks-modifier\n```\n\n```ts\nimport ladc from \"ladc\"\nimport sqlite3Adapter from \"@ladc/sqlite3-adapter\"\nimport sqlBricksModifier from \"@ladc/sql-bricks-modifier\"\n\nlet cn = ladc({\n  adapter: sqlite3Adapter({ fileName: \"path/to/db.sqlite\" }),\n  modifier: sqlBricksModifier()\n}\n```\n\nThen, create the storage:\n\n```ts\nexport async function createStorage(cn: import(\"@ladc/sql-bricks-modifier\").SBMainConnection, execDdl: boolean) {\n  return await createMediaStorage({\n    execInitScript: execDdl ? \"sqlite\" : undefined,\n    cn,\n    imagesConf: IMAGES_CONF\n  })\n}\n\nconst IMAGES_CONF: import(\"@paroi/media-engine\").ImageVariantsConfiguration = {\n  \"imageType1\": [\n    {\n      code: \"34x34\",\n      width: 68,\n      height: 68,\n      mediaType: \"image/png\"\n    },\n    {\n      code: \"200x200\",\n      width: 200,\n      height: 200,\n      mediaType: \"image/jpeg\"\n    }\n  ],\n  \"imageType2\": [\n    {\n      code: \"200x100\",\n      width: 200,\n      height: 100,\n      embed: true,\n      mediaType: \"image/jpeg\"\n    }\n  ]\n}\n```\n\nNotice: The `MediaStorage` can be used without an `UploadEngine`.\n\n## How to create an `UploadEngine`\n\nThe `UploadEngine` declares and implements the routes to `express`.\n\nHere is how to create an `UploadEngine`:\n\n```ts\nimport { Request } from \"express\"\nimport { ExternalRef, MediaRef, Media, MulterFile, MediaStorage, createMediaStorage, isSupportedImage } from \"@paroi/media-engine\"\nimport { createUploadEngine, UploadEngine, UploadEngineManager } from \"@paroi/media-engine/upload\"\n\nexport async function createUpload(storage: MediaStorage) {\n  return createUploadEngine({\n    manager: createUploadEngineManager(storage),\n    storage,\n    baseUrl: `url/to/medias`\n  })\n}\n\nfunction createUploadEngineManager(storage: MediaStorage): UploadEngineManager {\n  return {\n    canUpload(req: Request, externalRef: ExternalRef, overwrite: boolean, file: MulterFile) {\n      return {\n        canUpload: true,\n        ownerId: \"123\"\n      }\n    },\n\n    async makeJsonResponseForUpload(req: Request, mediaId: string, overwritten: boolean) {\n      return { /* your JSON response */ }\n    },\n\n    canRead(req: Request, mediaRef: MediaRef) {\n      return true\n    },\n\n    canDelete(req: Request, mediaRef: MediaRef) {\n      return true\n    },\n\n    async makeJsonResponseForDelete(req: Request, deletedMedia: Media) {\n      return { /* your JSON response */ }\n    }\n  }\n}\n```\n\nThen, let it declare the routes:\n\n```ts\nconst express = require(\"express\")\n\nlet router = express.Router()\nuploadEngine.declareRoutes(router)\n\nlet app = express()\napp.use(router)\nlet server = http.createServer(app)\nserver.listen(8080)\n```\n\nNow, three routes are available:\n\n* `url/to/medias/upload` (`POST`) Upload a file and create a media. A JSON object of type `UploadedFile` must be sent as a parameter with the file.\n* `url/to/medias/delete` (`POST`) Delete a media. A JSON object of type `{ mediaId: string }` must be sent as a request body.\n* `url/to/medias/:year/:variantId/:fileName?download=1` (`GET`) Serve a file. An optional URL parameter `download` can be set.\n\nThe `UploadedFile` type:\n\n```ts\ninterface UploadedFile {\n  ref {\n    type: string\n    id: string\n  }\n  overwrite?: boolean\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparoi-tech%2Fmedia-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparoi-tech%2Fmedia-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparoi-tech%2Fmedia-engine/lists"}