Commit Graph

24 Commits

Author SHA1 Message Date
Christian Bewernitz
007a7e6c47 pass matching mime type to xmldom; test [dynamicxml] (#10830)
* feat: pass matching mime type to xmldom

If the `Content-Type` header contains one of the mime types supported by `DOMParser`, the first matching mime type will be used instead of `text/xml`.

The default is still `text/xml` for cases when the header is not present or none of the mime types from the list are present.

* factor out and add tests

---------

Co-authored-by: chris48s <git@chris-shaw.dev>
2025-01-21 19:52:59 +00:00
chris48s
f3e0cc06f4 [DynamicXml] parse doc as html if served with text/html content type (#10607) 2024-10-12 08:07:28 +00:00
chris48s
cf656d3a4d catch xml ParseError (#10516) 2024-09-07 20:04:32 +01:00
dependabot[bot]
ffd0903878 chore(deps): bump @xmldom/xmldom from 0.8.10 to 0.9.0; run [DynamicXml] (#10481)
* chore(deps): bump @xmldom/xmldom from 0.8.10 to 0.9.0

Bumps [@xmldom/xmldom](https://github.com/xmldom/xmldom) from 0.8.10 to 0.9.0.
- [Release notes](https://github.com/xmldom/xmldom/releases)
- [Changelog](https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xmldom/xmldom/compare/0.8.10...0.9.0)

---
updated-dependencies:
- dependency-name: "@xmldom/xmldom"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* invoke parseFromString with mimetype

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
2024-09-07 17:56:13 +00:00
chris48s
cee41f5818 improve documentation for [dynamicxml] service (#9798) 2023-12-13 19:54:21 +00:00
chris48s
45bb786147 log 429s to sentry (attempt 2); affects [dynamic endpoint uptimerobot weblate opencollective discord github] (#9546)
* log to sentry if upstream service responds with 429

* allow services to decide which error(s) to log, default to 429

* don't log 429s from endpoint or dynamic badges

* supress 429s from uptime robot badges

* supress 429s from weblate if not calling default server

* cache opencollective badges for longer

* cache discord badges for longer

* cache github workflow badges for longer
2023-12-04 13:37:58 +00:00
chris48s
57c2ba0d68 Convert examples arrays to openApi objects (part 1) (#9320)
* add helper functions for generating Open API path/query params with defaults

* tweak Open API schema

- make description optional
- allow null example + allowEmptyValue (for boolean query params)

* convert examples --> openApi in amo

* convert examples --> openApi in ansible

* convert examples --> openApi in appveyor build/job

* add re-usable Open API query param for test-results badges

we can use these for all the 'test results' badges

* convert examples --> openApi in appveyor tests

* DRY up existing dynamic/endpoint param definitions

* DRY up queryParam

* allow enum param in serviceDefinition schema

* improve misleading param name

* check route and openApi are consistent on service load

* fix mistake in ansible role route

* documentation --> description

* add pathParams and queryParams helpers +docstrings

* give everything a search-friendly summary, check for duplicate summary

* prettier fixup
2023-07-31 12:22:33 +01:00
chris48s
14892e3943 Implement a pattern for dealing with upstream APIs which are slow on the first hit; affects [endpoint] (#9233)
* allow serviceData to override cacheSeconds with a longer value

* prevent [endpoint] json cacheSeconds property exceeding service default

* allow ShieldsRuntimeError to specify a cacheSeconds property

By default error responses use the cacheLength of
the service class throwing the error.

This allows error to tell the handling layer the maxAge
that should be set on the error badge response.

* add customExceptions param

This

1. allows us to specify custom properties to pass to the exception
   constructor if we throw any of the standard got errors
   e.g: `ETIMEDOUT`, `ECONNRESET`, etc
2. uses a custom `cacheSeconds` property (if set on the exception)
   to set the response maxAge

* customExceptions --> systemErrors

* errorMessages --> httpErrors
2023-06-13 21:08:43 +01:00
chris48s
4f4d49d424 switch from xmldom to @xmldom/xmldom (#9100) 2023-05-01 19:17:40 +01:00
chris48s
148b51d554 Export OpenAPI definitions from service examples; affects [dynamic endpoint static] (#8966)
* WIP export OpenAPI definitions from service examples

* allow services to optionally define an OpenApi Paths Object instead of examples

* make use of param descriptions and required query params

* convert other 'core' services to declare openApi..

..instead of examples

* tweak descriptions for standard query params

* move stuff around, add a high-level integration test for category2openapi

* update simple-icons text refs #9054

* remove legacy param names
2023-04-11 18:37:16 +01:00
Pierre-Yves B
23c0406bed Migrate from CommonJS to ESM (#6651) 2021-07-09 12:53:55 +01:00
Caleb Cartwright
ac54dd3ced convert some service classes to static props, run [drone dub dynamic] (#5543)
* refactor(drone): convert to static props

* refactor(dub): convert to static props

* refactor(dynamic): convert to static props
2020-09-15 01:42:57 +00:00
dependabot-preview[bot]
478d14300c Build(deps-dev): bump eslint-plugin-import from 2.20.1 to 2.20.2 (#4859)
* Build(deps-dev): bump eslint-plugin-import from 2.20.1 to 2.20.2

Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.20.1 to 2.20.2.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...v2.20.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Fixes

* refactor: combine imports

* refactor: combine imports

* refactor: combine imports

* refactor: update import ordering

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
Co-authored-by: Paul Melnikow <email@paulmelnikow.com>
Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
2020-04-16 18:39:13 -05:00
Marcin Mielnicki
22a85bfbcd A response size metric of an upstream service for dynamic badges like [dynamicyaml], (but not [jetbrains]) (#4434)
* Response size metric for all services

* Unused code removed

* Test for service response size metric

* All buckes of the service_response_bytes in a comment

* Register parameter in PrometheusMetrics is optional

* service response size metric enabled for dynamic badges

* Better test name

* JSDoc removed

* One import from one file

* Gather metrics in the background

* Revert saving response time metrics in the background
2020-01-04 17:48:24 +01:00
Marcin Mielnicki
4c159eff00 Support for XPath functions in [dynamicxml] badge (#4153)
* Support XPath query with type convertion

* Support XPath query with node function

* Parametrized tests for transform function

* Handle unusual values returned by 'select'
2019-10-12 17:23:17 +02:00
Caleb Cartwright
65f66642dd fix type errors in [DynamicXml] service (#4041)
* fix: type errors in DynamicXml service

* tests: add more tests for DynamicXml

* tests: another DynamicXml service test
2019-10-08 15:48:43 -05:00
chris48s
873172522f [dynamicxml] wrap xpath errors (#3955)
Closes #3796
2019-09-07 13:02:27 -04:00
dependabot-preview[bot]
294aa1e1df Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0; autofixes (#3671)
* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0

Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Autofixes
2019-07-08 12:13:46 -04:00
Paul Melnikow
d343fddb2c Rewrite [dynamicxml] tests, and fix issue with attribute filters (#3298)
This fixes queries with an attribute filter in the middle, such as //book[@id='bk102']/title.

Close #3089
2019-04-13 15:06:36 -04:00
Paul Melnikow
2d7be31b0c Validate query params in BaseService (#3042)
This is a mid-sized PR that adds query param validation to BaseService and updates most of the services which use query param validation to use it. There are a couple minor tweaks I made along the way.

Fix #2676
2019-02-20 22:24:47 -05:00
Paul Melnikow
7c3bca1ab7 Refactor endpoint functions (#2909) 2019-02-03 17:29:52 -05:00
Paul Melnikow
226fa67a02 Create shortcut for BaseService-related imports (#2809)
Continue to implement #2698:

- Add `core/base-service/index.js` (but hold off on moving the things it imports)
- Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits.
- Apply consistent ordering of imports and use of `module.exports` in testers.
- Remove some renaming of imports.
- Remove obsolete tests here and there.
2019-01-21 15:41:24 -05:00
Paul Melnikow
4a976b52ea Fix import issue with [dynamic] badge (#2578)
Ref https://github.com/badges/shields/pull/2519#issuecomment-449511750
2018-12-23 10:13:04 -05:00
Paul Melnikow
b8461aa921 Rewrite [DynamicXml] and [DynamicYaml] badges (#2487)
- A little related cleanup in `server.js`: remove a couple import renames.
2018-12-12 16:52:47 -05:00