GithubHelp home page GithubHelp logo

mindsers / yabf Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.17 MB

Yet Another Basic Framework for NodeJS

Home Page: https://www.npmjs.com/package/yabf

License: MIT License

JavaScript 0.40% TypeScript 99.60%
framework javascript nodejs typescript

yabf's Introduction

Hi there πŸ‘‹

I'm NathanaΓ«l Cherrier. I'm a full-time software engineer passionate about writing clean, beautiful and well-designed code. On my free time, I try to give back to open source by maintaining open source projects and contributing to others.

I'm also a tech content creator. I write tech posts, courses and tutorials to help people from beginner to advanced to learn and grow as a developer.

A few fun facts about me :

  • πŸ”­ I’m currently working on the mobile app of Steply
  • 🌱 I’m currently learning Infrastructure as Code
  • πŸ‘― I’m looking to collaborate on JS and Swift projects
  • πŸ€” I’m looking for help with Changelog Reader (GH Action)
  • πŸ’¬ Ask me about anything dev related
  • πŸ“« How to reach me: on my website contact forms
  • πŸ˜„ Pronouns: he/his

yabf's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

yabf's Issues

Injection error

When we use the package as base for other service we always get an error/warning at launch of the app.

Unable to register Function

Steps to reproduce

  • install Yabf
  • use it as the main framework
  • start the app

Expected behavior

As this error is a Yabf error and not a child error, we should be able to hide it.

Actual behavior

We always get an error/warning at launch of the app.

System configuration

OS and version: macOS v10.14.2

NodeJS version: v11.2.0

Yarn version: v1.12.3

Default router service is undefined

Yabf doesn't recognize his router service. It seems to be undefined.

Steps to reproduce

  • yarn add yabf
  • Create index.js with minimal code
      import { APP_CONFIG, Application } from 'yabf'
    
      import { CONFIG } from './config'
    
      (() => {
        const app = Application.createInstance()
    
        app.provide({ identity: APP_CONFIG, useValue: CONFIG })
    
        app.start()
      })()
  • yarn start

Server doesn't start and kill itself..

Expected behavior

The server should start and listen to the default port for HTTP request.

Actual behavior

The server thrown an error and stops:

 WARN: No data regitered with key : Function
 /usr/src/app/node_modules/yabf/dist/application/web-application.class.js:26
             this.routerService.enableCORS(config.cors.origins, config.cors.headers);
                               ^

 TypeError: this.routerService.enableCORS is not a function
     at WebApplication.start (/usr/src/app/node_modules/yabf/dist/application/web-application.class.js:26:32)
     at /usr/src/app/dist/index.js:8:9
     at Object.<anonymous> (/usr/src/app/dist/index.js:9:3)
     at Module._compile (internal/modules/cjs/loader.js:722:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
     at Module.load (internal/modules/cjs/loader.js:620:32)
     at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
     at Function.Module._load (internal/modules/cjs/loader.js:552:3)
     at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
     at startup (internal/bootstrap/node.js:300:19)
 error Command failed with exit code 1.
 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

System configuration

OS and version: macOS X 10.14.2

NodeJS version: 11.2.0

Yarn version: 1.12.3

Use rxjs

Currently YABF uses promises to handle async task. RXJS maybe simplify the code and provide more capabilities to the user.

Error message not clear at Application creation time

Describe the bug
At custom Application creation, if no build instructions are provided an error is thrown. But this message fail to specify which application class cannot be instantiated.

The name of the class is replaced by "Function" in the error message.

To Reproduce
Steps to reproduce the behavior:

  1. Create a class which extends AbstractApplication
  2. Return an empty array in buildInstructions
  3. Call <YourClass>.createInstance()
  4. See error

Expected behavior
The message should show the real name of the class-to-be-instanciated

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS
  • Browser chrome
  • Version 73

Additional context
N/A

Application class isn't usable out of Yabf

We recently externalize some common behaviors of applications inside an abstract class called Application. It's a great idea but it's not working.

Two cases:

  • createInstance need to be implemented in Application. Having to implements it in each child cause duplication of code. Only the dependencies array may change sometimes. Also it is impossible to really implement it because InjectorService is not exposed outside of Yabf.
  • It impossible to inherit from Application because it needs InjectorService as first argument. So, even if we don't use the createInstance method we can't use Application as mother class.

Solutions

For the first case, we may use the Template Pattern as proposed in #15. We could encapsulate all the logic around InjectorService and ask children for dependency list.

For the second case, we may use an interface instead of a class. If we do that we allow people to use other DI services if they respect the interface.

Write documentation

Need to write missing documentation about all the code on the first release.

Write documentation about updated code

Unusable controller class

Controller class use too restrictive index signature :

[action: string]: IAction|Routes[]

It limites possibilities on properties, methods creation : we can't add private method that not respect index signalions, unable to inject service in constructor...

We need to remove this restriction.

Add a proper logger

Add a proper logger and more log messages for debugging purpose.

We need to be able to show/hide messages using environment vars and depending on scope. (e.i. visionmedia/debug)

Wrong use of 'this' for static method

Source: root/src/application/abstract-application.class.ts
Problem: Access to instance method constructor from static method createInstance is not possible through this.

if (appData == null) {
  throw new MissingBuildInstruction(`Unable to build ${this.constructor.name}. Build instruction is missing.`) through `this`.
}

Unused variable, import, function or class

Source: root/src/application/web-application.spec.ts
Problem: Unused variable app.

test('starting', t => {
  t.notThrows(() => {
    const app = new WebApplication(
      {} as InjectorService,
      {} as RouterService,

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.