nut-ioc npm package is a simple, lightweight and fast IoC Container Framework.
nut-ioc injects dependencies run-time so that developers don't need to require modules.
Developers can implement in their codes following OOP basics, principles, patterns and concepts and probably more than that 🙂
Separation of Concern(SoC) Single Responsibility Principle(SRP) Open Closed Principle Dipendency Inversion(Injection) Principle(DIP) Chain of Responsibility Pattern Aspect Oriented Programming
you can reach github repository.
Installing nut-ioc with npm npm i nut-ioc
Demo GitHub Repository
You can find different usages of nut-ioc framework in separate brances.
Branch list load-dependencies-with-dependencyPath load-dependencies-with-dependencyPath-and_dynamically load-dependencies-with-different-loaders load-dependencies-with-interceptors load-dependencies-with-new-loaders-and-filters load-dependencies-with-programatic-notation nut-swagger-usage Continue reading
nut-swagger npm package is a light-weight and flexible library to generate Node.js controller modules from swagger definition file. The controller modules generated by this npm package is also used by nut-ioc
you can reach github repository.
https://github.com/nodejs-projects-kenanhancer/nut-swagger Continue reading
Downloading and Installing Maven
if you want to download
Maven manually, download it from http://maven.apache.org/download.cgi
But you can download
Maven programmatically as the following. So, run below script in your terminal.
tar -xzvf apache-maven*bin.tar.gz
# Fix the permissions:
# chown -R root:wheel Downloads/apache-maven*
mv apache-maven* /usr/local/apache-maven
Setting environment variables in zsh
If you are using zsh, then run the following script in your terminal.
Setting environment variables in bash
# add these three lines at the end of file and CTRL+X and Y and click enter :)
Check Maven Version
# Verify if Maven is running
tar -xzf kafka_2.11-1.1.0.tgz
Starting Zookeeper and kafka
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
bin/kafka-topics.sh --list --zookeeper localhost:2181
Send some messages to Kafka
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
bin/kafka-console-producer.sh --zookeeper localhost:2181 --topic test
Consume messages from Kafka
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
Downloading and Installing Java from OpenJDK
if you want to download OpenJDK manually, download it from
But you can download JDK programmatically as the following.
Java SE 7, 8, 9, 10, 11, 12, 13 are included below script. So, run below script in your terminal.
# Java SE 7
# Java SE 8
# Java SE 9
# Java SE 10
# Java SE 11
# Java SE 12
# Java SE 13
# Extract all downloaded jdk files
tar -xvzf openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-8u40-b25-linux-x64-10_feb_2015.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-9.0.4_linux-x64_bin.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-10.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-11.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-12.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm
tar -xvzf openjdk-13_linux-x64_bin.tar.gz -C /usr/lib/jvm
# Remove downloaded jdk files
# Install Java and Java Compiler to Environment
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-se-7u75-ri/bin/java 1
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-se-7u75-ri/bin/javac 1
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-se-8u40-ri/bin/java 2
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-se-8u40-ri/bin/javac 2
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-9.0.4/bin/java 3
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-9.0.4/bin/javac 3
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-10.0.2/bin/java 4
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-10.0.2/bin/javac 4
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.2/bin/java 5
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.2/bin/javac 5
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-12.0.2/bin/java 6
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-12.0.2/bin/javac 6
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13/bin/java 7
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13/bin/javac 7
# Verify Java and Java Compiler Installation
# check if java command is pointing to correct path in system
update-alternatives --display java
update-alternatives --display javac
# List all environment variables
update-alternatives --get-selections | grep java
update-alternatives --get-selections | grep ^java
Check Java Version
# Verify if Java is running
# Verify if Java Compiler is running
There are some new features in ES6(ECMAScript 2015) like the following. But, we will focus on classes.
Class Declaration Syntax
Instance properties must be defined inside of class methods.
I already mentioned many details in the following link. So I don't want to duplicate everything in this post one more time.
You can reach github project from the following link.
You can reach Babel 6.x post from the following link.
Creating Babel configuration file
nut-pipe npm package is an implementation of Chain of Responsibility Pattern. We can encapsulate or wrap every aspect of code in separate module or class or function, etc. So that, separated aspect modules would implement Single Responsibility Principle(SRP) and Seperation of Concern Principle(SoC) properly.
🙂 so if you want to implement OOP basics and principles, then you can use
nut.pipe npm package.
This design provides to developer clean business logic code. They don't need to think about Error, Exception, Log handling business logic. Before their business logic code is called, pipeline is called and it means first middleware is triggered then first middleware will trigger next one, but no middleware knows about next middleware. Middleware should know about its business logic then should call next one.
I know too much words but developers want to see code 🙂 same code will be developed in different ways.
Code example v1
I wrote a greeting service with
sayHello() and sayGoodbye() functions. They include all business logic in their body. This is not good approach definitely. Code duplications are everywhere 🙂 For example, every functions have try/catch, console.log('ENTRY: …'), console.log('SUCCESS: …'), console.log('ERROR: …'), etc. Notice that getFullName doesn't contain these business logics. So, we can't know whether it is called or not. If developer like me 🙂 doesn't write these kind of aspects(logging and exception handling is kind of aspect) then we never understand that that method is called in run-time. Continue reading
Asynchronous functions always return a
Promise. So, I added following promise example firstly.
The following three examples are doing same job. I used function statement and arrow function in Promise.
Promise with Function Declaration(Function Statement)
Promise with Arrow Function
Async Function Declaration(Function Statement)
Async Function Expression
Async Arrow Function
So, this is very very useful post for me. I hope that it will help any developers who need this kinds of collective documentation. Continue reading