Monday, April 27, 2020

Aws lambda

Serverless

Function as a service
I want to shut down my services at 6 pm.
Integrated with Database.

Build in fault tolerance.
Pricing: only when it is executed.

Create thumbnail function



Amazon ECS

ECS supports docker

Eliminate need to install operate your cluster.

Fleet of docker container

Fargate : managed ECS .
Next step to ECS.

Container as a Service


Aws Technical Professional Bootcamp



Edge location :
Route 53 : navigate to a certain site via edge location.
Regional Cache:
Amazon Elastic Container services
Virtualization to container
Lambda : serverless

Types of EC2
Memory Optimised
Compute optimised
Storage Optimised
GPU optimised
General Optimised

Size : large small xtra large

AMI : bootable operation system and additional software.You can take snapshot.

Families : types .









Saturday, April 25, 2020

AWS Auto Scaling



  Before getting start , lets revisit the following topics .


s

 a



a


a



s


a

s


a

s


a
s


s


 a



 a



a


Saturday, April 11, 2020

Error: Objects are not valid as a React child



Error Blog 

This blog is about the error Error: Objects are not valid as a React child 

Problem Statement

error on start of reactjs application

Error Details 

error Log

ERROR DETAILS 

Error: Objects are not valid as a React child (found: object with keys {TASK_ID, TASK_DESC, TASK_REF, TASK_STATUS, UPDATED_ON}). If you meant to render a collection of children, use an array instead. in div (at task-list.js:22) in TaskList (at App.js:10) in div (at App.js:9) in App (at src/index.js:9) in StrictMode (at src/index.js:8)



Error Code 

You will face this error if you try to convert an array response to json .



router.get('/', function (req, res) { Task.getAllTask(function (err, task) { console.log('controller') if (err) res.send(err); console.log('res', task); res.send( task); }); });





  

Solution

change the code so that the array is handled .

Code Changes 

wrap the array inside a json .

  
        
    
router.get('/', function (req, res) { Task.getAllTask(function (err, task) { console.log('controller') if (err) res.send(err); console.log('res', task); res.send({'resp':task}); }); });

         

OUTPUT
works 



Thanks for reading . Let me know your thoughts in the comments below    .

Sunday, April 5, 2020

TypeError: Class extends value undefined is not a constructor or null



Error Blog 

This blog is about the error TypeError: Class extends value undefined is not a constructor or null

Problem Statement

unable to start reactjs application

Error Details 

error Log

ERROR DETAILS 

Uncaught TypeError: Class extends value undefined is not a constructor or null
    at Module../src/task/task-list.js (task-list.js:5)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Module../src/App.js (App.css?4433:45)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Module../src/index.js (index.css?f3f6:45)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.1 (task.js:11)
    at __webpack_require__ (bootstrap:784)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1




Error Code 

You will face this error if you have improper syntax in extends React.Component.




import React from 'react';



class TaskList extends React.Component() {
  constructor() {
    super();
    this.state = {
      name: 'React',assetName:"asset name"
    };
  }
 
  render() {
     return (
    <div  >
       Task List
    </div>
  );
  }
}


export default TaskList;



  

Solution

change the code so that the syntax is proper for extends  . .

Code Changes 

add the following import in your component.ts file .

  
        
     class TaskList extends React.Component  {
         

OUTPUT
works 



Thanks for reading . Let me know your thoughts in the comments below    .

Saturday, April 4, 2020

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client



Error Blog 

This blog is about the error Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Problem Statement

unable to start node js express application

Error Details 

error Log

ERROR DETAILS 

\node_modules\mysql\lib\protocol\Parser.js:437
      throw err; // Rethrow non-MySQL errors
      ^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
    at ServerResponse.header (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\express\lib\response.js:771:10)
    at ServerResponse.send (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\express\lib\response.js:170:12)
    at ServerResponse.json (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\express\lib\response.js:267:15)
    at F:\ \study\gitRepo\new\learn\nodejs\expressjs\service\users.js:24:11
    at Query.<anonymous> (F:\ \study\gitRepo\new\learn\nodejs\expressjs\service\task.service.js:20:21)
    at Query.<anonymous> (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\mysql\lib\Connection.js:526:10)
    at Query._callback (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\mysql\lib\Connection.js:488:16)
    at Query.Sequence.end (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
    at Query._handleFinalResultPacket (F:\ \study\gitRepo\new\learn\nodejs\expressjs\node_modules\mysql\lib\protocol\sequences\Query.js:149:8)




Error Code 

You will face this error if you res.send twice in an express js application.




var express = require('express');
var router = express.Router();
var Task = require('./task.service.js');

router.get('/'function(reqres){
   Task.getAllTask(function(errtask) {

      console.log('controller')
      if (err)
        res.send(err);
        console.log('res'task);
      res.send(task);
    });
});
router.post('/create'function(reqres){
   console.log(req.body);
   var new_task = new Task(req.body);
   console.log(new_task);
   Task.createTask(new_taskfunction(errtask) {
    
      if (err)
        res.send(err);
      res.json(task);
    });
   res.send('success.');

});

//export this router to use in our index.js
module.exports = router;



  

Solution

change the code so that res.send is not called twice . .

Code Changes 

add the following import in your component.ts file .

  
        
      if (err)
        res.send(err);
      res.json(task);
    });
  // res.send('success.');

         

OUTPUT
works 



Thanks for reading . Let me know your thoughts in the comments below    .

ec2-user@ec2 Permission denied