Skip to main content

Posts

Showing posts from 2019

Differential Loading in Angular

Differential Loading in Angular Angular is a complete javascript framework with many inbuilt features like routing, dependency injection, form validation but the downside is the application bundle size. In order to overcome this issue, Angular 8 introduces the concept of differential loading. Until angular 7 versions, when we do an ng build command, the typescript files are converted into js files that can support both modern and old browsers. Since the build bundle should contain js files for new and old browsers, this results in huge bundle sizes. With angular 8 Differential loading, when we do an ng build two different bundles are created one for modern browsers (supports recent syntax changes in JavaScript such as arrow functions in ES2015 or async functions in ES2017) and other for older browsers (es5 ex. IE) When the app is deployed, both the bundles get deployed and based on the browser the clients opens the app from, the specific bundle gets loaded by the browser Basically, Dif

Angular - nvm (Node Version Manager)

nvm - Node Version Manager Node Version Manager helps you to install different Node versions and easily switch between different versions.  How to Install Node Version Manager? Install Node Version Manager from this link -  https://github.com/coreybutler/nvm-windows/releases/tag/1.1.7  (nvm-setup.zip) Open Command Prompt in Admin mode and perform the below steps,  Common Issues: Error Message:  This usually happens because your environment has changed since running 'npm install'. Run 'npm rebuild node-sass' to download the binding for your current environment. Solution: node-sass install steps -    1. npm -g uninstall node-sass    2. npm -g i node-sass    3. npm rebuild node-sass (in the app location)

Javascript vs TypeScript

JavaScript vs TypeScript Javascript   - Client-side programming language to create interactive web pages.  But it has a few disadvantages. As code grows, it becomes difficult to maintain and reuse code It doesn't support Object Orientation, strong type checking and compile-time error checks Can be used for small applications with the minimal code base, but not effective when application code grows. Typescript  - A modern age Javascript development language which can run on node.js or any browser which supports ECMAScript3 or above.  Features: Superset of Javascript Optionally typed scripting language . Typescript variable with no type will be inferred by Transcript Language Service(TLS) based on its value. Supports Object-oriented programming techniques like classes, interface, inheritance, subclasses etc.. Rich IDE available with autocomplete and code navigation features Compilation - Typescript transpiler provides error checking feature. It compiles the code, generates any syn

PCF - Blue Green Deployment

BLUE GREEN DEPLOYMENT PCF Blue-Green deployment is a technique to reduce the downtime of applications during deployment and also reduce the risk ie. if something unexpected happens we have an option to roll back to the previous version by switching back There are two identical production environments running called Blue(live) and Green(idle) and at any time only one of the environments is live.  When a new version of the app/software needs to be deployed, final stage of testing happens in the green environment and once it is fully tested, we can switch the router so all incoming requests now go to Green instead of blue. Green is now live and Blue is idle. For more details, please refer pivotal resource link -  https://docs.pivotal.io/pivotalcf/2-5/devguide/deploy-apps/blue-green.html

Angular - NGINX - PCF Integration

NGINX - PCF Nginx is a web server that can be used as a reverse proxy, load balancer, HTTP Cache etc.  In order to deploy apps with NGINX configuration, you need to have an Nginx.conf file in your app so that PCF uses it when deploying. Uses -     1. To get the PCF Environment variable for respective environments to manage them in Angular apps    2. To set the page refresh order before throwing 404 error An example nginx.conf file is shown below. You can configure the way you want based on your requirements and need.

Angular - Useful Extensions

There are a lot of useful extensions that can be used to improve productivity while developing Angular applications. Some useful extensions listed below,

Working with MongoDB in .Net Core (Part 5) - Mongo Queries

Mongo Aggregation pipeline Queries //Pipeline Query use Collection; db.getCollection(collectionName).aggregate( [ { " $match " : { " {field1} " : { " $eq " : " string " }, " {field2} " : { " $eq " : " string " } }, }, { " $group " : { " _id " : " $field " , " Count " : { " $sum " : 1.0 }, " Results " : { " $addToSet " : " $field " } } }, { " $sort " : { " Count " : -1.0 } }, { " $project " : { " count " : 1.0, " _id " : 1.0, " AccountId " : 1.0 } } ],

SwashBuckle - Swagger Open API Documentation

Swashbuckle Open API Swagger is Open API documentation used to understand the various methods and the request/responses of various endpoints. It generates the Web API SDK for clients. Swashbuckle .AspNetCore is an open-source project for generating Swagger documents for ASP.Net Core Web APIs.  Another open-source project is  NSwag  for generating swagger documents. Enable Swagger in .NET Core Apps -  Note - Install the  Swashbuckle.AspNetCore NuGet package  into your solution.Don't install Swashbuckle.AspNetCore.Swagger package) Add the below to the Configure() Method -  app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "AppName"); }); using Swashbuckle.AspNetCore.Examples ; using Swashbuckle.AspNetCore.Swagger ; public void ConfigureServices (IServiceCollection services) { // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { var appVersion

Working with MongoDB in .Net Core (Part 3) - Definitions and Builders

                 Mongo Queries - C# Driver Writing Complex Mongo Queries using Aggregation - Builders and BsonDocuments Builders -  1 2 3 4 5 6 7 8 9 10 11 12 //Filter Definition Builder var builder = Builders<T>.Filter; var filter = builder.Ne(_=>_.{field}, true ); filter = filter & builder.Eq(_=>_.{field}, value ); filter = filter & builder.Gte(_=>_.{field}, value ); filter = filter & builder.Lte(_=>_.{field}, value ); filter = filter & builder.In(_=>_.{field}, value ); filter = filter & builder.In(_=>_.{field}, new List< string > { value1, value2}); filter = filter & builder.AnyEq(_=>_.{field}, value ); filter = filter & builder.Or(_=>_.{field}, value ); filter = filter & builder.And(_=>_.{field}, value ); filter = filter & builder.ElemMatch(_=>_.{field}, t => t.Id == Id, t.Key == Key); 1 2 3 4 5 6 7 8 9 //Sort Definition Builder var sortfilter = Builders<T>.Sort.Descen

Working with MongoDB in .Net Core (Part 2) - Mongo Collection Base

Mongo Repository - C# Here we introduce an encapsulation called BaseRepository which every other repository created in the application uses to perform Mongo database Operations. BaseRepository 1 2 3 4 5 6 7 8 9 public abstract class BaseRepository <T> { private readonly IMongoCollection<T> _collection; public BaseRepository (IMongoConnectionManager connectionManager, string collectionName) { _collection = connectionManager.GetCollection<T>(collectionName) } } Mongo Database Operation Types //FindAsync - GetMany and GetSingle protected async Task<T> GetSingle(FilterDefinition<T> filter, FindOptions<T,T> options = null ) { var retval = await _collection.FindAsync(filter, options).ConfigureAwait( false ); return retval.FirstOrDefault(); } protected async Task<T> Get(FilterDefinition<T> filter, SortDefinition<T> sort = null ) { var retval = await _collection.FindAsync(filter, new

Working with MongoDB in .Net Core (Part 1) - Mongo Connection Manager

Connecting to Mongo Database C# Mongo DB is a NoSQL document-oriented database which stores data in a JSON-like format. Mongo DB stores the data in a binary-encoded format called BSON. Every application connecting to Mongo DB will have a Mongo connection manager to create Mongo Clients and connect to database and collection to perform CRUD operations. Here is a sample of how a Mongo Connection manager would look like, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 using MongoDB.Bson ; using MongoDB.Bson.Serialization.Conventions ; using MongoDB.Driver ; public class MongoConnectionManager : IMongoConnectionManager { public IMongoClient client { get ; set ;} private readonly MongoDBConfigSettings _mongoDBSettings; //Setup Mongo Client in the connection Manager constructor when the instance is created, so that it can be dependency injected into other classes public MongoConnectionManager (IOptions<MongoDBConfigSettings> mongoDBSettings) { m