diff --git a/packages/api/scripts/cli.js b/packages/api/scripts/cli.js index d866662cee..d4d771aa9d 100644 --- a/packages/api/scripts/cli.js +++ b/packages/api/scripts/cli.js @@ -33,7 +33,6 @@ prog outfile: path.join(__dirname, '..', 'dist', 'worker.js'), legalComments: 'external', inject: [path.join(__dirname, 'node-globals.js')], - loader: { '.js': 'jsx' }, plugins: [ { name: 'alias', diff --git a/packages/api/src/error-handler.js b/packages/api/src/error-handler.js index 40e01722ba..d7ee45302f 100644 --- a/packages/api/src/error-handler.js +++ b/packages/api/src/error-handler.js @@ -28,15 +28,15 @@ export function errorHandler (err, { log }, request) { return new JSONResponse(error, { status }) } - if (err instanceof HTTPError) { - return new JSONResponse(err, { status }) - } - let error = { code: err.code, message: err.message } + if (err instanceof HTTPError) { + return new JSONResponse(error, { status }) + } + switch (err.code) { // Magic SDK errors case MagicErrors.TokenExpired: diff --git a/packages/api/test/user.spec.js b/packages/api/test/user.spec.js index c4c4302d16..ad85fdac53 100644 --- a/packages/api/test/user.spec.js +++ b/packages/api/test/user.spec.js @@ -605,7 +605,6 @@ describe('userLoginPost', function () { assert.equal(typeof responseJson, 'object', 'response can be parsed as json') assert.ok(responseJson.message.includes('new user registration is closed'), 'response object message indicates new user registration is closed') assert.equal(responseJson.code, 'NEW_USER_DENIED_TRY_OTHER_PRODUCT') - assert.equal(responseJson.otherProduct, 'https://console.web3.storage/') }) }) })