From 96caca424c4962f753e9f1792093e8d729c5c518 Mon Sep 17 00:00:00 2001 From: Mohab Sameh <37941642+mohab-sameh@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:23:38 +0200 Subject: [PATCH] Create README.md --- .../redwoodjs/core/4/auth-decoder/README.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 codemods/redwoodjs/core/4/auth-decoder/README.md diff --git a/codemods/redwoodjs/core/4/auth-decoder/README.md b/codemods/redwoodjs/core/4/auth-decoder/README.md new file mode 100644 index 00000000..66af9ae6 --- /dev/null +++ b/codemods/redwoodjs/core/4/auth-decoder/README.md @@ -0,0 +1,84 @@ +# Auth Decoder + +## Description + +This codemod for RedwoodJS v4 automatically inserts an `authDecoder` property into the `createGraphQLHandler` call if it's not already present. It also adds an import statement for `authDecoder` from `@redwoodjs/auth-auth0-api` at the beginning of the file, ensuring that the necessary functionality for authentication is correctly integrated. + +## Example + +### Before + +```TypeScript +import { createGraphQLHandler } from '@redwoodjs/graphql-server'; + +import directives from 'src/directives/**/*.{js,ts}'; +import sdls from 'src/graphql/**/*.sdl.{js,ts}'; +import services from 'src/services/**/*.{js,ts}'; + +import { db } from 'src/lib/db'; +import { logger } from 'src/lib/logger'; + +export const handler = createGraphQLHandler({ + loggerConfig: { logger, options: {} }, + directives, + sdls, + services, + onException: () => { + // Disconnect from your database with an unhandled exception. + db.$disconnect(); + }, +}); +``` + +### After + +```TypeScript +import { authDecoder } from '@redwoodjs/auth-auth0-api'; +import { createGraphQLHandler } from '@redwoodjs/graphql-server'; + +import directives from 'src/directives/**/*.{js,ts}'; +import sdls from 'src/graphql/**/*.sdl.{js,ts}'; +import services from 'src/services/**/*.{js,ts}'; + +import { db } from 'src/lib/db'; +import { logger } from 'src/lib/logger'; + +export const handler = createGraphQLHandler({ + authDecoder: authDecoder, + loggerConfig: { logger, options: {} }, + directives, + sdls, + services, + + onException: () => { + // Disconnect from your database with an unhandled exception. + db.$disconnect(); + } +}); +``` + +## Applicability Criteria + +RedwoodJS < v4.0.0 + +## Other Metadata + +### Codemod Version + +v1.0.0 + +### Change Mode + +**Assistive**: The automation partially completes changes. Human involvement is needed to make changes ready to be pushed and merged. + +### **Codemod Engine** + +[jscodeshift](https://github.com/facebook/jscodeshift) + +### Estimated Time Saving + +~5 minutes per occurrence + +### Owner + +[Rajasegar Chandran](https://github.com/rajasegar)