Skip to content

Instantly share code, notes, and snippets.

View bbachi's full-sized avatar
💭
I may be slow to respond.

Bhargav Bachina bbachi

💭
I may be slow to respond.
View GitHub Profile
@bbachi
bbachi / Dockerfile
Created February 11, 2019 02:21
sample docker file
FROM node:8
RUN echo 'Building from base image Node:8'
ENV MONGO_URL=mongodb://mongo:27017/todos
ENV ROOT_URL=http://localhost
ENV PORT=3000
RUN apt-get install -y curl
RUN apt-get update
RUN apt-get install -y --no-install-recommends bsdtar
@bbachi
bbachi / app.module.ts
Last active February 11, 2019 16:03
Old way of doing Http
import { HttpModule } from '@angular/http';
@NgModule({
declarations: [
AppComponent
],
imports: [
HttpModule,
],
providers: [],
@bbachi
bbachi / app.module.ts
Created February 11, 2019 16:12
New way of using Http in Angular
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [
AppComponent
],
imports: [
HttpClientModule,
],
providers: [],
@bbachi
bbachi / package.json
Created February 11, 2019 18:18
new versions of rxjs
{
"rxjs": "^6.3.3",
"rxjs-compat": "^6.4.0"
}
@bbachi
bbachi / app.service.ts
Last active February 11, 2019 18:33
old way of doing rxjs
//import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
//import { Subject } from 'rxjs/Subject';
import { Subject } from 'rxjs';
//import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';
//import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@bbachi
bbachi / app.service.ts
Last active February 11, 2019 18:44
from chaining to piping
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/retry';
import 'rxjs/add/operator/map';
import { HttpClient } from '@angular/common/http';
@Injectable()
export class AppService implements OnInit {
@bbachi
bbachi / app.service.ts
Created February 11, 2019 18:44
new way pipe observale operators
import { HttpClient } from '@angular/common/http';
import { retry, map, catchError } from 'rxjs/operators';
@Injectable()
export class AppService implements OnInit {
constructor(private http: HttpClient) {}
ngOnInit(){
this.appConfig = this.http.get(this.configUrl);
@bbachi
bbachi / package.json
Created February 12, 2019 22:00
sample package.json
{
"name": "user_api",
"version": "1.0.0",
"description": "sample rest api",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Bhargav Bachina",
"license": "ISC"
@bbachi
bbachi / package.json
Created February 12, 2019 22:27
How to write production ready Node.js Rest API With javascript-package.json-v2
{
"name": "user_api",
"version": "1.0.0",
"description": "sample rest api",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Bhargav Bachina",
"license": "ISC",
@bbachi
bbachi / index.js
Last active February 13, 2019 03:41
How to write production ready Node.js Rest API With javascript
var express = require("express"),
bodyParser = require("body-parser"),
app = express(),
port = 3070;
// array to hold users
const users = [{firstName:"fnam1",lastName:"lnam1",userName:"username1"}];
app.use(bodyParser.json());