Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract defaultChannel for topic into util
- Loading branch information
1 parent
e8c00f4
commit 2dd3166
Showing
5 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ResourceIdentifier } from '../../../http/representation/ResourceIdentifier'; | ||
import { NOTIFY } from '../../../util/Vocabularies'; | ||
import type { NotificationChannel } from '../NotificationChannel'; | ||
|
||
/** | ||
* Default StreamingHTTPChanel2023 for a topic. | ||
* Currently chennel description is only used internally and never sent to the client. | ||
* The default channel uses Turtle. | ||
*/ | ||
export function defaultChannel(topic: ResourceIdentifier): NotificationChannel { | ||
return { | ||
id: `${topic.path}.channel`, | ||
type: NOTIFY.StreamingHTTPChannel2023, | ||
topic: topic.path, | ||
accept: 'text/turtle', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/unit/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Util.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defaultChannel } from '../../../../../src/server/notifications/StreamingHttpChannel2023/StreamingHttp2023Util'; | ||
import { NOTIFY } from '../../../../../src/util/Vocabularies'; | ||
|
||
describe('defaultChannel', (): void => { | ||
it('returns description given topic.', (): void => { | ||
const topic = { path: 'http://example.com/foo' }; | ||
const channel = defaultChannel(topic); | ||
expect(channel).toEqual({ | ||
id: `${topic.path}.channel`, | ||
type: NOTIFY.StreamingHTTPChannel2023, | ||
topic: topic.path, | ||
accept: 'text/turtle', | ||
}); | ||
}); | ||
}); |