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 fs = require("fs") | |
| const falso = require("@ngneat/falso") | |
| const express = require("express") | |
| const cors = require("cors") | |
| const app = express() | |
| app.use(cors()) | |
| app.use(express.json()) |
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 interface Movie { | |
| _id: String, | |
| title: String, | |
| releaseDate: Date, | |
| poster: SanityImageSource, // = string | SanityReference | SanityAsset | SanityImageObject etc. | |
| } | |
| @Component({ | |
| selector: 'app-movies', | |
| template: ` |
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 { Pipe, PipeTransform } from '@angular/core' | |
| import { SanityService } from '@core/services/sanity.service' | |
| import { SanityImageSource } from '@sanity/image-url/lib/types/types' | |
| @Pipe({ name: 'sanityImage' }) | |
| export class SanityImagePipe implements PipeTransform { | |
| constructor(private sanityService: SanityService) {} | |
| transform(value: SanityImageSource, width?: number): string { | |
| if (width) { |
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 { HttpClient } from '@angular/common/http' | |
| import { Inject, Injectable } from '@angular/core' | |
| import { WINDOW } from '@ng-web-apis/common' | |
| import sanityClient, { ClientConfig, SanityClient } from '@sanity/client' | |
| import imageUrlBuilder from '@sanity/image-url' | |
| import { ImageUrlBuilder } from '@sanity/image-url/lib/types/builder' | |
| import { SanityImageSource } from '@sanity/image-url/lib/types/types' | |
| import { map, Observable } from 'rxjs' | |
| import { environment } from '@environment' |
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 { FormBuilder, FormControl, FormGroup } from '@angular/forms' | |
| import { Observable, throwError } from 'rxjs' | |
| export abstract class AbstractFormService<T, InputT extends { id?: string }> { | |
| form: FormGroup | |
| constructor(protected fb: FormBuilder) { | |
| this.form = this.buildForm() | |
| } |
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 { Directive, ElementRef, HostListener, Input } from "@angular/core"; | |
| @Directive({ | |
| selector: "[appTextareaAutosize]" | |
| }) | |
| export class TextareaAutosizeDirective { | |
| @Input() minRows = 2; | |
| @Input() maxRows = 4; | |
| private offsetHeight = 0; |
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 { Injectable } from '@angular/core' | |
| import { BaseService } from '@core/services/base.service' | |
| import { SupabaseService } from '@core/services/supabase.service' | |
| import { Product } from '@features/products/types/product' | |
| const TABLE_PRODUCT = 'products' | |
| @Injectable({ | |
| providedIn: 'root', | |
| }) |
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 BaseService<T> { | |
| protected resource: string // table name | |
| constructor(protected supabase: SupabaseService, resource: string) { | |
| this.resource = resource | |
| } | |
| findById(id: number, select = '*'): Observable<T> { | |
| const query = this.supabase.table(this.resource).select(select).match({ id }).single() | |
| return from(query).pipe(map((res) => res.body as T)) |
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 type FilterOperator = | |
| | 'eq' | 'neq' | |
| | 'gt' | 'gte' | |
| | 'lt' | 'lte' | |
| | 'like' | 'ilike' | |
| | 'is' | 'in' | |
| | 'cs' | 'cd' | |
| | 'sl' | 'sr' | |
| | 'nxl' | 'nxr' | |
| | 'adj' | 'ov' |
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 { Injectable } from '@angular/core' | |
| import { environment } from '@environment/environment' | |
| import { AuthChangeEvent, createClient, Session, SupabaseClient } from '@supabase/supabase-js' | |
| @Injectable({ | |
| providedIn: 'root', | |
| }) | |
| export class SupabaseService { | |
| private supabase: SupabaseClient |