{"id":14989672,"url":"https://github.com/resource-watch/rw-api-microservice-node","last_synced_at":"2026-01-05T03:40:18.875Z","repository":{"id":41957327,"uuid":"315309678","full_name":"resource-watch/rw-api-microservice-node","owner":"resource-watch","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-08T13:04:50.000Z","size":611,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-26T04:44:46.650Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/resource-watch.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,"governance":null}},"created_at":"2020-11-23T12:34:18.000Z","updated_at":"2021-12-06T13:19:31.000Z","dependencies_parsed_at":"2023-02-13T17:05:54.358Z","dependency_job_id":"9c10a34a-897e-4ac6-a783-5423018e3f22","html_url":"https://github.com/resource-watch/rw-api-microservice-node","commit_stats":{"total_commits":79,"total_committers":2,"mean_commits":39.5,"dds":"0.025316455696202556","last_synced_commit":"cb3dfd400497ee3b48c989e9091243b1d12c45df"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resource-watch%2Frw-api-microservice-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resource-watch%2Frw-api-microservice-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resource-watch%2Frw-api-microservice-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resource-watch%2Frw-api-microservice-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/resource-watch","download_url":"https://codeload.github.com/resource-watch/rw-api-microservice-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244875047,"owners_count":20524591,"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-09-24T14:18:44.496Z","updated_at":"2026-01-05T03:40:18.847Z","avatar_url":"https://github.com/resource-watch.png","language":"TypeScript","readme":"# RW API microservice utility for Nodejs applications\n\n[![Build Status](https://travis-ci.com/resource-watch/rw-api-microservice-node.svg?branch=main)](https://travis-ci.com/resource-watch/rw-api-microservice-node)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/ee1ee2cab3d50b46fcd1/test_coverage)](https://codeclimate.com/github/resource-watch/rw-api-microservice-node/test_coverage)\n\nLibrary to register and integrate microservices in the [RW API](https://api.resourcewatch.org/).\n\nSupports [Koa](https://koajs.com/) 2.x and 1.x frameworks.\n\n## Requirements\n\n- Nodejs v11 or greater\n\n## Install\n\nUsing NPM:\n\n````\nnpm install --save rw-api-microservice-node\n````\n\nUsing Yarn:\n\n````\nyarn add rw-api-microservice-node\n````\n\n## Use in microservice\n\nIn the `listen` callback of your Koa application, add the following code snippet:\n\n```javascript\nconst Koa = require('koa');\nconst RWAPIMicroservice = require('rw-api-microservice-node')\n\nconst app = new Koa();\n\napp.use(RWAPIMicroservice.bootstrap({\n  logger: logger,\n  microserviceToken: '\u003cyour microservice token\u003e',\n  gatewayURL: '\u003cyour gateway URL\u003e',\n  fasltyEnabled: true,\n  fastlyServiceId: '\u003cyour Fastly service id\u003e',\n  fastlyAPIKey: '\u003cyour Fastly API key\u003e',\n  awsRegion: '\u003cyour AWS region\u003e',\n  awsCloudWatchLogStreamName: '\u003cyour AWS CloudWatch log stream name\u003e',\n}))\n\n// Make sure you add your auth-depending routes *after* bootstraping this module\n\nconst server = app.listen(process.env.PORT, () =\u003e {\n  logger.info('Server started!');\n});\n```\n\n## Configuration\n\nThese are the values you'll need to provide when using this library:\n\nSee [this link](https://docs.fastly.com/en/guides/finding-and-managing-your-account-info) for details on how to get\nFastly credentials.\n\n| Argument name                  | Type          | Description                                                                                                                                         | Required?         | Default value    |\n|--------------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|------------------|\n| logger                         | Object        | A `bunyan` logger object, for logging purposes                                                                                                      | yes               |                  |\n| gatewayURL                     | string        | The URL of the API as a whole, where all other services will be reachable                                                                           | yes               |                  |\n| microserviceToken              | string        | JWT token to use on calls to other services                                                                                                         | yes               |                  |\n| skipAPIKeyRequirementEndpoints | Array\u003cObject\u003e | List of object containing a `method` and `pathRegex`. Incoming requests that match one of the elements on the list will bypass API Key requirement. | no                |                  |\n| fastlyEnabled                  | boolean       | If set to `true`, the [Fastly](https://www.fastly.com/) integration will be enabled                                                                 | yes               |                  |\n| fastlyServiceId                | string        | Access credentials to the [Fastly](https://www.fastly.com/) API                                                                                     | if Fastly enabled |                  |\n| fastlyAPIKey                   | string        | Access credentials to the [Fastly](https://www.fastly.com/) API                                                                                     | if Fastly enabled |                  |\n| requireAPIKey                  | boolean       | If API keys are required. If set to true, requests with no API key automatically get a HTTP 403 response.                                           | no                | true             |\n| awsCloudWatchLoggingEnabled    | boolean       | If API key usage should be logged to AWS CloudWatch.                                                                                                | no                | true             |\n| awsRegion                      | string        | Which AWS region to use when logging requests to AWS CloudWatch.                                                                                    | yes               |                  |\n| awsCloudWatchLogGroupName      | string        | Which CloudWatch Log Group name to use when logging requests to AWS CloudWatch.                                                                     | no                | 'api-keys-usage' |\n| awsCloudWatchLogStreamName     | string        | Which CloudWatch Log Stream name to use when logging requests to AWS CloudWatch.                                                                    | yes               |                  |\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresource-watch%2Frw-api-microservice-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresource-watch%2Frw-api-microservice-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresource-watch%2Frw-api-microservice-node/lists"}