#NodeJS

Starting a Miroservices Project with NodeJS and Docker

If you are planning to build a project with Microservices pattern and DevOps culture, you can use the source code here.

In this source code, I built two services, one for Frontend AngularJS and Bootstrap, one for Backend ExpressJS and Mongoose. All services in this project is dockerized and pushed to Docker Hub. You can read Dockerfile in each service for further details. To create a new service, you just create a new directory, writing source code for that service and update docker-compose.yml file.

Run

The Orchestration of Project is written in docker-compose.yml file. So it is so easily to understand and run the project.

Using Vagrant and Virtualbox

We also start from Virtual Machine layer with Vagrant.

After that, you can access the application via link: http://172.20.20.20

You can read Vagrantfile to understand what we need to prepare for VMs.

System Architecture

With the source code, we will have a system architecture as below

Microservices DevOps Starter Project

Microservices DevOps Starter Project

 

Monitor & Logs

This starter project also fully supports monitor by using Telegraf, InfluxDB, Grafana and Kapacitor. Supports centralizing Logs with fluentd, Kibana and Elasticsearch.

Contents

Part Title Git Tag
1 Starting with ExpressJS 1.0
2 Logger with Winston 1.1
4 Config Management with Node-Config 1.2
5 Building Create User API 2.1
6 Adding Swagger Documents 2.2
7 Building Login API 2.3
8 Building Get User List/Detail API 2.4
9 Authorization all APIs 2.5
10 Unit Test 2.6
11 Building Config API 3.0
12 Using Cache 3.1
13 Using Queue 3.2
14 Starting AngularJS with Yeoman 4.0
15 Config Management for AngularJS 4.1
16 Building Login Page 4.2
17 Building List User Page 4.2
18 Pagination with AngularJS and Bootstrap 4.3
19 Multiple Languages 4.4
20 AngularJS Unit Test 4.5
21 Dockerize Aplication 5.0
22 Orchestration with Docker Compose 5.1

Upload images using AngularJS and NodeJS

This post will show you how to upload images using AngularJS and NodeJS.  In the client-size (AngularJS), we use ngFileUpload plugin. And in the server-side, we use ExpressJS 4.0.

At the first, we create a upload file service in the client-side:

And In your Angular Controller, you inject Files service and write the upload function as below:

In the server side, you need to create a upload API. And the post “How to upload file with NodeJS and ExpressJS” will help you do that

How to upload files with NodeJS and ExpressJS 4

It is quite long time, I have no new post.  Today, I will show you the way to upload files by using NodeJS.  In my way, I used connect-busboy packet and ExpressJS 4.0.

91a7a01f-9f70-4d88-ae95-bd0dd22b3c63-medium

In the new world, it is not the big fish, which eats the small fish, it’s the fast fish which eats the slow fish

At the first, create the directory tree as below:

See app.js:

See index.js file:

See upload.js file:

Now, you can run upload file application:

And if you want to view the uploaded images, you should use the source code below in app.js:

 

Starting to build a Admin Site with AngularJS and NodeJS

I would like to announce that I started building a simple Admin Site from AngularJS and NodeJS.  With this seed project, I hope that It will help you easily create a Admin Site.

e43c716c-5df4-4b2d-b208-a36ff032cb17-medium

The man who does more than he is paid for, will soon be paid for more than he does

Util now, The development still have not yet finished. I will update features in the free time and write the document to make it perfect day by day.

The features are supported or will be supported includes:

  • Login Page
  • Registration Page with email notification
  • User Profile
  • User Custom Field
  • Terms and Taxonomies
  • Privileges
  • Multiple Languages
  • CI/CD

Demo link at http://angular-admin-seed.sonnguyen.ws/

Github Source Code at:  https://github.com/thanhson1085/angular-admin-seed

I really hope that this open source will become helpful for all of you who use it.

Combines all swagger documents in microservices

If you are building a microservices system and using swagger as an API Document. You may have many API documents, per service an API document.

I met the same case as above, and I develop a tool to help me combine all documents to only one document. You can see it here.

Skills are cheap. Passion is priceless

Skills are cheap. Passion is priceless

Configuration

Create sample configuration file:

cp -R node_modules/swagger-combined/config .

And see config/default.json as below:


 

  • docs: swagger document links
  • base_path: Proxy Target
  • route_match: Routes for proxy

Change config/default.json to match your swagger links

node node_modules/swagger-combined/app.js

Please make note that you changed config/default.json to match all swagger document links you have

In the default, swagger-combined run on port 3000 and included swagger-ui. So you just run http://localhost:3000 to see everything you need

Github

https://github.com/thanhson1085/swagger-combined

Demo

https://swagger-combined.sonnguyen.ws/