Skip to content

Instantly share code, notes, and snippets.

View bharat-tiwari's full-sized avatar

Bharat Tiwari bharat-tiwari

View GitHub Profile
@bharat-tiwari
bharat-tiwari / AppErrorHandler.ts
Last active February 13, 2018 21:36
App Level Error Handler in Angular
import { AppDataService, AppNotificationService } from '../services';
import { AppError } from '../entities';
import { Injectable, Injector, ErrorHandler } from '@angular/core';
@Injectable()
export class AppErrorHandler implements ErrorHandler {
constructor(private injector: Injector) { }
@bharat-tiwari
bharat-tiwari / order.html
Last active March 13, 2018 22:39
Parent component - Order
<div>
<h3>Order Processing System</h3>
<div>
<label>Order # {{order.id}}</label>
<label>Order Date {{order.date}}</label>
</div>
....
import {Component,Input,SimpleChanges} from '@angular/core';
@Component({
selector: 'item-details',
templateUrl: 'item-details.html',
})
export class ItemDetails {
private _item; // private property _item
@bharat-tiwari
bharat-tiwari / item-details.ts
Last active March 14, 2018 16:56
Item details component using ngOnChanges
import {Component,Input, OnChanges, SimpleChanges, SimpleChange} from '@angular/core';
@Component({
selector: 'item-details',
templateUrl: 'item-details.html',
})
export class ItemDetails implements OnChanges {
private _item;
get item(): any {
@bharat-tiwari
bharat-tiwari / item-details.ts
Last active March 14, 2018 17:05
Item Details Component
import {Component,Input} from '@angular/core';
@Component({
selector: 'item-details',
templateUrl: 'item-details.html',
})
export class ItemDetails {
@Input() item;
@Input() notifyItemProcessed: () => void;
@bharat-tiwari
bharat-tiwari / tsconfig.json
Last active April 15, 2018 14:44
tsconfig.json for react-native project build with CRNA (Create React Native App)
{
"compilerOptions": {
"module":"es2015",
"target": "es2015",
"jsx": "react",
"rootDir": "src",
"outDir": "build",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"sourceMap": true,
@bharat-tiwari
bharat-tiwari / getLoggedUserWords.json
Last active December 23, 2018 05:28
mock test json data to test getLoggedUserWord
{
"requestContext": {
"identity": {
"cognitoIdentityId": "TEST-LOCAL-USER-A"
}
}
}
@bharat-tiwari
bharat-tiwari / getById.ts
Created December 24, 2018 05:10
NoteWordy API : endpoint to get word by id
import { APP_CONSTANTS } from '../../config/app_constants';
import getResponse from '../../utils/responseUtils';
import * as AWS from "aws-sdk";
const dynamoDb = new AWS.DynamoDB.DocumentClient({
'region': 'us-east-1'
});
export async function main(event, context, callback) {
const params = {
@bharat-tiwari
bharat-tiwari / update.ts
Last active December 24, 2018 15:09
noteWordy API - Lambda function to update a word
import { APP_CONSTANTS } from '../../config/app_constants';
import getResponse from '../../utils/responseUtils';
import * as AWS from "aws-sdk";
const dynamoDb = new AWS.DynamoDB.DocumentClient({
'region': 'us-east-1'
});
export async function main(event , context, callback){
const requestData = JSON.parse(event.body);
@bharat-tiwari
bharat-tiwari / update.json
Created December 24, 2018 15:45
notewordy API - mock test data to test update endpoint
{
"body": "{ \"word\": \"stranger-1\", \"meaning\": \"someone whom you don't know or who doesn't belong in a specific place\", \"example\": \"Don't talk to strangers.-1\" }",
"requestContext": {
"identity": {
"cognitoIdentityId": "TEST-LOCAL-USER-A"
}
},
"pathParameters": {
"id": "replace-this-with-the-id-of-an-item-you-have-in-your-dynamoDb-table"
}