└── mongoDb ├── HumanResource ├── README.md ├── angular.json ├── browserslist ├── dist │ └── out-tsc │ │ ├── e2e │ │ └── src │ │ │ ├── app.e2e-spec.js │ │ │ ├── app.e2e-spec.js.map │ │ │ ├── app.po.js │ │ │ └── app.po.js.map │ │ └── src │ │ ├── Model │ │ ├── person.js │ │ └── person.js.map │ │ ├── Service │ │ ├── personService.js │ │ └── personService.js.map │ │ ├── app │ │ ├── app.component.js │ │ ├── app.component.js.map │ │ ├── app.component.spec.js │ │ ├── app.component.spec.js.map │ │ ├── app.module.js │ │ └── app.module.js.map │ │ ├── environments │ │ ├── environment.js │ │ ├── environment.js.map │ │ ├── environment.prod.js │ │ └── environment.prod.js.map │ │ ├── main.js │ │ ├── main.js.map │ │ ├── polyfills.js │ │ ├── polyfills.js.map │ │ ├── test.js │ │ └── test.js.map ├── dump.rdb ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src │ ├── Model │ │ └── person.ts │ ├── Service │ │ └── personService.ts │ ├── app │ │ ├── app-routing.module.ts │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── login.html │ │ ├── login.scss │ │ ├── login.ts │ │ ├── main.html │ │ └── main.ts │ ├── assets │ │ └── img │ │ │ └── logo.png │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.scss │ └── test.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json ├── Socket └── app.js ├── config.js ├── service.js ├── swagger.json ├── token.js └── users.js /mongoDb/HumanResource/README.md: -------------------------------------------------------------------------------- 1 | # HumanResource 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.1.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "HumanResource": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/HumanResource", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "aot": false, 26 | "assets": [ 27 | "src/favicon.ico", 28 | "src/assets" 29 | ], 30 | "styles": [ 31 | "src/styles.scss" 32 | ], 33 | "scripts": [] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "fileReplacements": [ 38 | { 39 | "replace": "src/environments/environment.ts", 40 | "with": "src/environments/environment.prod.ts" 41 | } 42 | ], 43 | "optimization": true, 44 | "outputHashing": "all", 45 | "sourceMap": false, 46 | "extractCss": true, 47 | "namedChunks": false, 48 | "aot": true, 49 | "extractLicenses": true, 50 | "vendorChunk": false, 51 | "buildOptimizer": true, 52 | "budgets": [ 53 | { 54 | "type": "initial", 55 | "maximumWarning": "2mb", 56 | "maximumError": "5mb" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | "serve": { 63 | "builder": "@angular-devkit/build-angular:dev-server", 64 | "options": { 65 | "browserTarget": "HumanResource:build" 66 | }, 67 | "configurations": { 68 | "production": { 69 | "browserTarget": "HumanResource:build:production" 70 | } 71 | } 72 | }, 73 | "extract-i18n": { 74 | "builder": "@angular-devkit/build-angular:extract-i18n", 75 | "options": { 76 | "browserTarget": "HumanResource:build" 77 | } 78 | }, 79 | "test": { 80 | "builder": "@angular-devkit/build-angular:karma", 81 | "options": { 82 | "main": "src/test.ts", 83 | "polyfills": "src/polyfills.ts", 84 | "tsConfig": "tsconfig.spec.json", 85 | "karmaConfig": "karma.conf.js", 86 | "assets": [ 87 | "src/favicon.ico", 88 | "src/assets" 89 | ], 90 | "styles": [ 91 | "src/styles.scss" 92 | ], 93 | "scripts": [] 94 | } 95 | }, 96 | "lint": { 97 | "builder": "@angular-devkit/build-angular:tslint", 98 | "options": { 99 | "tsConfig": [ 100 | "tsconfig.app.json", 101 | "tsconfig.spec.json", 102 | "e2e/tsconfig.json" 103 | ], 104 | "exclude": [ 105 | "**/node_modules/**" 106 | ] 107 | } 108 | }, 109 | "e2e": { 110 | "builder": "@angular-devkit/build-angular:protractor", 111 | "options": { 112 | "protractorConfig": "e2e/protractor.conf.js", 113 | "devServerTarget": "HumanResource:serve" 114 | }, 115 | "configurations": { 116 | "production": { 117 | "devServerTarget": "HumanResource:serve:production" 118 | } 119 | } 120 | } 121 | } 122 | }}, 123 | "defaultProject": "HumanResource" 124 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/e2e/src/app.e2e-spec.js: -------------------------------------------------------------------------------- 1 | import * as tslib_1 from "tslib"; 2 | import { AppPage } from './app.po'; 3 | import { browser, logging } from 'protractor'; 4 | describe('workspace-project App', () => { 5 | let page; 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | it('should display welcome message', () => { 10 | page.navigateTo(); 11 | expect(page.getTitleText()).toEqual('Welcome to HumanResource!'); 12 | }); 13 | afterEach(() => tslib_1.__awaiter(this, void 0, void 0, function* () { 14 | // Assert that there are no errors emitted from the browser 15 | const logs = yield browser.manage().logs().get(logging.Type.BROWSER); 16 | expect(logs).not.toContain(jasmine.objectContaining({ 17 | level: logging.Level.SEVERE, 18 | })); 19 | })); 20 | }); 21 | //# sourceMappingURL=app.e2e-spec.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/e2e/src/app.e2e-spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.e2e-spec.js","sourceRoot":"","sources":["../../../../e2e/src/app.e2e-spec.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,IAAa,CAAC;IAElB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAS,EAAE;QACnB,2DAA2D;QAC3D,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC;YAClD,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;SACX,CAAC,CAAC,CAAC;IACvB,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/e2e/src/app.po.js: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | export class AppPage { 3 | navigateTo() { 4 | return browser.get(browser.baseUrl); 5 | } 6 | getTitleText() { 7 | return element(by.css('app-root h1')).getText(); 8 | } 9 | } 10 | //# sourceMappingURL=app.po.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/e2e/src/app.po.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.po.js","sourceRoot":"","sources":["../../../../e2e/src/app.po.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,OAAO,OAAO;IAClB,UAAU;QACR,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAiB,CAAC;IACtD,CAAC;IAED,YAAY;QACV,OAAO,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,EAAqB,CAAC;IACrE,CAAC;CACF"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/Model/person.js: -------------------------------------------------------------------------------- 1 | export class Name { 2 | constructor() { } 3 | } 4 | export class Person { 5 | constructor() { 6 | this.gender = "male"; 7 | } 8 | } 9 | //# sourceMappingURL=person.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/Model/person.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"person.js","sourceRoot":"","sources":["../../../../src/Model/person.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,IAAI;IAKb,gBAAgB,CAAC;CACpB;AAED,MAAM,OAAO,MAAM;IAWf;QACI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/Service/personService.js: -------------------------------------------------------------------------------- 1 | import * as tslib_1 from "tslib"; 2 | import { Injectable } from '@angular/core'; 3 | import { HttpHeaders } from '@angular/common/http'; 4 | import { throwError } from 'rxjs'; 5 | import { retry, catchError } from 'rxjs/operators'; 6 | let PersonService = class PersonService { 7 | constructor(httpClient) { 8 | this.httpClient = httpClient; 9 | this.baseUrl = "http://localhost:9480/people"; 10 | this.baseUrlDesc = "http://localhost:9480/peopleDesc"; 11 | this.pagingUrl = "http://localhost:9480/getpeoplebyPaging"; 12 | this.updateUrl = "http://localhost:9480/updatePeople"; 13 | this.inserteUrl = "http://localhost:9480/insertPeople"; 14 | this.searchUrl = "http://localhost:9480/getpeopleStartsWith"; 15 | this.deleteUrl = "http://localhost:9480/deletePeople"; 16 | this.page = 1; 17 | this.httpOptions = { 18 | headers: new HttpHeaders({ 19 | 'Content-Type': 'application/json' 20 | }) 21 | }; 22 | } 23 | getPeopleList(desc = false) { 24 | let url = desc ? this.baseUrlDesc : this.baseUrl; 25 | return this.httpClient.get(url) 26 | .pipe(retry(1), catchError(this.errorHandel)); 27 | } 28 | getPeopleListByPaging(pageNo) { 29 | return this.httpClient.get(this.pagingUrl + "/" + pageNo + "/5") 30 | .pipe(retry(1), catchError(this.errorHandel)); 31 | } 32 | updatePerson(data) { 33 | return this.httpClient.post(this.updateUrl, JSON.stringify(data), this.httpOptions) 34 | .pipe(retry(1), catchError(this.errorHandel)); 35 | } 36 | insertPeople(data) { 37 | return this.httpClient.post(this.inserteUrl, JSON.stringify(data), this.httpOptions) 38 | .pipe(retry(1), catchError(this.errorHandel)); 39 | } 40 | searchPeopleByName(name) { 41 | return this.httpClient.get(this.searchUrl + "/" + name) 42 | .pipe(retry(1), catchError(this.errorHandel)); 43 | } 44 | deletePeople(data) { 45 | return this.httpClient.post(this.deleteUrl, JSON.stringify(data), this.httpOptions) 46 | .pipe(retry(1), catchError(this.errorHandel)); 47 | } 48 | errorHandel(error) { 49 | let errorMessage = ''; 50 | if (error.error instanceof ErrorEvent) { 51 | // Get client-side error 52 | errorMessage = error.error.message; 53 | } 54 | else { 55 | // Get server-side error 56 | errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`; 57 | } 58 | console.log(errorMessage); 59 | return throwError(errorMessage); 60 | } 61 | }; 62 | PersonService = tslib_1.__decorate([ 63 | Injectable({ providedIn: 'root' }) 64 | ], PersonService); 65 | export { PersonService }; 66 | //# sourceMappingURL=personService.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/Service/personService.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"personService.js","sourceRoot":"","sources":["../../../../src/Service/personService.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.component.js: -------------------------------------------------------------------------------- 1 | import * as tslib_1 from "tslib"; 2 | import { Component, ViewChild } from '@angular/core'; 3 | import { fromEvent } from 'rxjs'; 4 | import { Person, Name } from 'src/Model/person'; 5 | import { map, filter, debounceTime } from 'rxjs/operators'; 6 | let AppComponent = class AppComponent { 7 | constructor(service) { 8 | this.service = service; 9 | this.isGetPeople = false; 10 | this.isInsert = false; 11 | this.optionSelect = ['male', 'female']; 12 | this.isEdit = false; 13 | this.title = 'HumanResource'; 14 | this.peopleList = []; 15 | this.currentPagecount = 1; 16 | this.isNextActive = true; 17 | this.isPreviewActive = false; 18 | } 19 | ngAfterViewInit() { 20 | this.getPeople(); 21 | fromEvent(this.userSearchInput.nativeElement, 'keyup').pipe( 22 | // get value 23 | map((event) => { 24 | event.target.value.length < 3 && !this.isGetPeople ? this.getPeople() : null; 25 | return event.target.value; 26 | }) 27 | // if character length greater then 2 28 | , filter(res => res.length > 2) 29 | // Time in milliseconds between key events 30 | , debounceTime(250) 31 | // If previous query is diffent from current 32 | // , distinctUntilChanged() 33 | // subscription for response 34 | ).subscribe((text) => { 35 | this.service.searchPeopleByName(text).subscribe((res) => { 36 | this.isGetPeople = false; 37 | console.log('res', res); 38 | this.peopleList = res; 39 | }, (err) => { 40 | console.log('error', err); 41 | }); 42 | }); 43 | } 44 | getPeople(desc = false) { 45 | return this.service.getPeopleList(desc).subscribe((data = []) => { 46 | this.isGetPeople = true; 47 | this.peopleList = data.slice(0, 5); 48 | console.log(this.peopleList); 49 | }); 50 | } 51 | clickInsert() { 52 | this.personModel = new Person(); 53 | this.name = new Name(); 54 | this.personModel.name = this.name; 55 | this.isInsert = !this.isInsert; 56 | this.isEdit = false; 57 | } 58 | ; 59 | Edit(data) { 60 | this.isEdit = (this.personModel == data || this.isInsert == true) ? !this.isEdit : this.isEdit; 61 | this.personModel = data; 62 | this.isInsert = false; 63 | } 64 | Delete(data) { 65 | this.service.deletePeople(data).subscribe((data) => { 66 | console.log("Sil:" + data.username); 67 | }, () => { }, () => this.getPeople()); 68 | } 69 | Save() { 70 | if (this.isEdit) { 71 | this.service.updatePerson(this.personModel).subscribe((data) => { }); 72 | this.personModel = null; 73 | this.isEdit = false; 74 | } 75 | else if (this.isInsert) { 76 | this.service.insertPeople(this.personModel).subscribe((data) => { 77 | this.getPeople(true); 78 | }); 79 | this.personModel = null; 80 | this.isInsert = false; 81 | } 82 | } 83 | Next() { 84 | this.currentPagecount = this.currentPagecount + 1 >= 0 ? this.currentPagecount + 1 : this.currentPagecount; 85 | return this.service.getPeopleListByPaging(this.currentPagecount).subscribe((data = []) => { 86 | if (data.length == 0) { 87 | this.currentPagecount = this.currentPagecount - 1; 88 | this.isNextActive = false; 89 | } 90 | else { 91 | this.isNextActive = true; 92 | this.peopleList = data; 93 | this.isPreviewActive = true; 94 | } 95 | console.log(this.peopleList); 96 | }); 97 | } 98 | Preview() { 99 | this.currentPagecount = this.currentPagecount - 1 > 0 ? this.currentPagecount - 1 : this.currentPagecount; 100 | return this.service.getPeopleListByPaging(this.currentPagecount).subscribe((data = []) => { 101 | if (data.length > 0) { 102 | this.isNextActive = true; 103 | this.isPreviewActive = true; 104 | this.peopleList = data; 105 | } 106 | this.isPreviewActive = this.currentPagecount == 1 ? false : true; 107 | console.log(this.peopleList); 108 | }); 109 | } 110 | }; 111 | tslib_1.__decorate([ 112 | ViewChild('userSearchInput', { static: false }) 113 | ], AppComponent.prototype, "userSearchInput", void 0); 114 | AppComponent = tslib_1.__decorate([ 115 | Component({ 116 | selector: 'app-root', 117 | templateUrl: './app.component.html', 118 | styleUrls: ['./app.component.scss'] 119 | }) 120 | ], AppComponent); 121 | export { AppComponent }; 122 | //# sourceMappingURL=app.component.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.component.js","sourceRoot":"","sources":["../../../../src/app/app.component.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.component.spec.js: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', () => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | }); 16 | it(`should have as title 'HumanResource'`, () => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('HumanResource'); 20 | }); 21 | it('should render title in a h1 tag', () => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to HumanResource!'); 26 | }); 27 | }); 28 | //# sourceMappingURL=app.component.spec.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.component.spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.component.spec.js","sourceRoot":"","sources":["../../../../src/app/app.component.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;QACpB,OAAO,CAAC,sBAAsB,CAAC;YAC7B,YAAY,EAAE;gBACZ,YAAY;aACb;SACF,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC,CAAC;IAEJ,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,CAAC,aAAa,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.module.js: -------------------------------------------------------------------------------- 1 | import * as tslib_1 from "tslib"; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { NgModule } from '@angular/core'; 4 | import { AppComponent } from './app.component'; 5 | import { PersonService } from 'src/Service/personService'; 6 | import { HttpClientModule } from '@angular/common/http'; 7 | import { FormsModule } from '@angular/forms'; 8 | let AppModule = class AppModule { 9 | }; 10 | AppModule = tslib_1.__decorate([ 11 | NgModule({ 12 | declarations: [ 13 | AppComponent, 14 | ], 15 | imports: [ 16 | BrowserModule, 17 | FormsModule, 18 | HttpClientModule 19 | ], 20 | providers: [PersonService], 21 | bootstrap: [AppComponent] 22 | }) 23 | ], AppModule); 24 | export { AppModule }; 25 | //# sourceMappingURL=app.module.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/app/app.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../../src/app/app.module.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAa7C,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAI,CAAA;AAAb,SAAS;IAZrB,QAAQ,CAAC;QACR,YAAY,EAAE;YACZ,YAAY;SACb;QACD,OAAO,EAAE;YACP,aAAa;YACb,WAAW;YACX,gBAAgB;SACjB;QACD,SAAS,EAAE,CAAC,aAAa,CAAC;QAC1B,SAAS,EAAE,CAAC,YAAY,CAAC;KAC1B,CAAC;GACW,SAAS,CAAI;SAAb,SAAS"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/environments/environment.js: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | export const environment = { 5 | production: false 6 | }; 7 | /* 8 | * For easier debugging in development mode, you can import the following file 9 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 10 | * 11 | * This import should be commented out in production mode because it will have a negative impact 12 | * on performance if an error is thrown. 13 | */ 14 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 15 | //# sourceMappingURL=environment.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/environments/environment.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../../src/environments/environment.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,gEAAgE;AAEhE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,mEAAmE"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/environments/environment.prod.js: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | //# sourceMappingURL=environment.prod.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/environments/environment.prod.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"environment.prod.js","sourceRoot":"","sources":["../../../../src/environments/environment.prod.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,IAAI;CACjB,CAAC"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/main.js: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | import { AppModule } from './app/app.module'; 4 | import { environment } from './environments/environment'; 5 | if (environment.production) { 6 | enableProdMode(); 7 | } 8 | platformBrowserDynamic().bootstrapModule(AppModule) 9 | .catch(err => console.error(err)); 10 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,IAAI,WAAW,CAAC,UAAU,EAAE;IAC1B,cAAc,EAAE,CAAC;CAClB;AAED,sBAAsB,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC;KAChD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/polyfills.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | /*************************************************************************************************** 17 | * BROWSER POLYFILLS 18 | */ 19 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 20 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 21 | /** 22 | * Web Animations `@angular/platform-browser/animations` 23 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 24 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 25 | */ 26 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 27 | /** 28 | * By default, zone.js will patch all possible macroTask and DomEvents 29 | * user can disable parts of macroTask/DomEvents patch by setting following flags 30 | * because those flags need to be set before `zone.js` being loaded, and webpack 31 | * will put import in the top of bundle, so user need to create a separate file 32 | * in this directory (for example: zone-flags.ts), and put the following flags 33 | * into that file, and then add the following code before importing zone.js. 34 | * import './zone-flags.ts'; 35 | * 36 | * The flags allowed in zone-flags.ts are listed here. 37 | * 38 | * The following flags will work for all browsers. 39 | * 40 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 41 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 42 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 43 | * 44 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 45 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 46 | * 47 | * (window as any).__Zone_enable_cross_context_check = true; 48 | * 49 | */ 50 | /*************************************************************************************************** 51 | * Zone JS is required by default for Angular itself. 52 | */ 53 | import 'zone.js/dist/zone'; // Included with Angular CLI. 54 | /*************************************************************************************************** 55 | * APPLICATION IMPORTS 56 | */ 57 | //# sourceMappingURL=polyfills.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/polyfills.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../../../src/polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AAEH,+EAA+E;AAC/E,oEAAoE;AAEpE;;;;GAIG;AACH,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AACH,OAAO,mBAAmB,CAAC,CAAE,6BAA6B;AAG1D;;GAEG"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/test.js: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | import 'zone.js/dist/zone-testing'; 3 | import { getTestBed } from '@angular/core/testing'; 4 | import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; 5 | // First, initialize the Angular testing environment. 6 | getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); 7 | // Then we find all the tests. 8 | const context = require.context('./', true, /\.spec\.ts$/); 9 | // And load the modules. 10 | context.keys().map(context); 11 | //# sourceMappingURL=test.js.map -------------------------------------------------------------------------------- /mongoDb/HumanResource/dist/out-tsc/src/test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/test.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,2CAA2C,CAAC;AAInD,qDAAqD;AACrD,UAAU,EAAE,CAAC,mBAAmB,CAC9B,2BAA2B,EAC3B,6BAA6B,EAAE,CAChC,CAAC;AACF,8BAA8B;AAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAC3D,wBAAwB;AACxB,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC"} -------------------------------------------------------------------------------- /mongoDb/HumanResource/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borakasmer/SocketIO-Angular8-Redis-NodeJS/9b0bfbd2d40fc6d465141289ffc03b612144c61b/mongoDb/HumanResource/dump.rdb -------------------------------------------------------------------------------- /mongoDb/HumanResource/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | 'browserName': 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 31 | } 32 | }; -------------------------------------------------------------------------------- /mongoDb/HumanResource/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to HumanResource!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/HumanResource'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "human-resource", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~8.1.0", 15 | "@angular/common": "~8.1.0", 16 | "@angular/compiler": "~8.1.0", 17 | "@angular/core": "~8.1.0", 18 | "@angular/forms": "~8.1.0", 19 | "@angular/platform-browser": "~8.1.0", 20 | "@angular/platform-browser-dynamic": "~8.1.0", 21 | "@angular/router": "~8.1.0", 22 | "ngx-socket-io": "^3.0.1", 23 | "rxjs": "~6.4.0", 24 | "tslib": "^1.9.0", 25 | "zone.js": "~0.9.1" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~0.801.0", 29 | "@angular/cli": "~8.1.0", 30 | "@angular/compiler-cli": "~8.1.0", 31 | "@angular/language-service": "~8.1.0", 32 | "@types/node": "~8.9.4", 33 | "@types/jasmine": "~3.3.8", 34 | "@types/jasminewd2": "~2.0.3", 35 | "codelyzer": "^5.0.0", 36 | "jasmine-core": "~3.4.0", 37 | "jasmine-spec-reporter": "~4.2.1", 38 | "karma": "~4.1.0", 39 | "karma-chrome-launcher": "~2.2.0", 40 | "karma-coverage-istanbul-reporter": "~2.0.1", 41 | "karma-jasmine": "~2.0.1", 42 | "karma-jasmine-html-reporter": "^1.4.0", 43 | "protractor": "~5.4.0", 44 | "ts-node": "~7.0.0", 45 | "tslint": "~5.15.0", 46 | "typescript": "~3.4.3" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/Model/person.ts: -------------------------------------------------------------------------------- 1 | export class Name { 2 | title: String; 3 | first: String; 4 | last: String; 5 | 6 | constructor() { } 7 | } 8 | 9 | export class Person { 10 | gender: String; 11 | email: String; 12 | username: String; 13 | name: { 14 | title: String, 15 | first: String, 16 | last: String 17 | }; 18 | fullName: String; 19 | 20 | constructor() { 21 | this.gender = "male"; 22 | } 23 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/Service/personService.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; 3 | import { Person } from 'src/Model/person'; 4 | import { Observable, throwError } from 'rxjs'; 5 | import { retry, catchError, map } from 'rxjs/operators'; 6 | 7 | import { Socket } from 'ngx-socket-io'; 8 | @Injectable({ providedIn: 'root' }) 9 | export class PersonService { 10 | baseUrl: string = "http://localhost:9480/people"; 11 | baseUrlDesc: string = "http://localhost:9480/peopleDesc"; 12 | pagingUrl: string = "http://localhost:9480/getpeoplebyPaging"; 13 | updateUrl: string = "http://localhost:9480/updatePeople"; 14 | inserteUrl: string = "http://localhost:9480/insertPeople"; 15 | searchUrl: string = "http://localhost:9480/getpeopleStartsWith"; 16 | deleteUrl: string = "http://localhost:9480/deletePeople"; 17 | 18 | loginUrl: string = "http://localhost:9480/login"; 19 | checkTokenUrl: string = "http://localhost:9480/checkToken"; 20 | page: number = 1; 21 | 22 | 23 | 24 | constructor(private httpClient: HttpClient, private socket: Socket) { } 25 | 26 | sendUpdatePerson(person: Person) { 27 | this.socket.emit('sendUpdatePerson', person); 28 | } 29 | sendSavePerson(person: Person) { 30 | this.socket.emit('sendSavePerson', person); 31 | } 32 | sendDeletePerson(person: Person) { 33 | debugger; 34 | this.socket.emit('sendDeletePerson', person); 35 | } 36 | 37 | updatedPerson = this.socket.fromEvent('Updatedperson'); 38 | savedPerson = this.socket.fromEvent('Savedperson'); 39 | deletedPerson = this.socket.fromEvent('Deletedperson'); 40 | 41 | GetToken(): string { 42 | if (window.localStorage.getItem("token") != null) { 43 | return window.localStorage.getItem("token"); 44 | } 45 | } 46 | 47 | public checkTokenTime() { 48 | debugger; 49 | if (window.localStorage.getItem("createdDate") != null) { 50 | var createdDate = new Date(window.localStorage.getItem("createdDate")); 51 | var now = new Date(); 52 | var difference = now.getTime() - createdDate.getTime(); 53 | var resultInMinutes = Math.round(difference / 60000); 54 | return resultInMinutes > 1; //45 olacak 55 | } 56 | else { 57 | return true; 58 | } 59 | } 60 | public getPeopleList(desc: boolean = false): Observable { 61 | let url: string = desc ? this.baseUrlDesc : this.baseUrl; 62 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 63 | let httpOptions = { 64 | headers: new HttpHeaders({ 65 | 'Content-Type': 'application/json', 66 | 'Authorization': 'Bearer ' + this.GetToken(), 67 | 'RefreshToken': refreshToken, 68 | }), 69 | observe: 'response' as 'body', 70 | } 71 | debugger; 72 | return this.httpClient.get(url, httpOptions) 73 | .pipe( 74 | map(response => { 75 | var token = response.headers.get('token'); 76 | var refreshToken = response.headers.get('refreshToken'); 77 | debugger; 78 | if (token && refreshToken) { 79 | console.log("Token :" + token); 80 | console.log("RefreshToken :" + refreshToken); 81 | window.localStorage.setItem("token", token); 82 | window.localStorage.setItem("refreshToken", refreshToken); 83 | window.localStorage.setItem("createdDate", new Date().toString()); 84 | } 85 | return response.body; 86 | }), 87 | retry(1), 88 | catchError(this.errorHandel), 89 | ) 90 | } 91 | /* public getPeopleListByPaging(pageNo: number): Observable { 92 | let httpOptions = { 93 | headers: new HttpHeaders({ 94 | 'Content-Type': 'application/json', 95 | 'Authorization': 'Bearer ' + this.GetToken(), 96 | }) 97 | } 98 | return this.httpClient.get(this.pagingUrl + "/" + pageNo + "/5", httpOptions) 99 | .pipe( 100 | retry(1), 101 | catchError(this.errorHandel) 102 | ) 103 | } */ 104 | public getPeopleListByPaging(pageNo: number): Observable { 105 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 106 | let httpOptions = { 107 | headers: new HttpHeaders({ 108 | 'Content-Type': 'application/json', 109 | 'Authorization': 'Bearer ' + this.GetToken(), 110 | 'RefreshToken': refreshToken, 111 | }), 112 | observe: 'response' as 'body', 113 | } 114 | return this.httpClient.get(this.pagingUrl + "/" + pageNo + "/5", httpOptions) 115 | .pipe( 116 | map(response => { 117 | var token = response.headers.get('token'); 118 | var refreshToken = response.headers.get('refreshToken'); 119 | debugger; 120 | if (token && refreshToken) { 121 | console.log("Token :" + token); 122 | console.log("RefreshToken :" + refreshToken); 123 | window.localStorage.setItem("token", token); 124 | window.localStorage.setItem("refreshToken", refreshToken); 125 | window.localStorage.setItem("createdDate", new Date().toString()); 126 | } 127 | return response.body; 128 | }), 129 | retry(1), 130 | catchError(this.errorHandel) 131 | ) 132 | } 133 | 134 | 135 | public updatePerson(data: Person): Observable { 136 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 137 | let httpOptions = { 138 | headers: new HttpHeaders({ 139 | 'Content-Type': 'application/json', 140 | 'Authorization': 'Bearer ' + this.GetToken(), 141 | 'RefreshToken': refreshToken, 142 | }), 143 | observe: 'response' as 'body', 144 | } 145 | return this.httpClient.post(this.updateUrl, JSON.stringify(data), httpOptions) 146 | .pipe( 147 | map(response => { 148 | var token = response.headers.get('token'); 149 | var refreshToken = response.headers.get('refreshToken'); 150 | debugger; 151 | if (token && refreshToken) { 152 | console.log("Token :" + token); 153 | console.log("RefreshToken :" + refreshToken); 154 | window.localStorage.setItem("token", token); 155 | window.localStorage.setItem("refreshToken", refreshToken); 156 | window.localStorage.setItem("createdDate", new Date().toString()); 157 | } 158 | this.sendUpdatePerson(data); // Send SocketIO 159 | return response.body; 160 | }), 161 | retry(1), 162 | catchError(this.errorHandel) 163 | ) 164 | } 165 | 166 | public insertPeople(data: Person): Observable { 167 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 168 | let httpOptions = { 169 | headers: new HttpHeaders({ 170 | 'Content-Type': 'application/json', 171 | 'Authorization': 'Bearer ' + this.GetToken(), 172 | 'RefreshToken': refreshToken, 173 | }), 174 | observe: 'response' as 'body', 175 | } 176 | return this.httpClient.post(this.inserteUrl, JSON.stringify(data), httpOptions) 177 | .pipe( 178 | map(response => { 179 | var token = response.headers.get('token'); 180 | var refreshToken = response.headers.get('refreshToken'); 181 | debugger; 182 | if (token && refreshToken) { 183 | console.log("Token :" + token); 184 | console.log("RefreshToken :" + refreshToken); 185 | window.localStorage.setItem("token", token); 186 | window.localStorage.setItem("refreshToken", refreshToken); 187 | window.localStorage.setItem("createdDate", new Date().toString()); 188 | } 189 | //YENİ EKLENEN SATIR 190 | //this.sendSavePerson(data); //Send SocketIO 191 | this.sendSavePerson(response.body); //Send SocketIO 192 | //------------------- 193 | return response.body; 194 | }), 195 | retry(1), 196 | catchError(this.errorHandel) 197 | ) 198 | } 199 | 200 | public searchPeopleByName(name: string): Observable { 201 | debugger; 202 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 203 | let httpOptions = { 204 | headers: new HttpHeaders({ 205 | 'Content-Type': 'application/json', 206 | 'Authorization': 'Bearer ' + this.GetToken(), 207 | 'RefreshToken': refreshToken, 208 | }), 209 | observe: 'response' as 'body', 210 | } 211 | return this.httpClient.get(this.searchUrl + "/" + name, httpOptions) 212 | .pipe( 213 | map(response => { 214 | var token = response.headers.get('token'); 215 | var refreshToken = response.headers.get('refreshToken'); 216 | debugger; 217 | if (token && refreshToken) { 218 | console.log("Token :" + token); 219 | console.log("RefreshToken :" + refreshToken); 220 | window.localStorage.setItem("token", token); 221 | window.localStorage.setItem("refreshToken", refreshToken); 222 | window.localStorage.setItem("createdDate", new Date().toString()); 223 | } 224 | return response.body; 225 | }), 226 | retry(1), 227 | catchError(this.errorHandel) 228 | ) 229 | } 230 | 231 | public deletePeople(data: Person): Observable { 232 | var refreshToken = (window.localStorage.getItem("refreshToken") != null && this.checkTokenTime()) ? window.localStorage.getItem("refreshToken") : ""; 233 | let httpOptions = { 234 | headers: new HttpHeaders({ 235 | 'Content-Type': 'application/json', 236 | 'Authorization': 'Bearer ' + this.GetToken(), 237 | 'RefreshToken': refreshToken, 238 | }), 239 | observe: 'response' as 'body', 240 | } 241 | return this.httpClient.post(this.deleteUrl, JSON.stringify(data), httpOptions) 242 | .pipe( 243 | map(response => { 244 | var token = response.headers.get('token'); 245 | var refreshToken = response.headers.get('refreshToken'); 246 | debugger; 247 | if (token && refreshToken) { 248 | console.log("Token :" + token); 249 | console.log("RefreshToken :" + refreshToken); 250 | window.localStorage.setItem("token", token); 251 | window.localStorage.setItem("refreshToken", refreshToken); 252 | window.localStorage.setItem("createdDate", new Date().toString()); 253 | } 254 | //YENİ EKLENEN SATIR 255 | this.sendDeletePerson(data); // Send SocketIO 256 | //------------------- 257 | return response.body; 258 | }), 259 | retry(1), 260 | catchError(this.errorHandel) 261 | ) 262 | } 263 | 264 | public login(userName: string, password: string): Observable { 265 | let httpOptions = { 266 | headers: new HttpHeaders({ 267 | 'Content-Type': 'application/json' 268 | }) 269 | } 270 | //return this.httpClient.post(this.loginUrl + "/" + userName + "/" + this.Encrypt(password), httpOptions) 271 | return this.httpClient.post(this.loginUrl, { username: userName, password: this.Encrypt(password) }, httpOptions) 272 | .pipe( 273 | retry(1), 274 | catchError(this.errorHandel) 275 | ) 276 | } 277 | 278 | public checkToken(): Observable { 279 | 280 | let httpOptions = { 281 | headers: new HttpHeaders({ 282 | 'Content-Type': 'application/json', 283 | 'Authorization': 'Bearer ' + this.GetToken(), 284 | }) 285 | } 286 | return this.httpClient.get(this.checkTokenUrl, httpOptions) 287 | .pipe( 288 | retry(1), 289 | catchError(this.errorHandel) 290 | ) 291 | } 292 | 293 | errorHandel(error) { 294 | let errorMessage = ''; 295 | if (error.error instanceof ErrorEvent) { 296 | // Get client-side error 297 | errorMessage = error.error.message; 298 | } else { 299 | // Get server-side error 300 | errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`; 301 | } 302 | console.log(errorMessage); 303 | return throwError(errorMessage); 304 | } 305 | 306 | public Encrypt(password: string) { 307 | 308 | let keyStr: string = "ABCDEFGHIJKLMNOP" + 309 | "QRSTUVWXYZabcdef" + 310 | "ghijklmnopqrstuv" + 311 | "wxyz0123456789+/" + 312 | "="; 313 | 314 | password = password.split('+').join('|'); 315 | //let input = escape(password); 316 | /* let input = password; */ 317 | let input = encodeURI(password); 318 | let output = ""; 319 | let chr1, chr2, chr3; 320 | let enc1, enc2, enc3, enc4; 321 | let i = 0; 322 | 323 | do { 324 | chr1 = input.charCodeAt(i++); 325 | chr2 = input.charCodeAt(i++); 326 | chr3 = input.charCodeAt(i++); 327 | 328 | enc1 = chr1 >> 2; 329 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 330 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 331 | enc4 = chr3 & 63; 332 | 333 | if (isNaN(chr2)) { 334 | enc3 = enc4 = 64; 335 | } else if (isNaN(chr3)) { 336 | enc4 = 64; 337 | 338 | } 339 | output = output + 340 | keyStr.charAt(enc1) + 341 | keyStr.charAt(enc2) + 342 | keyStr.charAt(enc3) + 343 | keyStr.charAt(enc4); 344 | chr1 = chr2 = chr3 = ""; 345 | enc1 = enc2 = enc3 = enc4 = ""; 346 | } while (i < input.length); 347 | //console.log("Password :" + output); 348 | return output; 349 | } 350 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { LoginComponent } from './login'; 4 | import { AppComponent } from './app.component'; 5 | 6 | const routes: Routes = [ 7 | { path: '', component: LoginComponent, pathMatch: 'full' }, 8 | { path: 'person', component: AppComponent, pathMatch: 'full' } 9 | ]; 10 | @NgModule({ 11 | imports: [RouterModule.forRoot(routes)], 12 | exports: [RouterModule] 13 | }) 14 | export class AppRoutingModule { 15 | 16 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

5 | Welcome to {{ title }}! 6 |

7 | 8 |
9 | 10 | 11 | 14 | 15 | 16 | 19 | 22 | 25 | 28 | 29 | 32 | 35 | 38 | 41 | 42 | 43 | 46 | 49 | 52 | 57 | 58 |
12 | 13 |
17 | Title : 18 | 20 | 21 | 23 | Name : 24 | 26 | 27 |
30 | Surname : 31 | 33 | 34 | 36 | Email : 37 | 39 | 40 |
44 |
UserName :
45 |
47 | 48 | 50 |
Gender :
51 |
53 | 56 |
59 |
60 |
61 | 62 | 63 | 64 | 67 | 70 | 71 | 72 | 74 | 75 | 76 | 78 | 79 | 80 | 81 | 82 | 86 | 87 | 88 | 89 | 90 | 91 |
65 | Name: 66 | 68 | 69 |
73 | #NameEmailGender
83 | 84 | 85 | {{people.name.first}}{{people.email}}{{people.gender}}
92 |
-------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'HumanResource'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('HumanResource'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to HumanResource!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core'; 2 | import { PersonService } from 'src/Service/personService'; 3 | import { Observable, fromEvent } from 'rxjs'; 4 | import { Person, Name } from 'src/Model/person'; 5 | import { map, filter, debounceTime, distinctUntilChanged } from 'rxjs/operators'; 6 | import { Router } from '@angular/router'; 7 | 8 | @Component({ 9 | templateUrl: './app.component.html', 10 | styleUrls: ['./app.component.scss'] 11 | }) 12 | export class AppComponent implements AfterViewInit { 13 | @ViewChild('userSearchInput', { static: false }) userSearchInput: ElementRef; 14 | isGetPeople: boolean = false; 15 | 16 | isInsert: boolean = false; 17 | 18 | optionSelect = ['male', 'female'] 19 | personModel: Person; 20 | name: Name; 21 | isEdit: boolean = false; 22 | title = 'HumanResource'; 23 | peopleList: any = []; 24 | currentPagecount: number = 1; 25 | isNextActive: boolean = true; 26 | isPreviewActive: boolean = false; 27 | constructor(public service: PersonService, private router: Router) { } 28 | 29 | ngAfterViewInit() { 30 | 31 | this.service.updatedPerson.subscribe((person: Person) => { 32 | debugger; 33 | let updateIndex = this.peopleList.findIndex(per => per.username === person.username) 34 | this.peopleList[updateIndex] = person; 35 | //alert(person.name.first + " " + person.name.last); 36 | }); 37 | 38 | this.service.savedPerson.subscribe((person: Person) => { 39 | debugger; 40 | this.peopleList.unshift(person); 41 | }); 42 | 43 | this.service.deletedPerson.subscribe((person: Person) => { 44 | debugger; 45 | let deleteIndex = this.peopleList.findIndex(per => per.username === person.username) 46 | this.peopleList.splice(deleteIndex, 1); 47 | }); 48 | 49 | 50 | this.getPeople(); 51 | fromEvent(this.userSearchInput.nativeElement, 'keyup').pipe( 52 | // get value 53 | map((event: any) => { 54 | event.target.value.length < 3 && !this.isGetPeople ? this.getPeople() : null; 55 | return event.target.value; 56 | }) 57 | // if character length greater then 2 58 | , filter(res => res.length > 2) 59 | // Time in milliseconds between key events 60 | , debounceTime(250) 61 | // If previous query is diffent from current 62 | // , distinctUntilChanged() 63 | // subscription for response 64 | ).subscribe((text: string) => { 65 | this.service.searchPeopleByName(text).subscribe((res) => { 66 | this.isGetPeople = false; 67 | console.log('res', res); 68 | this.peopleList = res; 69 | }, (err) => { 70 | console.log('error', err); 71 | }); 72 | }); 73 | } 74 | public getPeople(desc: boolean = false) { 75 | return this.service.getPeopleList(desc) 76 | .subscribe((data: any = []) => { 77 | if (data.success == false) { 78 | this.router.navigateByUrl(''); 79 | } 80 | else { 81 | this.isGetPeople = true; 82 | this.peopleList = data.slice(0, 5); 83 | console.log(this.peopleList); 84 | } 85 | }); 86 | } 87 | 88 | public clickInsert() { 89 | 90 | this.personModel = new Person(); 91 | this.name = new Name(); 92 | this.personModel.name = this.name; 93 | 94 | this.isInsert = !this.isInsert; 95 | this.isEdit = false; 96 | }; 97 | 98 | public Edit(data: Person) { 99 | this.isEdit = (this.personModel == data || this.isInsert == true) ? !this.isEdit : this.isEdit; 100 | this.personModel = data; 101 | this.isInsert = false; 102 | } 103 | 104 | public Delete(data: Person) { 105 | if (confirm("Silmek istediğinize emin misiniz ")) { 106 | this.service.deletePeople(data).subscribe((data: any) => { 107 | if (data.success == false) { 108 | this.router.navigateByUrl(''); 109 | } 110 | else { 111 | console.log("Sil:" + data.username); 112 | this.getPeople(); 113 | } 114 | }); 115 | } 116 | } 117 | 118 | public Save() { 119 | if (this.isEdit) { 120 | this.service.updatePerson(this.personModel).subscribe((data: any) => { 121 | if (data.success == false) { 122 | this.router.navigateByUrl(''); 123 | } 124 | }); 125 | this.personModel = null; 126 | this.isEdit = false; 127 | } 128 | else if (this.isInsert) { 129 | this.service.insertPeople(this.personModel).subscribe((data: any) => { 130 | if (data.success == false) { 131 | this.router.navigateByUrl(''); 132 | } 133 | else { 134 | this.getPeople(true); 135 | } 136 | }); 137 | this.personModel = null; 138 | this.isInsert = false; 139 | } 140 | } 141 | 142 | public Next() { 143 | this.currentPagecount = this.currentPagecount + 1 >= 0 ? this.currentPagecount + 1 : this.currentPagecount 144 | return this.service.getPeopleListByPaging(this.currentPagecount).subscribe((data: any = []) => { 145 | if (data.success == false) { 146 | this.router.navigateByUrl(''); 147 | } 148 | else { 149 | if (data.length == 0) { 150 | this.currentPagecount = this.currentPagecount - 1; 151 | this.isNextActive = false; 152 | } 153 | else { 154 | this.isNextActive = true; 155 | this.peopleList = data; 156 | this.isPreviewActive = true; 157 | } 158 | console.log(this.peopleList); 159 | } 160 | }); 161 | } 162 | public Preview() { 163 | this.currentPagecount = this.currentPagecount - 1 > 0 ? this.currentPagecount - 1 : this.currentPagecount 164 | return this.service.getPeopleListByPaging(this.currentPagecount).subscribe((data: any = []) => { 165 | if (data.success == false) { 166 | this.router.navigateByUrl(''); 167 | } 168 | else { 169 | if (data.length > 0) { 170 | this.isNextActive = true; 171 | this.isPreviewActive = true; 172 | this.peopleList = data; 173 | } 174 | this.isPreviewActive = this.currentPagecount == 1 ? false : true; 175 | console.log(this.peopleList); 176 | } 177 | }); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { PersonService } from 'src/Service/personService'; 6 | import { HttpClientModule } from '@angular/common/http'; 7 | import { FormsModule } from '@angular/forms'; 8 | import { LoginComponent } from './login'; 9 | import { AppRoutingModule } from './app-routing.module'; 10 | import { MainComponent } from './main'; 11 | 12 | import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io'; 13 | const config: SocketIoConfig = { url: 'http://localhost:1453', options: {} }; 14 | @NgModule({ 15 | declarations: [ 16 | AppComponent, 17 | LoginComponent, 18 | MainComponent 19 | ], 20 | imports: [ 21 | BrowserModule, 22 | FormsModule, 23 | HttpClientModule, 24 | AppRoutingModule, 25 | SocketIoModule.forRoot(config) 26 | ], 27 | providers: [PersonService], 28 | bootstrap: [MainComponent] 29 | }) 30 | export class AppModule { } 31 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/login.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 17 |
18 |
19 |
20 |
-------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/login.scss: -------------------------------------------------------------------------------- 1 | .form-signin 2 | { 3 | padding-top: 20px; 4 | padding-right: 20px; 5 | padding-bottom: 20px; 6 | padding-left: 20px; 7 | 8 | margin-top:25%; 9 | margin-left:40%; 10 | 11 | background-color:#F5F5F5; 12 | border: 1px solid rgba(0,0,0,0.1); 13 | } 14 | .wrapper { 15 | text-align: center; 16 | } 17 | 18 | .button { 19 | position: absolute; 20 | top: 50%; 21 | } 22 | 23 | #heading 24 | { 25 | padding-bottom: 20px; 26 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/login.ts: -------------------------------------------------------------------------------- 1 | import { Component, AfterViewInit } from '@angular/core'; 2 | import { PersonService } from 'src/Service/personService'; 3 | import { Router } from '@angular/router'; 4 | @Component({ 5 | templateUrl: './login.html', 6 | styleUrls: ['./login.scss'] 7 | }) 8 | export class LoginComponent implements AfterViewInit { 9 | userName: string; 10 | password: string; 11 | constructor(public service: PersonService, private router: Router) { } 12 | ngAfterViewInit(): void { 13 | this.service.checkToken().subscribe((data: any) => { 14 | if (data.success != false) { 15 | this.router.navigateByUrl('person'); 16 | } 17 | }); 18 | //throw new Error("Method not implemented."); 19 | } 20 | 21 | Redirect() { 22 | this.service.login(this.userName, this.password).subscribe((data: any) => { 23 | debugger; 24 | window.localStorage.setItem("token", data.token); 25 | window.localStorage.setItem("refreshToken", data.refreshToken); 26 | window.localStorage.setItem("createdDate", new Date().toString()); 27 | this.router.navigateByUrl('person'); 28 | }); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './main.html' 6 | }) 7 | export class MainComponent { 8 | constructor() { } 9 | 10 | } -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/assets/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borakasmer/SocketIO-Angular8-Redis-NodeJS/9b0bfbd2d40fc6d465141289ffc03b612144c61b/mongoDb/HumanResource/src/assets/img/logo.png -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borakasmer/SocketIO-Angular8-Redis-NodeJS/9b0bfbd2d40fc6d465141289ffc03b612144c61b/mongoDb/HumanResource/src/favicon.ico -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HumanResource 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "include": [ 8 | "src/**/*.ts" 9 | ], 10 | "exclude": [ 11 | "src/test.ts", 12 | "src/**/*.spec.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | }, 22 | "angularCompilerOptions": { 23 | "fullTemplateTypeCheck": true, 24 | "strictInjectionParameters": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /mongoDb/HumanResource/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "array-type": false, 5 | "arrow-parens": false, 6 | "deprecation": { 7 | "severity": "warning" 8 | }, 9 | "component-class-suffix": true, 10 | "contextual-lifecycle": true, 11 | "directive-class-suffix": true, 12 | "directive-selector": [ 13 | true, 14 | "attribute", 15 | "app", 16 | "camelCase" 17 | ], 18 | "component-selector": [ 19 | true, 20 | "element", 21 | "app", 22 | "kebab-case" 23 | ], 24 | "import-blacklist": [ 25 | true, 26 | "rxjs/Rx" 27 | ], 28 | "interface-name": false, 29 | "max-classes-per-file": false, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-consecutive-blank-lines": false, 47 | "no-console": [ 48 | true, 49 | "debug", 50 | "info", 51 | "time", 52 | "timeEnd", 53 | "trace" 54 | ], 55 | "no-empty": false, 56 | "no-inferrable-types": [ 57 | true, 58 | "ignore-params" 59 | ], 60 | "no-non-null-assertion": true, 61 | "no-redundant-jsdoc": true, 62 | "no-switch-case-fall-through": true, 63 | "no-use-before-declare": true, 64 | "no-var-requires": false, 65 | "object-literal-key-quotes": [ 66 | true, 67 | "as-needed" 68 | ], 69 | "object-literal-sort-keys": false, 70 | "ordered-imports": false, 71 | "quotemark": [ 72 | true, 73 | "single" 74 | ], 75 | "trailing-comma": false, 76 | "no-conflicting-lifecycle": true, 77 | "no-host-metadata-property": true, 78 | "no-input-rename": true, 79 | "no-inputs-metadata-property": true, 80 | "no-output-native": true, 81 | "no-output-on-prefix": true, 82 | "no-output-rename": true, 83 | "no-outputs-metadata-property": true, 84 | "template-banana-in-box": true, 85 | "template-no-negated-async": true, 86 | "use-lifecycle-interface": true, 87 | "use-pipe-transform-interface": true 88 | }, 89 | "rulesDirectory": [ 90 | "codelyzer" 91 | ] 92 | } -------------------------------------------------------------------------------- /mongoDb/Socket/app.js: -------------------------------------------------------------------------------- 1 | const app = require('express')(); 2 | const server = require('http').Server(app); 3 | const io = require('socket.io')(server); 4 | 5 | server.listen(1453); 6 | 7 | io.on('connection', (socket) => { 8 | console.log('User Socket Connected'); 9 | socket.on("disconnect", () => console.log(`${socket.id} User disconnected.`)); 10 | 11 | socket.broadcast.on("sendUpdatePerson", person => { 12 | console.log("Update Person:" + person.name.first + ' ' + person.name.last); 13 | socket.broadcast.emit("Updatedperson", person); 14 | }); 15 | // Yeni EKLENDİ Insert Person 16 | socket.broadcast.on("sendSavePerson", person => { 17 | console.log("Saved Person:" + person.name.first + ' ' + person.name.last); 18 | socket.broadcast.emit("Savedperson", person); 19 | }); 20 | //------------------------------- 21 | 22 | // Yeni EKLENDİ Delete Person 23 | socket.broadcast.on("sendDeletePerson", person => { 24 | console.log("Deleted Person:" + person.name.first + ' ' + person.name.last); 25 | socket.broadcast.emit("Deletedperson", person); 26 | }); 27 | //------------------------------- 28 | }); 29 | -------------------------------------------------------------------------------- /mongoDb/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | secret: 'cutthenightwiththelight', 3 | salt: 'c3d3b76f0d085898f6c5a3738ac9a167' 4 | }; -------------------------------------------------------------------------------- /mongoDb/service.js: -------------------------------------------------------------------------------- 1 | var express = require("express"); 2 | var mongoose = require("mongoose"); 3 | var cors = require("cors"); 4 | var app = express(); 5 | 6 | let jwt = require('jsonwebtoken'); 7 | let config = require('./config'); 8 | let token = require('./token'); 9 | var crypto = require('crypto'); //Default Geliyor 10 | 11 | //Redis 12 | var redis = require('redis'); 13 | var redisClient = redis.createClient(); //creates a new client 14 | 15 | 16 | redisClient.on('connect', function () { 17 | console.log('Redis client bağlandı'); 18 | }); 19 | 20 | redisClient.on('error', function (err) { 21 | console.log('Redis Clientda bir hata var ' + err); 22 | }); 23 | //Redis End 24 | 25 | app.use(cors({ 26 | exposedHeaders: ['Content-Length', 'Content-Type', 'Authorization', 'RefreshToken', 'Token'], 27 | })); 28 | 29 | //Swagger 30 | var swaggerUi = require('swagger-ui-express'); 31 | swaggerDocument = require('./swagger.json'); 32 | 33 | app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); 34 | //--------------------- 35 | 36 | var bodyParser = require('body-parser'); 37 | 38 | app.use(bodyParser.urlencoded({ 39 | extended: false 40 | })); 41 | 42 | app.use(bodyParser.json()); 43 | 44 | 45 | mongoose.connect('mongodb://localhost/people', { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true }); 46 | mongoose.set('useFindAndModify', false); 47 | 48 | var humanSchema = new mongoose.Schema({ 49 | gender: String, 50 | email: String, 51 | username: String, 52 | name: { 53 | title: String, 54 | first: String, 55 | last: String 56 | }, 57 | fullName: String 58 | }); 59 | 60 | var ClientSchema = new mongoose.Schema({ 61 | username: { 62 | type: String, 63 | required: true, 64 | minlength: 3, 65 | maxlength: 50 66 | }, 67 | email: { 68 | type: String, 69 | required: true, 70 | minlength: 5, 71 | maxlength: 255, 72 | unique: true 73 | }, 74 | password: { 75 | type: String, 76 | required: true, 77 | minlength: 3, 78 | maxlength: 255 79 | } 80 | }); 81 | 82 | var Client = mongoose.model('Client', ClientSchema, 'clients'); 83 | var Human = mongoose.model('Human', humanSchema, 'users'); 84 | 85 | /* app.get('/', function (req, res) { 86 | res.send("Selam Millet @coderBora"); 87 | }) */ 88 | 89 | app.get("/people", token, function (req, res) { 90 | //res.send("Günaydın Millet"); 91 | if (redisClient.connected) { 92 | //Redis Search 93 | redisClient.keys('User*', function (err, keys) { 94 | if (err) return console.log(err); 95 | 96 | if (keys.length > 0) {//Redis'de kayıt var ise ordan gelir. 97 | var personList = []; 98 | for (var i = 0, len = keys.length; i < len; i++) { 99 | //console.log("i:" + i); 100 | redisClient.get(keys[i], function (err, user) { 101 | //console.log(user); 102 | personList.push(JSON.parse(user)); 103 | //console.log('len:' + keys.length) 104 | if (personList.length == keys.length - 1) { 105 | res.send(personList); 106 | //console.log(personList); 107 | } 108 | }) 109 | } 110 | } 111 | else { 112 | //Read All Data From MongoDB. Redis'de kayıt yok. 113 | var counter = 0; 114 | Human.find(function (err, doc) { 115 | doc.forEach(function (item) { 116 | //counter += 1; 117 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 118 | //Write All Data To Redis 119 | //var userName = 'User' + counter; 120 | var userName = 'User:' + item._doc.username; 121 | redisClient.get(userName, function (err, user) { 122 | if (user == null) { 123 | var data = JSON.stringify(item._doc); 124 | console.log(data); 125 | redisClient.set(userName, data, function (err, res) { }); 126 | } 127 | else { 128 | console.log(JSON.parse(user).name.first); 129 | } 130 | }); 131 | //End Redis Write 132 | }); 133 | res.send(doc); 134 | }) 135 | } 136 | }); 137 | //--- 138 | } 139 | else //Redis Connect Değil ise mongoDB'den çekilir. 140 | { 141 | //var counter = 0; 142 | Human.find(function (err, doc) { 143 | doc.forEach(function (item) { 144 | //counter += 1; 145 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 146 | }); 147 | res.send(doc); 148 | }) 149 | } 150 | }) 151 | 152 | app.get("/peopleDesc", token, function (req, res) { 153 | //res.send("Günaydın Millet"); 154 | Human.find() 155 | .sort('-_id') 156 | .exec( 157 | function (err, doc) { 158 | doc.forEach(function (item) { 159 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 160 | }); 161 | res.send(doc); 162 | }) 163 | }) 164 | 165 | app.get("/getpeoplebyPaging/:page/:count", token, function (req, res) { 166 | //res.send("Günaydın Millet"); 167 | var page = parseInt(req.params.page) - 1; 168 | var rowCount = parseInt(req.params.count); 169 | var skip = page * rowCount; 170 | Human.find() 171 | .skip(skip) 172 | .limit(rowCount) 173 | .exec( 174 | function (err, doc) { 175 | if (doc != null) { 176 | doc.forEach(function (item) { 177 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 178 | }); 179 | } 180 | res.send(doc); 181 | } 182 | ) 183 | }) 184 | 185 | app.get("/getpeopleByUsername/:name", token, function (req, res) { 186 | //res.send("Günaydın Millet"); 187 | console.log(req) 188 | var query = { username: req.params.name }; 189 | Human.find(query, function (err, doc) { 190 | doc.forEach(function (item) { 191 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 192 | }); 193 | res.send(doc); 194 | }) 195 | }) 196 | app.get("/getpeopleByLastname", token, function (req, res) { 197 | //res.send("Günaydın Millet"); 198 | var query = { "name.last": req.query.lastname }; 199 | Human.find(query, function (err, doc) { 200 | doc.forEach(function (item) { 201 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 202 | }); 203 | res.send(doc); 204 | }) 205 | }) 206 | 207 | app.get("/getpeopleContainsOrderTopWith/:name/:top", token, function (req, res) { 208 | //res.send("Günaydın Millet"); 209 | var query = { "name.first": { $regex: req.params.name } }; 210 | var top = parseInt(req.params.top); 211 | Human.find(query) 212 | .sort('-name.first') 213 | .skip(1) 214 | .limit(top) 215 | .exec( 216 | function (err, doc) { 217 | doc.forEach(function (item) { 218 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 219 | }); 220 | res.send(doc); 221 | } 222 | ) 223 | }) 224 | 225 | app.get("/getpeopleStartsWith/:name", token, function (req, res) { 226 | //res.send("Günaydın Millet"); 227 | var query = { "name.first": { $regex: '^' + req.params.name } }; 228 | Human.find(query, function (err, doc) { 229 | doc.forEach(function (item) { 230 | item.fullName = item._doc.name.first + ' ' + item._doc.name.last; 231 | }); 232 | res.send(doc); 233 | }) 234 | }) 235 | 236 | app.post('/insertPeople', token, async (req, res) => { 237 | console.log("req.body : " + req.body.username); 238 | console.log("req.body.last : " + req.body.name.last); 239 | try { 240 | var person = new Human(req.body); 241 | var result = await person.save(); 242 | //Redis Insert 243 | if (redisClient.connected) { 244 | var userName = 'User:' + req.body.username; 245 | var data = JSON.stringify(person); 246 | redisClient.set(userName, data, function (err, res) { }); 247 | } 248 | //-------------- 249 | res.send(result); 250 | } catch (error) { 251 | res.status(500).send(error); 252 | } 253 | }) 254 | 255 | app.post('/updatePeople', token, async (req, res) => { 256 | console.log("req.username : " + req.body.username); 257 | try { 258 | var updatePerson = new Human(req.body); 259 | const person = await Human.findOne({ username: updatePerson.username }); 260 | await person.updateOne(updatePerson); 261 | 262 | //Redis Update 263 | if (redisClient.connected) { 264 | var userName = 'User:' + updatePerson.username; 265 | var data = JSON.stringify(updatePerson); 266 | redisClient.set(userName, data, function (err, res) { }); 267 | } 268 | //-------------- 269 | 270 | /* return res.send("succesfully saved"); */ 271 | /* return true; */ 272 | return res.status(200).json({ status: "succesfully update" }); 273 | } catch (error) { 274 | res.status(500).send(error); 275 | } 276 | }) 277 | 278 | app.post('/login', async (req, res) => { 279 | try { 280 | console.log("req.username : " + req.body.username); 281 | console.log("req.password : " + req.body.password); 282 | var password = Decrypt(req.body.password); 283 | //Encrypt 284 | this.salt = config.salt; 285 | //this.salt = crypto.randomBytes(16).toString('hex'); 286 | this.hash = crypto.pbkdf2Sync(password, this.salt, 1000, 64, 'sha512').toString('hex'); 287 | //-------------------------- 288 | var query = { username: req.body.username, password: this.hash }; 289 | Client.find(query, function (err, doc) { 290 | if (doc.length > 0) { 291 | let token = jwt.sign({ username: req.body.username }, 292 | config.secret, 293 | { 294 | expiresIn: '1h' // expires in 1 hour 295 | /* expiresIn: 15 // expires in 15 minutes */ 296 | } 297 | ); 298 | var refreshToken = jwt.sign({ username: req.body.username }, 299 | config.secret, 300 | { 301 | expiresIn: '2h' // expires in 2 hour 302 | } 303 | ); 304 | return res.status(200).json({ status: "succesfully login", token: token, refreshToken: refreshToken, success: true }); 305 | } 306 | else { 307 | return res.status(401).send("Username or Password Wrong!"); 308 | } 309 | }) 310 | 311 | /* if (req.params.username == "bora" && req.params.password == "123456") { 312 | return res.status(200).json({ status: "succesfully login" }); 313 | } 314 | else { 315 | return res.status(401).send("Username or Password Wrong!"); 316 | }*/ 317 | } catch (error) { 318 | res.status(500).send(error); 319 | } 320 | }) 321 | 322 | app.get("/checkToken", token, function (req, res) { 323 | return res.status(200).json({ status: "succesfully logedin" }); 324 | }); 325 | 326 | 327 | app.post('/deletePeople', token, (req, res) => { 328 | console.log("req.username : " + req.body.username); 329 | try { 330 | var deletePerson = new Human(req.body); 331 | Human.findOneAndRemove({ username: deletePerson.username }) 332 | .then(function (doc) { 333 | if (doc) { 334 | //return res.send("succesfully delete"); 335 | //Redis Update 336 | if (redisClient.connected) { 337 | var userName = 'User:' + req.body.username; 338 | redisClient.del(userName); 339 | } 340 | //----------------- 341 | return res.status(200).json({ status: "succesfully delete" }); 342 | } 343 | else { 344 | return res.send("no document found!"); 345 | } 346 | }).catch(function (error) { 347 | throw error; 348 | }); 349 | } catch (error) { 350 | res.status(500).send(error); 351 | } 352 | }) 353 | 354 | function Decrypt(password) { 355 | let keyStr = "ABCDEFGHIJKLMNOP" + 356 | "QRSTUVWXYZabcdef" + 357 | "ghijklmnopqrstuv" + 358 | "wxyz0123456789+/" + 359 | "="; 360 | 361 | var output = ""; 362 | 363 | var i = 0; 364 | password = password.replace("/[^ A - Za - z0 - 9\+\/\=] / g", ""); 365 | do { 366 | var enc1 = keyStr.indexOf(password[i++]); 367 | var enc2 = keyStr.indexOf(password[i++]); 368 | var enc3 = keyStr.indexOf(password[i++]); 369 | var enc4 = keyStr.indexOf(password[i++]); 370 | 371 | var chr1 = (enc1 << 2) | (enc2 >> 4); 372 | var chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 373 | var chr3 = ((enc3 & 3) << 6) | enc4; 374 | 375 | output = output + String.fromCharCode(chr1); 376 | if (enc3 != 64) { 377 | output = output + String.fromCharCode(chr2); 378 | } 379 | if (enc4 != 64) { 380 | output = output + String.fromCharCode(chr3); 381 | } 382 | chr1 = chr2 = chr3 = null; 383 | enc1 = enc2 = enc3 = enc4 = null; 384 | } while (i < password.length); 385 | output = unescape(output); 386 | var pattern = new RegExp("[|]"); 387 | output = output.replace(pattern, "+"); 388 | return output; 389 | } 390 | 391 | app.listen(9480); 392 | 393 | /* mongoimport--db people--collection users--jsonArray users.js */ 394 | /* https://petstore.swagger.io/ */ 395 | /* https://editor.swagger.io/ */ -------------------------------------------------------------------------------- /mongoDb/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "securityDefinitions": { 4 | "Bearer": { 5 | "type": "apiKey", 6 | "name": "Authorization", 7 | "in": "header", 8 | "description": "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\"" 9 | } 10 | }, 11 | "info": { 12 | "version": "1.0.0", 13 | "title": "coderBora-NodeJS-CRUD-MongoDB", 14 | "description": "A minimal and easy to follow example of what you need to create a CRUD style API in NodeJs", 15 | "license": { 16 | "name": "MIT", 17 | "url": "https://opensource.org/licenses/MIT" 18 | } 19 | }, 20 | "tags": [ 21 | { 22 | "name": "People", 23 | "description": "API for users in the Hueman Resource" 24 | } 25 | ], 26 | "consumes": [ 27 | "application/json" 28 | ], 29 | "produces": [ 30 | "application/json" 31 | ], 32 | "paths": { 33 | "/login": { 34 | "post": { 35 | "tags": [ 36 | "Users" 37 | ], 38 | "summary": "Log in system", 39 | "produces": [ 40 | "application/json" 41 | ], 42 | "parameters": [ 43 | { 44 | "name": "credential", 45 | "in": "body", 46 | "required": true, 47 | "description": "Login user", 48 | "schema": { 49 | "type": "object", 50 | "properties": { 51 | "username": { 52 | "type": "string" 53 | }, 54 | "password": { 55 | "type": "string" 56 | } 57 | } 58 | } 59 | } 60 | ], 61 | "responses": { 62 | "200": { 63 | "description": "OK", 64 | "schema": { 65 | "$ref": "#/definitions/User" 66 | } 67 | }, 68 | "401": { 69 | "description": "Failed. Not authorized user." 70 | } 71 | } 72 | } 73 | }, 74 | "/people": { 75 | "get": { 76 | "tags": [ 77 | "Users" 78 | ], 79 | "security": [ 80 | { 81 | "Bearer": [] 82 | } 83 | ], 84 | "summary": "Get all users in system", 85 | "responses": { 86 | "200": { 87 | "description": "OK", 88 | "schema": { 89 | "$ref": "#/definitions/User" 90 | } 91 | } 92 | } 93 | } 94 | }, 95 | "/peopleDesc": { 96 | "get": { 97 | "tags": [ 98 | "Users" 99 | ], 100 | "security": [ 101 | { 102 | "Bearer": [] 103 | } 104 | ], 105 | "summary": "Get all users descending in system", 106 | "responses": { 107 | "200": { 108 | "description": "OK", 109 | "schema": { 110 | "$ref": "#/definitions/User" 111 | } 112 | } 113 | } 114 | } 115 | }, 116 | "/insertPeople": { 117 | "post": { 118 | "tags": [ 119 | "Users" 120 | ], 121 | "summary": "Create a new user in system", 122 | "produces": [ 123 | "application/json" 124 | ], 125 | "parameters": [ 126 | { 127 | "name": "model", 128 | "in": "body", 129 | "description": "person detail", 130 | "required": true, 131 | "schema": { 132 | "$ref": "#/definitions/User" 133 | } 134 | } 135 | ], 136 | "security": [ 137 | { 138 | "Bearer": [] 139 | } 140 | ], 141 | "responses": { 142 | "200": { 143 | "description": "OK", 144 | "schema": { 145 | "$ref": "#/definitions/User" 146 | } 147 | }, 148 | "400": { 149 | "description": "Failed. Bad post data." 150 | } 151 | } 152 | } 153 | }, 154 | "/getpeoplebyPaging/{page}/{count}": { 155 | "get": { 156 | "tags": [ 157 | "Users" 158 | ], 159 | "security": [ 160 | { 161 | "Bearer": [] 162 | } 163 | ], 164 | "summary": "Get user list by paging", 165 | "parameters": [ 166 | { 167 | "name": "page", 168 | "in": "path", 169 | "required": true, 170 | "description": "Page number of person list", 171 | "type": "string" 172 | }, 173 | { 174 | "name": "count", 175 | "in": "path", 176 | "required": true, 177 | "description": "Get total User count per page", 178 | "type": "string" 179 | } 180 | ], 181 | "responses": { 182 | "200": { 183 | "description": "OK", 184 | "schema": { 185 | "$ref": "#/definitions/User" 186 | } 187 | }, 188 | "404": { 189 | "description": "Failed. Cat not found." 190 | } 191 | } 192 | } 193 | }, 194 | "/getpeopleByUsername/{name}": { 195 | "get": { 196 | "tags": [ 197 | "Users" 198 | ], 199 | "summary": "Get user list by userName", 200 | "security": [ 201 | { 202 | "Bearer": [] 203 | } 204 | ], 205 | "parameters": [ 206 | { 207 | "name": "name", 208 | "in": "path", 209 | "required": true, 210 | "description": "Get UserName for filter", 211 | "type": "string" 212 | } 213 | ], 214 | "responses": { 215 | "200": { 216 | "description": "OK", 217 | "schema": { 218 | "$ref": "#/definitions/User" 219 | } 220 | }, 221 | "404": { 222 | "description": "Failed. Cat not found." 223 | } 224 | } 225 | } 226 | }, 227 | "/getpeopleByLastname": { 228 | "get": { 229 | "tags": [ 230 | "Users" 231 | ], 232 | "security": [ 233 | { 234 | "Bearer": [] 235 | } 236 | ], 237 | "summary": "Get user list by lastName", 238 | "parameters": [ 239 | { 240 | "name": "lastname", 241 | "in": "query", 242 | "required": true, 243 | "description": "Get Lastname for filter", 244 | "type": "string" 245 | } 246 | ], 247 | "responses": { 248 | "200": { 249 | "description": "OK", 250 | "schema": { 251 | "$ref": "#/definitions/User" 252 | } 253 | }, 254 | "404": { 255 | "description": "Failed. Cat not found." 256 | } 257 | } 258 | } 259 | }, 260 | "/getpeopleContainsOrderTopWith/{name}/{top}": { 261 | "get": { 262 | "tags": [ 263 | "Users" 264 | ], 265 | "security": [ 266 | { 267 | "Bearer": [] 268 | } 269 | ], 270 | "summary": "Get user list contains name descending order. Take Top count item", 271 | "parameters": [ 272 | { 273 | "name": "name", 274 | "in": "path", 275 | "required": true, 276 | "description": "Contains name in the UserList", 277 | "type": "string" 278 | }, 279 | { 280 | "name": "top", 281 | "in": "path", 282 | "required": true, 283 | "description": "Get taken total User count", 284 | "type": "string" 285 | } 286 | ], 287 | "responses": { 288 | "200": { 289 | "description": "OK", 290 | "schema": { 291 | "$ref": "#/definitions/User" 292 | } 293 | }, 294 | "404": { 295 | "description": "Failed. Cat not found." 296 | } 297 | } 298 | } 299 | }, 300 | "/getpeopleStartsWith/{name}": { 301 | "get": { 302 | "tags": [ 303 | "Users" 304 | ], 305 | "security": [ 306 | { 307 | "Bearer": [] 308 | } 309 | ], 310 | "summary": "Get user list starts with name.", 311 | "parameters": [ 312 | { 313 | "name": "name", 314 | "in": "path", 315 | "required": true, 316 | "description": "Contains name in the UserList", 317 | "type": "string" 318 | } 319 | ], 320 | "responses": { 321 | "200": { 322 | "description": "OK", 323 | "schema": { 324 | "$ref": "#/definitions/User" 325 | } 326 | }, 327 | "404": { 328 | "description": "Failed. Cat not found." 329 | } 330 | } 331 | } 332 | }, 333 | "/updatePeople": { 334 | "post": { 335 | "tags": [ 336 | "Users" 337 | ], 338 | "security": [ 339 | { 340 | "Bearer": [] 341 | } 342 | ], 343 | "summary": "Update user in system", 344 | "produces": [ 345 | "application/json" 346 | ], 347 | "parameters": [ 348 | { 349 | "name": "model", 350 | "in": "body", 351 | "description": "person detail", 352 | "required": true, 353 | "schema": { 354 | "$ref": "#/definitions/User" 355 | } 356 | } 357 | ], 358 | "responses": { 359 | "200": { 360 | "description": "OK", 361 | "schema": { 362 | "$ref": "#/definitions/User" 363 | } 364 | }, 365 | "400": { 366 | "description": "Failed. Bad post data." 367 | } 368 | } 369 | } 370 | }, 371 | "/deletePeople": { 372 | "post": { 373 | "tags": [ 374 | "Users" 375 | ], 376 | "security": [ 377 | { 378 | "Bearer": [] 379 | } 380 | ], 381 | "summary": "Delete a user in system", 382 | "produces": [ 383 | "application/json" 384 | ], 385 | "parameters": [ 386 | { 387 | "name": "model", 388 | "in": "body", 389 | "description": "person detail", 390 | "required": true, 391 | "schema": { 392 | "$ref": "#/definitions/User" 393 | } 394 | } 395 | ], 396 | "responses": { 397 | "200": { 398 | "description": "OK", 399 | "schema": { 400 | "$ref": "#/definitions/User" 401 | } 402 | }, 403 | "400": { 404 | "description": "Failed. Bad post data." 405 | } 406 | } 407 | } 408 | } 409 | }, 410 | "definitions": { 411 | "User": { 412 | "type": "object", 413 | "properties": { 414 | "gender": { 415 | "type": "string" 416 | }, 417 | "email": { 418 | "type": "string" 419 | }, 420 | "username": { 421 | "type": "string" 422 | }, 423 | "name": { 424 | "type": "object", 425 | "properties": { 426 | "title": { 427 | "type": "string" 428 | }, 429 | "first": { 430 | "type": "string" 431 | }, 432 | "last": { 433 | "type": "string" 434 | } 435 | } 436 | } 437 | } 438 | } 439 | } 440 | } -------------------------------------------------------------------------------- /mongoDb/token.js: -------------------------------------------------------------------------------- 1 | let jwt = require('jsonwebtoken'); 2 | //npm install jsonwebtoken 3 | 4 | const config = require('./config.js'); 5 | 6 | module.exports = (req, res, next) => { 7 | let token = req.headers['x-access-token'] || req.headers['authorization']; // Express headers are auto converted to lowercase 8 | if (token != undefined && token.startsWith('Bearer ')) { 9 | // Remove Bearer from string 10 | token = token.slice(7, token.length); 11 | } 12 | 13 | if (token && token != "undefined" && token != undefined) { 14 | jwt.verify(token, config.secret, (err, decoded) => { 15 | if (err) { 16 | return res.json({ 17 | success: false, 18 | message: 'Token is not valid' 19 | }); 20 | } else { 21 | req.decoded = decoded; 22 | var exp = new Date(decoded.exp * 1000); 23 | //var iat = new Date(decoded.iat * 1000); 24 | var now = new Date(); 25 | var difference = exp.getTime() - now.getTime(); 26 | var resultInMinutes = Math.round(difference / 60000); 27 | //Refresh Token Time 28 | if (resultInMinutes < 59) { //resultInMinutes < 15 olacak 29 | var refreshToken = req.headers['refreshtoken'] 30 | if (refreshToken && refreshToken!="" && refreshToken != "undefined" && refreshToken != undefined) { 31 | jwt.verify(refreshToken, config.secret, (err, decoded) => { 32 | if (err) { 33 | console.log(err); 34 | } else { 35 | var newToken = jwt.sign({ username: decoded.username }, 36 | config.secret, 37 | { 38 | expiresIn: '1h' // expires in 1 hour 39 | } 40 | ); 41 | var newRefreshToken = jwt.sign({ username: decoded.username }, 42 | config.secret, 43 | { 44 | expiresIn: '2h' // expires in 2 hour 45 | } 46 | ); 47 | res.setHeader('Token', newToken); 48 | res.setHeader('RefreshToken', newRefreshToken); 49 | } 50 | }) 51 | } 52 | } 53 | // End Refresh Token ----------- 54 | next(); 55 | } 56 | }); 57 | } else { 58 | return res.json({ 59 | success: false, 60 | message: 'Auth token is not supplied' 61 | }); 62 | } 63 | }; -------------------------------------------------------------------------------- /mongoDb/users.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "gender": "female", 4 | "name": { 5 | "title": "miss", 6 | "first": "mary", 7 | "last": "jones" 8 | }, 9 | "email": "mary.jones56@example.com", 10 | "username": "crazypeacock512" 11 | }, 12 | { 13 | "gender": "male", 14 | "name": { 15 | "title": "mr", 16 | "first": "alan", 17 | "last": "walters" 18 | }, 19 | "email": "alan.walters29@example.com", 20 | "username": "crazytiger134" 21 | }, 22 | { 23 | "gender": "female", 24 | "name": { 25 | "title": "miss", 26 | "first": "miriam", 27 | "last": "wallace" 28 | }, 29 | "email": "miriam.wallace36@example.com", 30 | "username": "blackpanda974" 31 | }, 32 | { 33 | "gender": "female", 34 | "name": { 35 | "title": "mrs", 36 | "first": "annette", 37 | "last": "black" 38 | }, 39 | "email": "annette.black70@example.com", 40 | "username": "greenelephant690" 41 | }, 42 | { 43 | "gender": "male", 44 | "name": { 45 | "title": "mr", 46 | "first": "joshua", 47 | "last": "pearson" 48 | }, 49 | "email": "joshua.pearson33@example.com", 50 | "username": "bluebutterfly167" 51 | }, 52 | { 53 | "gender": "male", 54 | "name": { 55 | "title": "mr", 56 | "first": "willard", 57 | "last": "barrett" 58 | }, 59 | "email": "willard.barrett17@example.com", 60 | "username": "redfrog150" 61 | }, 62 | { 63 | "gender": "female", 64 | "name": { 65 | "title": "miss", 66 | "first": "lucy", 67 | "last": "hansen" 68 | }, 69 | "email": "lucy.hansen42@example.com", 70 | "username": "bluesnake414" 71 | }, 72 | { 73 | "gender": "male", 74 | "name": { 75 | "title": "mr", 76 | "first": "johnni", 77 | "last": "franklin" 78 | }, 79 | "email": "johnni.franklin85@example.com", 80 | "username": "biglion303" 81 | }, 82 | { 83 | "gender": "male", 84 | "name": { 85 | "title": "mr", 86 | "first": "kenneth", 87 | "last": "warren" 88 | }, 89 | "email": "kenneth.warren82@example.com", 90 | "username": "goldenkoala804" 91 | }, 92 | { 93 | "gender": "male", 94 | "name": { 95 | "title": "mr", 96 | "first": "sergio", 97 | "last": "ryan" 98 | }, 99 | "email": "sergio.ryan90@example.com", 100 | "username": "smallsnake403" 101 | }, 102 | { 103 | "gender": "male", 104 | "name": { 105 | "title": "mr", 106 | "first": "michael", 107 | "last": "hart" 108 | }, 109 | "email": "michael.hart69@example.com", 110 | "username": "browndog574" 111 | }, 112 | { 113 | "gender": "male", 114 | "name": { 115 | "title": "mr", 116 | "first": "judd", 117 | "last": "steeves" 118 | }, 119 | "email": "judd.steeves56@example.com", 120 | "username": "purpleswan777" 121 | }, 122 | { 123 | "gender": "male", 124 | "name": { 125 | "title": "mr", 126 | "first": "aiden", 127 | "last": "peterson" 128 | }, 129 | "email": "aiden.peterson83@example.com", 130 | "username": "crazypanda94" 131 | }, 132 | { 133 | "gender": "male", 134 | "name": { 135 | "title": "mr", 136 | "first": "edwin", 137 | "last": "morales" 138 | }, 139 | "email": "edwin.morales41@example.com", 140 | "username": "bigkoala328" 141 | }, 142 | { 143 | "gender": "female", 144 | "name": { 145 | "title": "miss", 146 | "first": "gail", 147 | "last": "holmes" 148 | }, 149 | "email": "gail.holmes71@example.com", 150 | "username": "silvertiger605" 151 | }, 152 | { 153 | "gender": "female", 154 | "name": { 155 | "title": "mrs", 156 | "first": "jackie", 157 | "last": "medina" 158 | }, 159 | "email": "jackie.medina91@example.com", 160 | "username": "bigladybug498" 161 | }, 162 | { 163 | "gender": "female", 164 | "name": { 165 | "title": "mrs", 166 | "first": "anita", 167 | "last": "turner" 168 | }, 169 | "email": "anita.turner36@example.com", 170 | "username": "silverdog296" 171 | }, 172 | { 173 | "gender": "male", 174 | "name": { 175 | "title": "mr", 176 | "first": "oscar", 177 | "last": "wells" 178 | }, 179 | "email": "oscar.wells37@example.com", 180 | "username": "whitedog307" 181 | }, 182 | { 183 | "gender": "male", 184 | "name": { 185 | "title": "mr", 186 | "first": "george", 187 | "last": "young" 188 | }, 189 | "email": "george.young96@example.com", 190 | "username": "whiteduck952" 191 | }, 192 | { 193 | "gender": "male", 194 | "name": { 195 | "title": "mr", 196 | "first": "wyatt", 197 | "last": "nelson" 198 | }, 199 | "email": "wyatt.nelson81@example.com", 200 | "username": "lazymeercat254" 201 | }, 202 | { 203 | "gender": "male", 204 | "name": { 205 | "title": "mr", 206 | "first": "ian", 207 | "last": "west" 208 | }, 209 | "email": "ian.west17@example.com", 210 | "username": "tinyduck707" 211 | }, 212 | { 213 | "gender": "male", 214 | "name": { 215 | "title": "mr", 216 | "first": "felix", 217 | "last": "miles" 218 | }, 219 | "email": "felix.miles29@example.com", 220 | "username": "blackdog881" 221 | }, 222 | { 223 | "gender": "male", 224 | "name": { 225 | "title": "mr", 226 | "first": "lloyd", 227 | "last": "herrera" 228 | }, 229 | "email": "lloyd.herrera71@example.com", 230 | "username": "blueelephant847" 231 | }, 232 | { 233 | "gender": "female", 234 | "name": { 235 | "title": "miss", 236 | "first": "toni", 237 | "last": "obrien" 238 | }, 239 | "email": "toni.obrien19@example.com", 240 | "username": "bluebear73" 241 | }, 242 | { 243 | "gender": "female", 244 | "name": { 245 | "title": "miss", 246 | "first": "kelly", 247 | "last": "shaw" 248 | }, 249 | "email": "kelly.shaw12@example.com", 250 | "username": "blackgorilla589" 251 | }, 252 | { 253 | "gender": "male", 254 | "name": { 255 | "title": "mr", 256 | "first": "darryl", 257 | "last": "hopkins" 258 | }, 259 | "email": "darryl.hopkins33@example.com", 260 | "username": "bigbear866" 261 | }, 262 | { 263 | "gender": "male", 264 | "name": { 265 | "title": "mr", 266 | "first": "arthur", 267 | "last": "ferguson" 268 | }, 269 | "email": "arthur.ferguson86@example.com", 270 | "username": "crazygorilla163" 271 | }, 272 | { 273 | "gender": "female", 274 | "name": { 275 | "title": "miss", 276 | "first": "rachel", 277 | "last": "garrett" 278 | }, 279 | "email": "rachel.garrett39@example.com", 280 | "username": "silverfish61" 281 | }, 282 | { 283 | "gender": "male", 284 | "name": { 285 | "title": "mr", 286 | "first": "freddie", 287 | "last": "matthews" 288 | }, 289 | "email": "freddie.matthews37@example.com", 290 | "username": "yellowgorilla642" 291 | }, 292 | { 293 | "gender": "male", 294 | "name": { 295 | "title": "mr", 296 | "first": "calvin", 297 | "last": "freeman" 298 | }, 299 | "email": "calvin.freeman62@example.com", 300 | "username": "heavygoose106" 301 | } 302 | ] --------------------------------------------------------------------------------