{"id":22725340,"url":"https://github.com/ovotech/apollo-datasource-s3","last_synced_at":"2025-04-13T20:27:18.891Z","repository":{"id":33152970,"uuid":"151681928","full_name":"ovotech/apollo-datasource-s3","owner":"ovotech","description":"S3DataSource is responsible for fetching data from a given s3 bucket, using aws js api.","archived":false,"fork":false,"pushed_at":"2023-07-11T18:13:47.000Z","size":1459,"stargazers_count":5,"open_issues_count":21,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-05T16:09:40.370Z","etag":null,"topics":["boost-bit","boostpower","company-ovo"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ovotech.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-10-05T06:54:14.000Z","updated_at":"2023-11-24T10:51:07.000Z","dependencies_parsed_at":"2023-01-14T23:40:20.210Z","dependency_job_id":null,"html_url":"https://github.com/ovotech/apollo-datasource-s3","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fapollo-datasource-s3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fapollo-datasource-s3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fapollo-datasource-s3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fapollo-datasource-s3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ovotech","download_url":"https://codeload.github.com/ovotech/apollo-datasource-s3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229089207,"owners_count":18018390,"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","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":["boost-bit","boostpower","company-ovo"],"created_at":"2024-12-10T16:09:22.574Z","updated_at":"2024-12-10T16:09:23.329Z","avatar_url":"https://github.com/ovotech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo S3DataSource\n\n[![CircleCI](https://circleci.com/gh/ovotech/apollo-datasource-s3.svg?style=svg\u0026circle-token=c64973d3fd46a2b132c93516f9f44df992380a3b)](https://circleci.com/gh/ovotech/apollo-datasource-s3)\n[![npm (scoped)](https://img.shields.io/npm/v/@ovotech/apollo-datasource-s3.svg)](https://www.npmjs.com/package/@ovotech/apollo-datasource-s3)\n\nS3DataSource is responsible for fetching data from a given S3 bucket using aws js API. Integrates with the cache and expires tags on S3, following the example of [Apollo Data Sources](https://www.apollographql.com/docs/apollo-server/features/data-sources.html). This useful if you want to read data from a private / restricted s3 bucket.\n\n### Using\n\n```bash\nyarn add @ovotech/apollo-datasource-s3\n```\n\nThis module ships with TypeScript types. It also has helper methods to deal with JSON objects directly.\n\n```ts\nimport { S3DataSource } from '@ovotech/apollo-datasource-s3';\nimport { S3 } from 'aws-sdk';\n\nclass MyS3DataSource extends S3DataSource {\n  async get() {\n    return await this.getObjectJson({ Bucket: 'bucket', Key: 'data.json' });\n  }\n\n  async put(data) {\n    return await this.putObjectJson(data, { Bucket: 'bucket', Key: 'test' });\n  }\n}\n\nconst s3 = new S3();\nconst ds = new MyS3DataSource(s3);\n```\n\nYou can also access the lower level api to load the raw data from s3, as well as list and delete items. Those request mimic the s3 api itself, but adds a layer of caching in front of it.\n\n```ts\nclass MyS3DataSource extends S3DataSource {\n  async get() {\n    return await this.getObject({ Bucket: 'bucket', Key: 'data.json' });\n  }\n\n  async put(data) {\n    return await this.putObject({ Bucket: 'bucket', Key: 'test', Body: 'data' });\n  }\n\n  async list() {\n    return await this.listObjects({ Bucket: 'bucket' });\n  }\n\n  async delete() {\n    return await this.deleteObject({ Bucket: 'bucket', Key: 'data.json' });\n  }\n}\n```\n\n## Running the tests\n\nThe tests require a running s3 mock server, and we're using [localstack](https://github.com/localstack/localstack) for that.\nYou'll need to start the s3 server:\n\n```bash\nSERVICES=s3 localstack start\n```\n\nAfter which you can run all the tests:\n\n```bash\nyarn test\n```\n\n### Coding style (linting, etc) tests\n\nStyle is maintained with prettier and tslint\n\n```\nyarn lint\n```\n\n## Deployment\n\nTo deploy a new version, push to master and then create a new release. CircleCI will automatically build and deploy a the version to the npm registry.\n\n## Contributing\n\nHave a bug? File an issue with a simple example that reproduces this so we can take a look \u0026 confirm.\n\nWant to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see `test/S3DataSource.spec.ts`). You can run the tests with `SERVICES=s3 localstack start` and `yarn test`.\n\n## Responsible Team\n\n- Boost Internal Tools (BIT)\n\n## License\n\nThis project is licensed under Apache 2 - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovotech%2Fapollo-datasource-s3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovotech%2Fapollo-datasource-s3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovotech%2Fapollo-datasource-s3/lists"}