From 00708b97cadf62f026112db79e13701128cbf8a5 Mon Sep 17 00:00:00 2001 From: Beng Eu Date: Tue, 13 Jul 2021 16:29:22 +0800 Subject: [PATCH] Encapsulate routes in separate plugins So that changes to the Fastify instance will only be reflected in each plugin's scope. --- src/routes/bucket/index.ts | 12 ++++++------ src/routes/object/index.ts | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/routes/bucket/index.ts b/src/routes/bucket/index.ts index 8a0f3463..858dd1b4 100644 --- a/src/routes/bucket/index.ts +++ b/src/routes/bucket/index.ts @@ -8,10 +8,10 @@ import updateBucket from './updateBucket' // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export default async function routes(fastify: FastifyInstance) { - createBucket(fastify) - deleteBucket(fastify) - emptyBucket(fastify) - getAllBuckets(fastify) - getBucket(fastify) - updateBucket(fastify) + fastify.register(createBucket) + fastify.register(deleteBucket) + fastify.register(emptyBucket) + fastify.register(getAllBuckets) + fastify.register(getBucket) + fastify.register(updateBucket) } diff --git a/src/routes/object/index.ts b/src/routes/object/index.ts index e7efc921..74e45db3 100644 --- a/src/routes/object/index.ts +++ b/src/routes/object/index.ts @@ -13,15 +13,15 @@ import updateObject from './updateObject' // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export default async function routes(fastify: FastifyInstance) { - copyObject(fastify) - createObject(fastify) - deleteObject(fastify) - deleteObjects(fastify) - getObject(fastify) - getSignedObject(fastify) - getPublicObject(fastify) - getSignedURL(fastify) - moveObject(fastify) - updateObject(fastify) - listObjects(fastify) + fastify.register(copyObject) + fastify.register(createObject) + fastify.register(deleteObject) + fastify.register(deleteObjects) + fastify.register(getObject) + fastify.register(getSignedObject) + fastify.register(getPublicObject) + fastify.register(getSignedURL) + fastify.register(moveObject) + fastify.register(updateObject) + fastify.register(listObjects) }