{"id":18862801,"url":"https://github.com/eik-lib/sink-file-system","last_synced_at":"2026-02-15T04:02:22.910Z","repository":{"id":250672055,"uuid":"835175596","full_name":"eik-lib/sink-file-system","owner":"eik-lib","description":"Sink implementation that persists files on the local file system","archived":false,"fork":false,"pushed_at":"2025-09-06T02:05:03.000Z","size":67,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-06T04:08:48.985Z","etag":null,"topics":["eik","eik-sink"],"latest_commit_sha":null,"homepage":"https://eik.dev","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/eik-lib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-29T10:06:15.000Z","updated_at":"2025-08-01T10:39:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"5dc98504-c068-4b5e-8d49-efe5b3738c53","html_url":"https://github.com/eik-lib/sink-file-system","commit_stats":null,"previous_names":["eik-lib/sink-file-system"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/eik-lib/sink-file-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-file-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-file-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-file-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-file-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eik-lib","download_url":"https://codeload.github.com/eik-lib/sink-file-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fsink-file-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274613129,"owners_count":25317682,"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-11T02:00:13.660Z","response_time":74,"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":["eik","eik-sink"],"created_at":"2024-11-08T04:35:47.793Z","updated_at":"2026-01-07T07:02:42.413Z","avatar_url":"https://github.com/eik-lib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @eik/sink-file-system\n\nSink implementation that persists files on the local file system.\n\n## Usage\n\n```sh\nnpm install @eik/sink-file-system\n```\n\n```js\nimport path from 'node:path';\nimport { pipeline } from 'node:stream';\nimport Sink from '@eik/sink-file-system';\nimport express from 'express';\n\nconst app = express();\nconst sink = new Sink({\n    sinkFsRootPath: path.join(process.cwd(), 'eik-files'),\n});\n\napp.get('/file.js', async (req, res, next) =\u003e {\n    try {\n        const file = await sink.read('/path/to/file/file.js');\n        pipeline(file.stream, res, (error) =\u003e {\n            if (error) return next(error);\n        });\n    } catch (error) {\n        next(error);\n    }\n});\n\napp.listen(8000);\n```\n\n## API\n\nThe sink instance has the following API:\n\n### .write(filePath, contentType)\n\nMethod for writing a file to storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be stored - Required.\n-   `contentType` - String - The content type of the file - Required.\n\nResolves with a writable stream.\n\n```js\nimport { pipeline } from 'node:stream';\n\nconst fromStream = new SomeReadableStream();\nconst sink = new Sink({ ... });\n\ntry {\n    const file = await sink.write('/path/to/file/file.js', 'application/javascript');\n    pipeline(fromStream, file.stream, (error) =\u003e {\n        if (error) console.log(error);\n    });\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .read(filePath)\n\nMethod for reading a file from storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be read - Required.\n\nResolves with a [ReadFile][read-file] object which holds metadata about\nthe file and a readable stream with the byte stream of the file on the\n`.stream` property.\n\n```js\nimport { pipeline } from 'node:stream';\n\nconst toStream = new SomeWritableStream();\nconst sink = new Sink({ ... });\n\ntry {\n    const file = await sink.read('/path/to/file/file.js');\n    pipeline(file.stream, toStream, (error) =\u003e {\n        if (error) console.log(error);\n    });\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .delete(filePath)\n\nMethod for deleting a file in storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be deleted - Required.\n\nResolves if file is deleted and rejects if file could not be deleted.\n\n```js\nconst sink = new Sink({ ... });\n\ntry {\n    await sink.delete('/path/to/file/file.js');\n} catch (error) {\n    console.log(error);\n}\n```\n\n### .exist(filePath)\n\nMethod for checking if a file exist in the storage.\n\nThis method takes the following arguments:\n\n-   `filePath` - String - Path to the file to be checked for existence - Required.\n\nResolves if file exists and rejects if file does not exist.\n\n```js\nconst sink = new Sink({ ... });\n\ntry {\n    await sink.exist('/path/to/file/file.js');\n} catch (error) {\n    console.log(error);\n}\n```\n\n[eik]: https://github.com/eik-lib\n[read-file]: https://github.com/eik-lib/common/blob/master/lib/classes/read-file.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fsink-file-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feik-lib%2Fsink-file-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fsink-file-system/lists"}