Skip to content

Commit

Permalink
fix(plugin): makes fastify plugin async instead of callback
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikj31 committed Nov 9, 2023
1 parent 248f38d commit a889f25
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { FastifyPluginCallback } from "fastify";
import { FastifyPluginAsync, FastifyPluginCallback } from "fastify";
import fastifyPlugin from "fastify-plugin";
import { createOnRequestHook } from "./hooks/onRequest";
import { createOnSendHook } from "./hooks/onSend";
Expand All @@ -11,10 +11,9 @@ export interface PluginOptions {
defaultTTL: number;
}

export const dynamodbCache: FastifyPluginCallback<PluginOptions> = (
export const dynamodbCache: FastifyPluginAsync<PluginOptions> = async (
fastify,
opts,
done
opts
) => {
const dynamoClient = new DynamoDBClient({
endpoint: opts.dynamoDbAddress,
Expand Down Expand Up @@ -54,8 +53,6 @@ export const dynamodbCache: FastifyPluginCallback<PluginOptions> = (
}
}
});

done();
};

declare module "fastify" {
Expand Down

0 comments on commit a889f25

Please sign in to comment.