Skip to content

Commit

Permalink
fix(auth): loadRouters
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Jan 4, 2024
1 parent 4a2a2f4 commit 356fff4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/medusa-plugin-auth/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import AzureStrategy from '../auth-strategies/azure-oidc';

import { AuthOptions, AuthOptionsWrapper, handleOption } from '../types';

export default async function (rootDirectory, pluginOptions: AuthOptions[]): Promise<Router[]> {
export default async function (rootDirectory, pluginOptions: AuthOptions | AuthOptions[]): Promise<Router[]> {
const configModule = loadConfig(rootDirectory);
return loadRouters(configModule, pluginOptions);
}

async function loadRouters(configModule: ConfigModule, options: AuthOptionsWrapper[]): Promise<Router[]> {
async function loadRouters(
configModule: ConfigModule,
options: AuthOptionsWrapper | AuthOptionsWrapper[]
): Promise<Router[]> {
const routers: Router[] = [];

for (const opt of options) {
const options_ = Array.isArray(options) ? options : [options];
for (const opt of options_) {
const option = await handleOption(opt, configModule);

switch (option.type) {
Expand Down

0 comments on commit 356fff4

Please sign in to comment.