{"id":21685251,"url":"https://github.com/mplewis/pge-coding-exercise","last_synced_at":"2025-03-20T11:42:32.088Z","repository":{"id":225114416,"uuid":"764947710","full_name":"mplewis/pge-coding-exercise","owner":"mplewis","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-03T17:31:01.000Z","size":161,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T12:08:11.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mplewis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-02-29T01:59:31.000Z","updated_at":"2024-02-29T09:13:24.000Z","dependencies_parsed_at":"2024-02-29T12:11:02.230Z","dependency_job_id":null,"html_url":"https://github.com/mplewis/pge-coding-exercise","commit_stats":null,"previous_names":["mplewis/pge-coding-exercise"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mplewis%2Fpge-coding-exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mplewis%2Fpge-coding-exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mplewis%2Fpge-coding-exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mplewis%2Fpge-coding-exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mplewis","download_url":"https://codeload.github.com/mplewis/pge-coding-exercise/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244609330,"owners_count":20480779,"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":[],"created_at":"2024-11-25T16:18:55.466Z","updated_at":"2025-03-20T11:42:32.057Z","avatar_url":"https://github.com/mplewis.png","language":"TypeScript","readme":"# PG\u0026E Coding Exercise\n\nThis implements an AWS Lambda function which reads from the [Divvy Bikes Station Information](https://gbfs.divvybikes.com/gbfs/en/station_information.json) API, processes the data for all stations with \u003c 12 capacity into a CSV, and stores it in a public S3 bucket.\n\n## Usage\n\n### Install dependencies\n\nThis project uses pnpm, so install it before installing dependencies:\n\n```bash\nnpm install -g pnpm\npnpm install\n```\n\n### Run tests\n\nThis project uses Vitest to run tests ending in `.spec.ts`:\n\n```bash\npnpm test\n```\n\n### Start the dev server\n\nThe Hapi server's entrypoint is [src/serve.ts](src/serve.ts). This server is for demo purposes only and doesn't build the CSV report or upload to S3. Run this locally on port 3000 with hot reloading:\n\n```bash\npnpm dev\n```\n\nGet the list of stations using curl:\n\n```bash\ncurl -H \"Authorization: Bearer dummy-token-for-testing\" \\\n\thttp://localhost:3000\n```\n\n### Run in a Docker container\n\nUse the package.json scripts to build and run the Hapi server in a Docker container:\n\n```bash\npnpm docker-build\npnpm docker-run\n```\n\nSend a request to the Docker container:\n\n```bash\ncurl -H \"Authorization: Bearer dummy-token-for-testing\" \\\n\thttp://localhost:3000\n```\n\n### Deploy the Lambda function\n\nThe Lambda function's entrypoint is [src/lambda.ts](src/lambda.ts). Deployment is performed by AWS CDK and defined in [deploy/lib/deploy-stack.ts](deploy/lib/deploy-stack.ts):\n\n```bash\nbin/bootstrap  \t\t\t\t\t\t\t\t\t # only necessary before your first deploy run\nbin/deploy\t\t\t\t\t\t\t\t\t\t\t # create the infrastructure and deploy the Lambda code\n(cd deploy \u0026\u0026 pnpm cdk destroy)  # if you want to destroy the stack and its resources\n```\n\nDeploying this function will print the URL for your API Gateway endpoint:\n\n```bash\nOutputs:\nDivvyBikeStations.DivvyBikeStationsAPIEndpointCB164D8F = https://mnor5f4dxj.execute-api.us-west-2.amazonaws.com/prod/\n```\n\nYou can test my demo instance of this Lambda function using curl:\n\n```bash\ncurl -H \"Authorization: Bearer dummy-token-for-testing\" \\\n\thttps://mnor5f4dxj.execute-api.us-west-2.amazonaws.com/prod/\n```\n\nOn success, this function returns a JSON response pointing to the CSV report in the public S3 bucket:\n\n```json\n{\n\t\"csvReportURL\": \"https://divvy-bikes-stations-data-352053662162.s3.amazonaws.com/stations-1709197898.csv\"\n}\n```\n\n## Environment Variables\n\nThe behavior of the server can be customized using environment variables, defined in [src/config.ts](src/config.ts):\n\n| Name                          | Type       | Description                                                     | Default                                                        |\n| ----------------------------- | ---------- | --------------------------------------------------------------- | -------------------------------------------------------------- |\n| `DIVVY_BIKE_STATIONS_API_URL` | `string`   | The API URL for fetching information about Divvy Bike stations  | `https://gbfs.divvybikes.com/gbfs/en/station_information.json` |\n| `HOST`                        | `string`   | The host on which the server runs                               | `localhost`                                                    |\n| `PORT`                        | `number`   | The port on which the server listens                            | `3000`                                                         |\n| `AUTH_TOKENS`                 | `string[]` | The valid authentication tokens for the server, comma-separated | `dummy-token-for-testing,another-dummy-token`                  |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmplewis%2Fpge-coding-exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmplewis%2Fpge-coding-exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmplewis%2Fpge-coding-exercise/lists"}