From 66597f0095c2d0acdeda6aec22469464eda7e1e7 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 21 Oct 2022 17:37:57 +0200 Subject: [PATCH 1/5] feat: add /.well-known/core route --- src/introduction/well-known.controller.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/introduction/well-known.controller.ts b/src/introduction/well-known.controller.ts index 82b64dd..8f514b3 100644 --- a/src/introduction/well-known.controller.ts +++ b/src/introduction/well-known.controller.ts @@ -28,4 +28,10 @@ export class WellKnownController { response.header('Content-length', `${size}`); await response.send(); } + + @Get('core') + @Header('Content-type', 'application/link-format') + public wellKnownCore() { + return 'rt="wot.directory";ct=432'; + } } From 4f1c5b8d8f92eda4402897c9415d05943846b279 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 21 Oct 2022 17:38:25 +0200 Subject: [PATCH 2/5] docs: update WellKnownController documentation --- src/introduction/well-known.controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/introduction/well-known.controller.ts b/src/introduction/well-known.controller.ts index 8f514b3..8e89f16 100644 --- a/src/introduction/well-known.controller.ts +++ b/src/introduction/well-known.controller.ts @@ -5,9 +5,13 @@ import { FastifyReply } from 'fastify'; import { WellKnownService } from './well-known.service'; /** - * This controller is used to expose the Thing Description document. + * This controller is used to handle well-known URIs. + * + * It exposes the Thing Description document via `/.well-known/wot` and + * implements the CoRE Link Format introduction method via `/.well-known/core`. * * @see https://w3c.github.io/wot-discovery/#introduction-well-known + * @see https://w3c.github.io/wot-discovery/#introduction-core-rd-sec */ @ApiTags('Introduction') @Controller('.well-known') From a55a70a0498093c52be0be454ccd642276a26591 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 21 Oct 2022 17:49:36 +0200 Subject: [PATCH 3/5] docs: mark CoRE introduction method as completed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index baf8fd8..eeaa797 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ services: - [ ] Standard API * [ ] XPath queries * [ ] SPARQL queries supported with an external SPARQL endpoint - * [ ] CoRE introduction method + * [x] CoRE introduction method - [ ] Experimental API * [ ] GEO spatial queries * [ ] User private TD collection CRUD From bb48bcb53e60587fc2bd541a3c909a3d97ce60b2 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 21 Oct 2022 17:55:34 +0200 Subject: [PATCH 4/5] test: add test for CoRE Link Format and /.well-known/core --- test/e2e/well-known.e2e-spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/well-known.e2e-spec.ts b/test/e2e/well-known.e2e-spec.ts index ff880eb..a590b34 100644 --- a/test/e2e/well-known.e2e-spec.ts +++ b/test/e2e/well-known.e2e-spec.ts @@ -9,6 +9,10 @@ describe('/well-known', () => { * @see https://w3c.github.io/wot-discovery/#introduction-well-known */ const SPECIFICATION_PATH = 'wot'; + /** + * @see https://www.rfc-editor.org/rfc/rfc6690.html#section-7.1 + */ + const WELL_KNOWN_CORE_PATH = 'core'; let axios: AxiosInstance; let app: INestApplication; @@ -67,4 +71,24 @@ describe('/well-known', () => { }); }); }); + + describe(`/${WELL_KNOWN_CORE_PATH}`, () => { + describe('GET', () => { + it('should answer to well-known', async () => { + const { status } = await axios.get(`/.well-known/${WELL_KNOWN_CORE_PATH}`); + expect(status).toBe(200); + }); + + /** + * @see https://w3c.github.io/wot-discovery/#introduction-core-rd-sec + */ + it('should follow the specification', async () => { + const { status, headers, data } = await axios.get(`/.well-known/${WELL_KNOWN_CORE_PATH}`); + + expect(status).toBe(200); + expect(data).toBe('rt="wot.directory";ct=432'); + expect(headers['content-type']).toContain('application/link-format'); + }); + }); + }); }); From 1bad31da2fc33ce5e8e4eae8f4d0ec0530004ae9 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Tue, 25 Oct 2022 10:57:03 +0200 Subject: [PATCH 5/5] docs: add CoRE Link Format to the list of features --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eeaa797..6f2b969 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ and flexible. Currently, Zion supports the following features: - [Introduction methods](https://w3c.github.io/wot-discovery/#introduction-mech) : - DNS-SD - Well-known URL + - CoRE Link Format and `/.well-known/core` - Standard API: - CRUD operations on the collection of TDs - JSONPath queries compliant with IETF JSONPath standard [draft 5](https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base#section-3.5.8)