Skip to content

Commit

Permalink
update(@nestjs) add techniques chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 2, 2018
1 parent 295ff66 commit 59b4b27
Show file tree
Hide file tree
Showing 97 changed files with 3,036 additions and 462 deletions.
2 changes: 1 addition & 1 deletion .angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "scalio-base2-front"
"name": "docs.nestjs.com"
},
"apps": [
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable web applications. :cat: </p>
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications. :cat: </p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --sourcemap=false --port=4100",
"start": "ng serve --sourcemap=false",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
Expand Down Expand Up @@ -42,7 +42,7 @@
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.6.1",
"@angular/cli": "^1.6.0-rc.2",
"@angular/compiler-cli": "^5.1.1",
"@angular/language-service": "^5.1.1",
"@types/jasmine": "~2.8.2",
Expand Down
77 changes: 76 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ import { CqrsComponent } from './homepage/pages/recipes/cqrs/cqrs.component';
import { MockgooseComponent } from './homepage/pages/recipes/mockgoose/mockgoose.component';
import { CustomDecoratorsComponent } from './homepage/pages/custom-decorators/custom-decorators.component';
import { SwaggerComponent } from './homepage/pages/recipes/swagger/swagger.component';
import { ExecutionContextComponent } from './homepage/pages/execution-context/execution-context.component';
import { QuickStartComponent } from './homepage/pages/graphql/quick-start/quick-start.component';
import { ResolversMapComponent } from './homepage/pages/graphql/resolvers-map/resolvers-map.component';
import { MutationsComponent } from './homepage/pages/graphql/mutations/mutations.component';
import { SubscriptionsComponent } from './homepage/pages/graphql/subscriptions/subscriptions.component';
import { SchemaStitchingComponent } from './homepage/pages/graphql/schema-stitching/schema-stitching.component';
import { GuardsInterceptorsComponent } from './homepage/pages/graphql/guards-interceptors/guards-interceptors.component';
import { IdeComponent } from './homepage/pages/graphql/ide/ide.component';
import { MvcComponent } from './homepage/pages/techniques/mvc/mvc.component';
import { SqlComponent } from './homepage/pages/techniques/sql/sql.component';
import { MongoComponent } from './homepage/pages/techniques/mongo/mongo.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -140,6 +151,46 @@ const routes: Routes = [
path: 'fundamentals/e2e-testing',
component: E2eTestingComponent,
data: { title: 'E2E Testing' },
},
{
path: 'execution-context',
component: ExecutionContextComponent,
data: { title: 'Execution Context' },
},
{
path: 'graphql/quick-start',
component: QuickStartComponent,
data: { title: 'GraphQL - Quick Start' },
},
{
path: 'graphql/resolvers-map',
component: ResolversMapComponent,
data: { title: 'GraphQL - Resolvers Map' },
},
{
path: 'graphql/mutations',
component: MutationsComponent,
data: { title: 'GraphQL - Mutations' },
},
{
path: 'graphql/subscriptions',
component: SubscriptionsComponent,
data: { title: 'GraphQL - Subscriptions' },
},
{
path: 'graphql/guards-interceptors',
component: GuardsInterceptorsComponent,
data: { title: 'GraphQL - Guards & Interceptors' },
},
{
path: 'graphql/ide',
component: IdeComponent,
data: { title: 'GraphQL - IDE' },
},
{
path: 'graphql/schema-stitching',
component: SchemaStitchingComponent,
data: { title: 'GraphQL - Schema Stitching' },
},
{
path: 'websockets/gateways',
Expand Down Expand Up @@ -223,8 +274,12 @@ const routes: Routes = [
},
{
path: 'recipes/passport',
redirectTo: 'techniques/authentication',
},
{
path: 'techniques/authentication',
component: PassportComponent,
data: { title: 'Passport integration' },
data: { title: 'Authentication' },
},
{
path: 'recipes/sql-sequelize',
Expand All @@ -240,6 +295,26 @@ const routes: Routes = [
path: 'recipes/swagger',
component: SwaggerComponent,
data: { title: 'OpenAPI (Swagger)' },
},
{
path: 'techniques/mvc',
component: MvcComponent,
data: { title: 'MVC' },
},
{
path: 'techniques/mvc',
component: MvcComponent,
data: { title: 'MVC' },
},
{
path: 'techniques/sql',
component: SqlComponent,
data: { title: 'SQL' },
},
{
path: 'techniques/mongodb',
component: MongoComponent,
data: { title: 'MongoDB' },
},
{
path: 'faq/express-instance',
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';

import { TITLE_SUFFIX, HOMEPAGE_TITLE } from './constants';
import { SwUpdate } from '@angular/service-worker';

@Component({
selector: 'app-root',
Expand All @@ -15,7 +16,7 @@ export class AppComponent implements OnInit {
private readonly router: Router,
private readonly activatedRoute: ActivatedRoute) {}

ngOnInit() {
async ngOnInit() {
this.router.events
.filter((ev) => ev instanceof NavigationEnd)
.subscribe((ev) => {
Expand Down
27 changes: 25 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,29 @@ import { MockgooseComponent } from './homepage/pages/recipes/mockgoose/mockgoose
import { CustomDecoratorsComponent } from './homepage/pages/custom-decorators/custom-decorators.component';
import {ServiceWorkerModule} from '@angular/service-worker';
import {environment} from '../environments/environment';
import { ExecutionContextComponent } from './homepage/pages/execution-context/execution-context.component';
import { QuickStartComponent } from './homepage/pages/graphql/quick-start/quick-start.component';
import { ResolversMapComponent } from './homepage/pages/graphql/resolvers-map/resolvers-map.component';
import { MutationsComponent } from './homepage/pages/graphql/mutations/mutations.component';
import { SubscriptionsComponent } from './homepage/pages/graphql/subscriptions/subscriptions.component';
import { SchemaStitchingComponent } from './homepage/pages/graphql/schema-stitching/schema-stitching.component';
import { GuardsInterceptorsComponent } from './homepage/pages/graphql/guards-interceptors/guards-interceptors.component';
import { IdeComponent } from './homepage/pages/graphql/ide/ide.component';
import { SqlComponent } from './homepage/pages/techniques/sql/sql.component';
import { MvcComponent } from './homepage/pages/techniques/mvc/mvc.component';
import { MongoComponent } from './homepage/pages/techniques/mongo/mongo.component';

const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
suppressScrollX: true
suppressScrollX: true,
wheelPropagation: true,
};

@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
PerfectScrollbarModule,
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production})
//ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production})
],
declarations: [
AppComponent,
Expand Down Expand Up @@ -124,6 +136,17 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
TabsComponent,
ExtensionPipe,
CustomDecoratorsComponent,
ExecutionContextComponent,
QuickStartComponent,
ResolversMapComponent,
MutationsComponent,
SubscriptionsComponent,
SchemaStitchingComponent,
GuardsInterceptorsComponent,
IdeComponent,
SqlComponent,
MvcComponent,
MongoComponent,
],
bootstrap: [AppComponent],
providers: [
Expand Down
69 changes: 40 additions & 29 deletions src/app/common/directives/match-height.directive.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
import {
Directive, ElementRef, AfterViewChecked,
Input, HostListener, Renderer2, NgZone
Directive,
ElementRef,
AfterViewChecked,
Input,
HostListener,
Renderer2,
NgZone,
} from '@angular/core';

@Directive({
selector: '[matchHeight]'
selector: '[matchHeight]',
})
export class MatchHeightDirective implements AfterViewChecked {
constructor(
private readonly zone: NgZone,
private readonly renderer: Renderer2,
private readonly el: ElementRef) {}
constructor(
private readonly zone: NgZone,
private readonly renderer: Renderer2,
private readonly el: ElementRef,
) {}

ngAfterViewChecked() {
setTimeout(() => this.zone.run(() => this.matchHeight(this.el.nativeElement)), 800);
}

@HostListener('window:resize')
onResize() {
setTimeout(() => this.matchHeight(this.el.nativeElement), 500);
}
ngAfterViewChecked() {
setTimeout(
() => this.zone.run(() => this.matchHeight(this.el.nativeElement)),
800,
);
}

matchHeight(parent: HTMLElement) {
if (!parent) {
return;
}
const children = Array.from(parent.children);
children.forEach((x: HTMLElement) => {
this.renderer.setStyle(x, 'height', 'initial');
});
const itemHeights = children.map(x => x.getBoundingClientRect().height);
const maxHeight = itemHeights.reduce((prev, curr) => {
return curr > prev ? curr : prev;
}, 0);
@HostListener('window:resize')
onResize() {
setTimeout(() => this.matchHeight(this.el.nativeElement), 500);
}

children.forEach((x: HTMLElement) => this.renderer.setStyle(x, 'height', `${maxHeight}px`));
matchHeight(parent: HTMLElement) {
if (!parent) {
return;
}
}
const children = Array.from(parent.children);
children.forEach((x: HTMLElement) => {
this.renderer.setStyle(x, 'height', 'initial');
});
const itemHeights = children.map(x => x.getBoundingClientRect().height);
const maxHeight = itemHeights.reduce((prev, curr) => {
return curr > prev ? curr : prev;
}, 0);

children.forEach((x: HTMLElement) =>
this.renderer.setStyle(x, 'height', `${maxHeight}px`),
);
}
}
2 changes: 1 addition & 1 deletion src/app/homepage/homepage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
</app-header>
<div class="container-fluid" matchHeight>
<app-menu [class.opened]="isSidebarOpened" perfect-scrollbar></app-menu>
<app-menu [class.opened]="isSidebarOpened" perfectScrollbar></app-menu>
<div class="container" [class.wide]="!isSidebarOpened">
<div class="page-wrapper">
<router-outlet></router-outlet>
Expand Down
4 changes: 4 additions & 0 deletions src/app/homepage/homepage.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
background: #f3f3f3;
position: relative;

@include media(medium) {
margin: 40px -30px 0;
}

h4, img {
display: inline-block;
vertical-align: middle;
Expand Down
43 changes: 35 additions & 8 deletions src/app/homepage/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ export class MenuComponent implements OnInit {
{ title: 'E2E Testing', path: '/fundamentals/e2e-testing' },
]
},
{
title: 'Techniques',
isOpened: false,
children: [
{ title: 'MVC', path: '/techniques/mvc' },
{ title: 'SQL', path: '/techniques/sql' },
{ title: 'MongoDB', path: '/techniques/mongodb' },
{ title: 'Authentication', path: '/techniques/authentication' },
]
},
{
title: 'GraphQL',
isOpened: false,
children: [
{ title: 'Quick Start', path: '/graphql/quick-start' },
{ title: 'Resolvers Map', path: '/graphql/resolvers-map' },
{ title: 'Mutations', path: '/graphql/mutations' },
{ title: 'Subscriptions', path: '/graphql/subscriptions' },
{ title: 'Guards & Interceptors', path: '/graphql/guards-interceptors' },
{ title: 'Schema stitching', path: '/graphql/schema-stitching' },
{ title: 'IDE', path: '/graphql/ide' },
]
},
{
title: 'WebSockets',
isOpened: false,
Expand All @@ -68,27 +91,31 @@ export class MenuComponent implements OnInit {
]
},
{
title: 'Advanced',
title: 'Execution Context',
isOpened: false,
children: [
{ title: 'Hierarchical Injector', path: '/advanced/hierarchical-injector' },
{ title: 'Mixin Class', path: '/advanced/mixins' },
]
path: '/execution-context',
},
{
title: 'Recipes',
isOpened: false,
children: [
{ title: 'SQL (TypeORM)', path: '/recipes/sql-typeorm' },
{ title: 'MongoDB (Mongoose)', path: '/recipes/mongodb' },
{ title: 'MongoDB E2E (Mockgoose)', path: '/recipes/mockgoose' },
{ title: 'SQL (Sequelize)', path: '/recipes/sql-sequelize' },
{ title: 'Passport integration', path: '/recipes/passport' },
{ title: 'Authentication (Passport)', path: '/recipes/passport' },
{ title: 'CQRS', path: '/recipes/cqrs' },
{ title: 'OpenAPI (Swagger)', path: '/recipes/swagger' },
{ title: 'GraphQL', path: '/recipes/graphql', isPending: true }
{ title: 'MongoDB E2E (Mockgoose)', path: '/recipes/mockgoose' },
],
},
{
title: 'Advanced',
isOpened: false,
children: [
{ title: 'Hierarchical Injector', path: '/advanced/hierarchical-injector' },
{ title: 'Mixin Class', path: '/advanced/mixins' },
]
},
{
title: 'FAQ',
isOpened: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class HierarchicalInjectorComponent extends BasePageComponent {
get coreModule() {
return `
@Module({
modules: [CommonModule],
imports: [CommonModule],
components: [CoreService, ContextService],
})
export class CoreModule {}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5>This chapter applies only to TypeScript</h5>
</blockquote>
<p>
This function takes the <code>isCached()</code> predicate as an argument and assigns it to the mixin class.
The last step is to setup the interceptor:
The last step is to set up the interceptor:
</p>
<pre><code class="language-typescript">{{ setup }}</code></pre>
<p>
Expand Down
Loading

0 comments on commit 59b4b27

Please sign in to comment.