Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Updating examples to match the new fastify plugin architecture #91

Merged
merged 13 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 185 additions & 15 deletions example/cds-hooks-api-guide/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example/cds-hooks-api-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"@sero.run/sero": "0.0.17"
"@sero.run/sero": "^0.0.19",
"fastify": "^3.21.6"
},
"type": "module"
}
6 changes: 3 additions & 3 deletions example/cds-hooks-api-guide/src/current-time/current-time.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service, Card } from "@sero.run/sero";
import { CDSService, CDSCard } from "@sero.run/sero";

const options = {
id: "get-current-time",
Expand All @@ -16,7 +16,7 @@ const handler = async () => {
}${minutes}:${today.getSeconds()}`;
return {
cards: [
new Card({
new CDSCard({
source: {
label: "Automate Medical, Inc.",
url: "https://www.automatemedical.com/",
Expand All @@ -29,4 +29,4 @@ const handler = async () => {
};
};

export default new Service(options, handler);
export default new CDSService(options, handler);
23 changes: 15 additions & 8 deletions example/cds-hooks-api-guide/src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { Http, CDSHooks, start } from "@sero.run/sero";
import { CDSHooks } from "@sero.run/sero";
import Fastify from "fastify";

import compareTimeService from "./current-time/current-time.js";
import prefetchContext from "./prefetch-context/prefetch-context.js";
import suggestionsLinksFhir from "./suggestions-links-fhir/suggestions-links-fhir.js";

const config = {
cdsHooks: {
services: [compareTimeService, prefetchContext, suggestionsLinksFhir],
cors: true,
},
services: [compareTimeService, prefetchContext, suggestionsLinksFhir],
cors: true,
};

const http = Http(config);
CDSHooks(config, http);
start(http);
const fastify = Fastify({
logger: true,
});

fastify.register(CDSHooks, config);
fastify.listen(8080, (err) => {
if (err) {
fastify.log.error(err);
process.exit(1);
}
});
Loading