This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const triggerPushMsg = function(subscription, dataToSend) { | |
| let _subscription = subscription.subscriber; | |
| let pushSubscription = JSON.parse(_subscription); | |
| let buildPushSubscription = { | |
| endpoint: pushSubscription.endpoint, | |
| keys: pushSubscription.keys | |
| }; | |
| return webpush.sendNotification(buildPushSubscription, dataToSend) | |
| .catch((err) => { | |
| if (err.statusCode === 410) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.notification = (req, res, next) => { | |
| const notificationPayload = { | |
| notification: { | |
| title: 'Blogial new post', | |
| body: req.body.title, | |
| icon: 'assets/icons/icon-512x512.png' | |
| } | |
| }; | |
| Subscription.find() | |
| .then(subscriptions => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Questo e app-routing | |
| const routes: Routes = [ | |
| { path: '', loadChildren: './features/blog/blog.module#BlogModule', data: { preload: false , animation: {page: 'home'}} }, | |
| { path: 'admin', loadChildren: './features/admin/admin.module#AdminModule', data: { preload: false, animation: {page: 'dashboard'} } }, | |
| { path: 'auth', loadChildren: './features/authentication/authentication.module#AuthenticationModule', data: { preload: false, animation: {page: 'login'} } }, | |
| { path: '**', redirectTo: '', pathMatch: 'full' } | |
| ]; | |
| @NgModule({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const multer = require('multer'); | |
| const MIME_TYPE_MAP = { | |
| 'image/png': 'png', | |
| 'image/jpeg': 'jpg', | |
| 'image/jpg': 'jpg' | |
| }; | |
| const storage = multer.diskStorage({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, BehaviorSubject } from 'rxjs'; | |
| import { pluck, distinctUntilChanged } from 'rxjs/operators'; | |
| import { User } from './auth/shared/services/auth/auth.service'; | |
| import { Meal } from './health/shared/services/meals/meals.service'; | |
| export interface State { | |
| user: User, | |
| meals: Meal[], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function clearState(reducer: ActionReducer<State>): ActionReducer<State> { | |
| return function(state: State, action: Action): State { | |
| console.log('action',action.type); | |
| console.log('state',state); | |
| if (action.type === '[Auth] Logout') { | |
| console.log('BINGO'); | |
| state = undefined; | |
| } | |
| return reducer(state, action); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class PwaService { | |
| promptEvent: ServiceWorkerEvent; | |
| constructor(private swUpdate: SwUpdate, platform: PlatformService) { | |
| if(platform.isBrowser() && environment.production){ | |
| console.log('hello browser'); | |
| swUpdate.available.subscribe(event => { | |
| console.log('current version is', event.current); | |
| console.log('available version is', event.available); | |
| if (window.confirm('Want to update?')) { | |
| swUpdate.activateUpdate().then(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const customStorage: Storage = { | |
| length: 0, | |
| clear: function(): void { | |
| if (window && window.localStorage) { | |
| window.localStorage.clear(); | |
| this.length = window.localStorage.length; | |
| } | |
| }, | |
| getItem: function(key: string): string | null { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // VECCHIO | |
| .pipe( | |
| tap((event: HttpEvent<any>) => { | |
| if (event instanceof HttpResponse) { | |
| } | |
| }, (err: any) => { | |
| if (err instanceof HttpErrorResponse) { | |
| // do something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
| return this.store.select(fromStore.getToken) | |
| .pipe( | |
| take(1), | |
| switchMap((token: AuthenticationToken) => { | |
| console.log('token',token); | |
| if (token) { | |
| const clonedRequest = request.clone({ | |
| setHeaders: { | |
| Authorization: `Bearer ${token.token}` |