Skip to content

Commit

Permalink
fix: round robiin error with medusa
Browse files Browse the repository at this point in the history
  • Loading branch information
Govind Diwakar committed Nov 3, 2023
1 parent 372af65 commit 6a3d275
Show file tree
Hide file tree
Showing 19 changed files with 21,063 additions and 5,757 deletions.
21,571 changes: 16,362 additions & 5,209 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions packages/medusa-plugin-strapi-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-strapi-ts",
"version": "5.0.4",
"version": "5.0.15",
"description": "A plugin for medusa to use strapi in the backend as the cms in typescript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -19,8 +19,8 @@
"e-commerce",
"content management"
],
"funding":{
"type":"github",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/SGFGOV"
},
"author": "Govind Diwakar",
Expand All @@ -33,7 +33,7 @@
"test": "jest --coverage --runInBand --setupFiles=dotenv/config "
},
"devDependencies": {
"@medusajs/medusa": "^1.8.2",
"@medusajs/medusa": "^1.16.1",
"@strapi/plugin-users-permissions": "^4.6.1",
"@types/express": "^4.17.17",
"@types/jest": "^27.4.0",
Expand Down Expand Up @@ -67,7 +67,8 @@
"typescript": "^4.9.5"
},
"peerDependencies": {
"@medusajs/medusa": "^1.8.2",
"@medusajs/admin": "^7.1.2",
"@medusajs/medusa": "^1.16.1",
"@strapi/plugin-users-permissions": "^4.6.1",
"axios": "^0.27.2",
"medusa-interfaces": "latest",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import UpdateMedusaService from '../../../services/update-medusa';
import * as jwt from "jsonwebtoken";
import {ConfigModule} from "@medusajs/medusa/dist/types/global";
import {StrapiSignalInterface} from "./strapi-signal";
import * as jwt from 'jsonwebtoken';
import { ConfigModule, Logger } from '@medusajs/medusa/dist/types/global';
import { StrapiSignalInterface } from './strapi-signal';

export interface UpdateMedusaDataInterface {
type: string;
data: any;
origin: 'strapi' | 'medusa';
}


export default async (req, res, next) => {
const config = req.scope.resolve('configModule') as ConfigModule;
const updateMedusaService = req.scope.resolve('updateMedusaService') as UpdateMedusaService;

const logger = req.scope.resolve('logger') as Logger;
try {
const medusaSecret = config.projectConfig.jwt_secret;
const signedMessage = req.body['signedMessage'];
Expand All @@ -21,9 +21,16 @@ export default async (req, res, next) => {

// find Strapi entry type from body of webhook
const strapiType = body.type;
const origin = body.origin;
// get the ID
let entryId: string;

if (origin == 'medusa') {
res.sendStatus(200);
logger.info('received update confirmation');
return;
}

let updated = {};
switch (strapiType) {
case 'product':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export default (app, options, config: ConfigModule) => {
/*app.set('query parser', (queryString) => {
return new URLSearchParams(queryString);
});*/
contentRouter.options('/:type/:id', (req, res, next) => {
res.setHeader('Allow', 'GET').sendStatus(200);
});
contentRouter.options('/:type', (req, res, next) => {
res.setHeader('Allow', 'GET').sendStatus(200);
//next();
});
contentRouter.get('/:type/:id', fetchContent);
contentRouter.get('/:type', fetchContent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cors from 'cors';

import authenticate from '@medusajs/medusa/dist/api/middlewares/authenticate';
import { StrapiMedusaPluginOptions } from '../../../types/globals';
import { ConfigModule } from '@medusajs/medusa/dist/types/global';
import { ConfigModule } from '@medusajs/types';
import { UserService } from '@medusajs/medusa';

const adminRouter = Router();
Expand All @@ -29,7 +29,7 @@ export default (app: Router, options: StrapiMedusaPluginOptions, config: ConfigM
if (process.env.NODE_ENV != 'test') {
adminRouter.use(cors(adminCors));
}
const jwtSecret = config.projectConfig.jwt_secret;
const jwtSecret = config.projectConfig.jwt_secret || (config.projectConfig as any).jwtSecret;
adminRouter.options('/login', cors(adminCors));
adminRouter.get('/login', cors(adminCors));
adminRouter.get('/login', authenticate());
Expand Down
Loading

0 comments on commit 6a3d275

Please sign in to comment.