All Projects → brainhubeu → Hadron

brainhubeu / Hadron

Licence: mit
⚛️Framework for building a testable, modular backend with a dependency injection pattern in plain JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Hadron

Apollo
Java libraries for writing composable microservices
Stars: ✭ 1,632 (+1108.89%)
Mutual labels:  framework
Meshki
Meshki: A Black-Colored, Responsive Boilerplate for UI Development
Stars: ✭ 129 (-4.44%)
Mutual labels:  framework
Parlour
A package of UI extensions, components and improvements for Unity's UI frameworks.
Stars: ✭ 132 (-2.22%)
Mutual labels:  framework
Notification
WordPress Notification plugin
Stars: ✭ 128 (-5.19%)
Mutual labels:  framework
Xnode
Unity Node Editor: Lets you view and edit node graphs inside Unity
Stars: ✭ 2,077 (+1438.52%)
Mutual labels:  framework
Unity Raymarching Framework
A framework to easy implement raymarching in unity. Include lots of hash,noise,fbm,SDF,rotate functions
Stars: ✭ 129 (-4.44%)
Mutual labels:  framework
Ocpp
Python implementation of the Open Charge Point Protocol (OCPP).
Stars: ✭ 127 (-5.93%)
Mutual labels:  framework
Pyrogram
Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots
Stars: ✭ 2,252 (+1568.15%)
Mutual labels:  framework
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+1198.52%)
Mutual labels:  framework
Framework
Lightweight PHP framework
Stars: ✭ 131 (-2.96%)
Mutual labels:  framework
Panic Server
Testing for collaborative apps and tools
Stars: ✭ 128 (-5.19%)
Mutual labels:  framework
Involt
Inject hardware interactions directly into HTML layout.
Stars: ✭ 128 (-5.19%)
Mutual labels:  framework
Facelandmarksdetection
Finds facial features such as face contour, eyes, mouth and nose in an image.
Stars: ✭ 130 (-3.7%)
Mutual labels:  framework
Hanu
Golang Framework for writing Slack bots
Stars: ✭ 128 (-5.19%)
Mutual labels:  framework
Cyclejs.cn
The Cycle.js Chinese documentation website.
Stars: ✭ 132 (-2.22%)
Mutual labels:  framework
Uadmin
The web framework for Golang
Stars: ✭ 127 (-5.93%)
Mutual labels:  framework
Zulu
Total environment manager for ZSH
Stars: ✭ 129 (-4.44%)
Mutual labels:  framework
Dedsploit
Network protocol auditing framework
Stars: ✭ 133 (-1.48%)
Mutual labels:  framework
Wookiee
Scala based lightweight service framework using akka and other popular technologies.
Stars: ✭ 132 (-2.22%)
Mutual labels:  framework
Spasm
Write single page applications in D that compile to webassembly
Stars: ✭ 129 (-4.44%)
Mutual labels:  framework

Hadron Logo

CircleCI

Why?

Hadron's purpose is to facilitate the building of Node.js applications:

Low-level framework-agnostic

Your application is built independently from other frameworks (Express, Koa). Hadron creates a layer between HTTP requests and your app written in plain Javascript.

Hadron abstracts away underlying request and response objects, providing simple data structures as input/output of your routes' handlers, making them simple to test and easy to deal with.

Dependency injection

The dependency injection pattern enables you to easily change interface implementation. Hadron gives us the power to create SOLID applications.

Containers as a dependency management solution provides a convenient way to access all dependencies in functions.

Modular structure

The modular structure enables you to add/remove packages or create your own extensions. Hadron provides a complete solution for request processing using separate packages.

Current packages:

  • security management
  • input validation
  • database integration (through TypeORM)
  • data serialization
  • logging
  • events handling
  • CLI tool

Built with TypeScript, but it's primary target is JavaScript apps. Hadron’s API embraces current ECMAScript standards, with the cherry of good IDE support via codebase types declarations on top.

To read more about hadron check out our article: How to use Hadron?

Installation

  • Install Node.js. We recommend using the latest version, installation details on nodejs.org

  • Install following modules from npm:

npm install @brainhubeu/hadron-core @brainhubeu/hadron-express express --save

Hello World app

Let's start with a simple Hello World app. It will give you a quick grasp of the framework.

const hadron = require('@brainhubeu/hadron-core').default;
const express = require('express');

const port = 8080;
const expressApp = express();

const config = {
  routes: {
    helloWorldRoute: {
      path: '/',
      callback: () => 'Hello world!',
      methods: ['get'],
    },
  },
};

hadron(expressApp, [require('@brainhubeu/hadron-express')], config).then(() => {
  expressApp.listen(port, () =>
    console.log(`Listening on http://localhost:${port}`),
  );
});

Documentation

Hadron documentation can be found at http://hadron.pro

Getting Started

Requirements

  • Installed GIT
  • Installed node.js (we recommend using nvm to run multiple versions of node).

We recommend using latest version of node. If you want to use older versions you may need to add babel-polyfill to use some features.

Clone it

git clone [email protected]:brainhubeu/hadron.git
cd brainhub-framework-app

Install dependencies

npm install

Run development server

npm run dev

Run production server

npm start

Running tests

All tests

npm run test
# or
PORT=8181 npm run test

Unit tests

Run unit tests for each package:

npm run test:unit

Run unit tests for a single package:

npm run test:package <package name>

E2E tests

PORT=8181 npm run test:e2e

It will run test.sh script which in turn, will run app, wait for it to start listening and run npm run test:cucumber command. You need to provide the script with valid PORT or default (8080) will be used.

Linter

npm run lint        # to just show linter errors and warnings
npm run lint:fix    # to fix the errors and show what's left

Typescript types management

Note! Because we're using "noImplicitAny": true, we are required to have a .d.ts file for every library we use. While we could set noImplicitAny to false to silence errors about missing .d.ts files, it is a best practice to have a .d.ts file for every library.

  1. After installing any npm package as a dependency or dev dependency, immediately try to install the .d.ts file via @types. If it succeeds, you are done. If not, continue to next step.
  2. Try to generate a .d.ts file with dts-gen. If it succeeds, you are done. If not, continue to next step.
  3. Create a file called <some-library>.d.ts in types folder.
  4. Add the following code:
declare module '<some-library>';
  1. At this point everything should compile with no errors and you can either improve the types in the .d.ts file by following this guide on authoring .d.ts files or continue with no types.

Lerna

  1. To run npm i on all packages, and compile them, just run
  lerna bootstrap
  1. To run any command on all packages, just can use exec command. F.e. to compile all packages, you can run
  lerna exec tsc
  1. To clean all node_modules in packages, run
  lerna clean
  1. To clean all node_modules AND dist directories, run
  npm run clean
  1. To add dependency between packages, run
  lerna add <source-package-name> --scope=<target-package-name1>, <target-package-name2>
  1. To publish to npm, run
  lerna publish

To get more command, please visit this link.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].