Code Monkey home page Code Monkey logo

magellan's People

Contributors

dreamora avatar eins78 avatar jwloka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

magellan's Issues

magellan serve supports dynamic paths

Story

As Frontend Developer I want to have static + dynamic path support for magellan serve, so that I can use React's BrowserRouter.

AC

  • static path for static assets can be configured
  • default all dynamic

Errors thrown by @service functions do not yield a promise.reject on the frontend

Bug Report

When // @service annotated functions cause an error to be thrown in their backend execution. The frontend does not correctly reject the promise (as expected and documented) but instead an {error, message} object is resolved, breaking the code flow.

This appears to be caused by changes that took place along the TransportHandler implementation.

๐Ÿ•— Version & Regression Information

  • This is the behavior in every version I tried

๐Ÿ’ป Code

Function outside services directory

import {throwsError} from "./throws-error.ts";

export const executeFunction = async (): Promise<string> => {
  try {
    return await throwsError();
  } catch (e) {
    const err = e as Error;
    console.error(`Function 'throwsError' has thrown error ${err.message}`);
  }
}

Service function in a services directory.

// @service()
export const throwsError = async (): Promise<string> => {
    if (Math.random() > 0.999) {
        return "success";
    }
    throw new Error("This should not be provided as the return value");
};

๐Ÿ™ Actual behavior

When the function is called and the Random value is <= 0.999, throwsError() does not fail try-catch and instead returns an {error, message} object.

๐Ÿ™‚ Expected behavior

When the function is called and the Random value is <= 0.999, the console.error from the 'catch' clause is written.

Cyclic module dependencies in client / server between transport and configuration/services

Bug Report

Currently, there are cyclic dependencies between src/transport and src/configuration / src/services which express themselfes through the need to mock formdataFetch in client/src/config/configuration-repository.spec.ts, server/src/config/configuration-repository.spec.ts and server/src/services/FunctionService.spec.ts (see commit 59e6f5c)

This will negatively impact the ability to chunk code with @quatico/magellan-client and @quatico/magellan-server dependencies.

๐Ÿ”Ž Search Terms

  • cyclic dependency
  • "formdataFetch" not initialized

๐Ÿ•— Version & Regression Information

After replacing the ts-jest transformer with @swc/jest

๐Ÿ™ Actual behavior

formdata-fetch => formdataFetch mocks are necessary to execute jest tests with @swc/jest.

๐Ÿ™‚ Expected behavior

tests do not require to mock away the dependency on formdataFetch to avoid issues with cyclic dependencies.

Client custom configuration causes error when incomplete

Description

When the default client configuration is replaced with an incomplete configuration, for example during bundling, then magellan does not correctly complete the configuration as it does normally.

Example

magellan.config.js

module.exports = {
    namespaces: { default: { endpoint: "/api", transport: "default" } },
};

Replace the default client config using webpack's NormalModuleReplacementPlugin
webpack.config.js

        new webpack.NormalModuleReplacementPlugin(
            /node_modules\/@quatico\/magellan-client\/lib\/configuration\/config.js/,
            join(__dirname, "magellan.config.js")
        ),

Experienced behavior

An error is thrown

default-configuration.js:23 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at completeConfig (default-configuration.js:23:1)
    at getDefaultConfiguration (default-configuration.js:14:1)
    at getConfiguration (configuration-repository.js:17:24)
    at resolveNamespace (namespace.js:50:1)
    at transport-request.js:25:35
    at Generator.next (<anonymous>)
    at tslib.es6.js:76:1
    at new Promise (<anonymous>)
    at Module.__awaiter (tslib.es6.js:72:1)

Expected behavior

The default transport is correctly added to the configuration when loaded.

Enhancement of package and release structure

To enhance the package structure in both the context of the end user and the internal knowledge, I would like to propose the following restructure of the Magellan packages and alteration of which packages will be released publically:

Current

image

Future

image

This will enable focused changes for public API (CLI, webpack and client / server api modules) while isolating the inner workings enabling easier and more reliable iterations.

magellan-server does not depend on tslib (but requires)

Bug Report

When using magellan-server serve function, tslib is required but can't be found. It should be added to the package.json dependencies.

๐Ÿ”Ž Search Terms

tslib

๐Ÿ•— Version & Regression Information

  • no blocker, I can run yarn add tslib

๐Ÿ’ป Code

echo '{}' > package.json
yarn add "@quatico/[email protected]"
node -p 'require("@quatico/magellan-server").serve()'

๐Ÿ™ Actual behavior

๐Ÿ’ฃ

โฏ node -p 'require("@quatico/magellan-server").serve()'
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'tslib'
Require stack:
- /private/tmp/magrep/node_modules/@quatico/magellan-server/lib/configuration/configuration-repository.js
- /private/tmp/magrep/node_modules/@quatico/magellan-server/lib/configuration/index.js
- /private/tmp/magrep/node_modules/@quatico/magellan-server/lib/index.js
- /private/tmp/magrep/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/private/tmp/magrep/node_modules/@quatico/magellan-server/lib/configuration/configuration-repository.js:10:17)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/tmp/magrep/node_modules/@quatico/magellan-server/lib/configuration/configuration-repository.js',
    '/private/tmp/magrep/node_modules/@quatico/magellan-server/lib/configuration/index.js',
    '/private/tmp/magrep/node_modules/@quatico/magellan-server/lib/index.js',
    '/private/tmp/magrep/[eval]'
  ]
}

๐Ÿ™‚ Expected behavior

โฏ node -p 'require("@quatico/magellan-server").serve()'
/private/tmp/magrep/node_modules/@quatico/magellan-server/lib/server.js:26
    const { port = (0, exports.normalizePort)(process.env.PORT) } = options;
            ^

TypeError: Cannot read properties of undefined (reading 'port')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.