repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
StellarCrow/wfh-client
src/app/core/services/action.service.ts
import {Injectable, OnDestroy} from '@angular/core'; import {GameViewService} from '../../modules/game/services/game-view.service'; import {DONE} from '../../modules/game/constants/game-views'; import {SocketService} from '../../modules/game/services/socket.service'; import {DataStoreService} from './data-store.service...
StellarCrow/wfh-client
src/app/modules/game/components/timer/timer.component.ts
import {Component, OnDestroy, OnInit} from '@angular/core'; import {interval, Subject, Subscription} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; import {SocketService} from '../../services/socket.service'; import {DataStoreService} from '../../../../core/services/data-store.service'; import {GameViewService}...
StellarCrow/wfh-client
src/app/core/services/notification.service.ts
import {Injectable} from '@angular/core'; import {Subject} from 'rxjs'; @Injectable({ providedIn: 'root' }) export class NotificationService { public notification$: Subject<string> = new Subject(); }
StellarCrow/wfh-client
src/app/core/services/data.service.ts
import {Injectable} from '@angular/core'; import {HttpClient, HttpHeaders} from '@angular/common/http'; import {Observable} from 'rxjs'; import {apiUrl} from '../../../environments/environment'; import {IAvatarUploadResponse} from '../../shared/interfaces/iavatar-upload-response'; @Injectable({ providedIn: 'root' })...
StellarCrow/wfh-client
src/app/shared/interfaces/iavatar-upload-response.ts
import {IServerResponse} from './iserver-response'; export interface IAvatarUploadResponse extends IServerResponse { payload: { avatar: string }; }
StellarCrow/wfh-client
src/app/modules/game/services/peer.service.ts
import {Injectable} from '@angular/core'; import {IWSPeer} from '../interfaces/iwspeer'; @Injectable({ providedIn: 'root' }) export class PeerService { public peers: IWSPeer[] = []; public removePeer(peerID: string): void { this.peers = this.peers.filter(p => p.id !== peerID); } public destroyPeer(peer...
StellarCrow/wfh-client
src/app/modules/game/pages/game/game-views/matching-view/matching-view.component.ts
import {Component, OnDestroy, OnInit} from '@angular/core'; import {DataStoreService} from '../../../../../../core/services/data-store.service'; import {Stages} from '../../../../constants/stages.enum'; import {IPicture} from 'src/app/modules/game/interfaces/ipicture'; import {IPhrase} from 'src/app/modules/game/interf...
StellarCrow/wfh-client
src/app/shared/interfaces/i-login-response.ts
import {IServerResponse} from './iserver-response'; import {IUser} from './user'; export interface ILoginResponse extends IServerResponse { payload: ILoginPayload; } interface ILoginPayload { userData: IUser; token: string; }
StellarCrow/wfh-client
src/app/modules/home/components/signin/signin.component.ts
<filename>src/app/modules/home/components/signin/signin.component.ts<gh_stars>0 import {Component, OnInit, ViewChild} from '@angular/core'; import {Router} from '@angular/router'; import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {AuthService} from '../../../../core/services/auth.service'; impor...
StellarCrow/wfh-client
src/app/shared/components/tee-image/tee-image.component.spec.ts
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {TeeImageComponent} from './tee-image.component'; describe('TeeImageComponent', () => { let component: TeeImageComponent; let fixture: ComponentFixture<TeeImageComponent>; beforeEach(async(() => { TestBed.configureTestingModule(...
StellarCrow/wfh-client
src/app/core/guards/game-leave/game-leave.guard.spec.ts
<reponame>StellarCrow/wfh-client<filename>src/app/core/guards/game-leave/game-leave.guard.spec.ts import {TestBed} from '@angular/core/testing'; import {GameLeaveGuard} from './game-leave.guard'; describe('GameLeaveGuard', () => { let guard: GameLeaveGuard; beforeEach(() => { TestBed.configureTestingModule({...
StellarCrow/wfh-client
src/app/modules/home/home.module.ts
<gh_stars>0 import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {HomeRoutingModule} from './home-routing.module'; import {SharedModule} from '../../shared/shared.module'; import {LoginFormComponent} from './compone...
StellarCrow/wfh-client
src/app/modules/game/interfaces/itee.ts
import {IPhrase} from './iphrase'; import {IPicture} from './ipicture'; export interface ITee { phrase: IPhrase; picture: IPicture; }
StellarCrow/wfh-client
src/app/modules/game/interfaces/ipeer-player.ts
<filename>src/app/modules/game/interfaces/ipeer-player.ts import Peer from 'simple-peer'; export interface IPeerPlayer { username: string; avatar: string; socketId: string; peerData: Peer; }
StellarCrow/wfh-client
src/app/modules/main/main.module.ts
<filename>src/app/modules/main/main.module.ts import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MainRoutingModule} from './main-routing.module'; import {MainComponent} from './main.component'; import {WelcomeCo...
StellarCrow/wfh-client
src/app/shared/interfaces/auth.ts
<reponame>StellarCrow/wfh-client export interface IAuth { success: boolean; payload: string; status: string; }
StellarCrow/wfh-client
src/app/modules/game/interfaces/iwspeer.ts
<reponame>StellarCrow/wfh-client import Peer from 'simple-peer'; export interface IWSPeer { id: string; data: Peer; }
StellarCrow/wfh-client
src/app/modules/main/components/form-join-room/form-join-room.component.spec.ts
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormJoinRoomComponent} from './form-join-room.component'; describe('FormJoinRoomComponent', () => { let component: FormJoinRoomComponent; let fixture: ComponentFixture<FormJoinRoomComponent>; beforeEach(async(() => { TestBed.co...
StellarCrow/wfh-client
src/app/modules/game/components/video/video.component.ts
<filename>src/app/modules/game/components/video/video.component.ts import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; import Peer from 'simple-peer'; @Component({ selector: 'app-video', templateUrl: './video.component.html', styleUrls: ['./video.component.scss'], }) export class Video...
eXsiLe95/timetracker_server
src/controller/ProjectController.ts
<filename>src/controller/ProjectController.ts import {Request, Response} from 'express'; import {ProjectService} from '../service/ProjectService'; import {Project} from '../entity/Project'; import {Connection} from 'typeorm'; import {User} from '../entity/User'; import {UserService} from '../service/UserService'; impor...
eXsiLe95/timetracker_server
src/entity/User.ts
<reponame>eXsiLe95/timetracker_server import {Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable} from "typeorm"; import {WorkPlace} from "./WorkPlace"; import {Project} from "./Project"; @Entity() export class User { @PrimaryGeneratedColumn() id: number; @Column() firstName: string; ...
eXsiLe95/timetracker_server
src/server.ts
import express = require('express'); import {WorkPlaceController} from './controller/WorkPlaceController'; import {ProjectController} from './controller/ProjectController'; import {Connection, createConnection} from 'typeorm'; import {UserController} from './controller/UserController'; import * as session from 'express...
eXsiLe95/timetracker_server
src/service/WorkPlaceService.ts
import {Connection, Repository} from "typeorm"; import {WorkPlace} from "../entity/WorkPlace"; export class WorkPlaceService { static connection: Connection = null; static async createConnection(connection: Connection) { WorkPlaceService.connection = connection; } static async getAll(): Prom...
eXsiLe95/timetracker_server
src/controller/UserController.ts
import {Request, Response} from "express"; import {UserService} from "../service/UserService"; import {User} from "../entity/User"; import {Connection} from "typeorm"; export class UserController { static async getAll(request: Request, response: Response) { const users: User[] = await UserService.getAll(...
eXsiLe95/timetracker_server
src/service/UserService.ts
import {Connection, Repository} from "typeorm"; import {User} from "../entity/User"; export class UserService { static connection: Connection = null; static async createConnection(connection: Connection) { UserService.connection = connection; } static async getAll(): Promise<User[]> { ...
eXsiLe95/timetracker_server
src/service/ProjectService.ts
<gh_stars>0 import {Connection, Repository} from "typeorm"; import {Project} from "../entity/Project"; export class ProjectService { static connection: Connection = null; static async createConnection(connection: Connection) { ProjectService.connection = connection; } static async getAll(): ...
eXsiLe95/timetracker_server
src/entity/Activity.ts
import {Entity, PrimaryGeneratedColumn, Column, ManyToOne} from "typeorm"; import {Project} from "./Project"; @Entity() export class Activity { @PrimaryGeneratedColumn() id: number; @Column() start: Date; @Column({nullable: true}) end: Date; @ManyToOne(type => Project, project => projec...
eXsiLe95/timetracker_server
src/controller/AuthenticationController.ts
<filename>src/controller/AuthenticationController.ts import {NextFunction, Request, Response} from 'express'; import {User} from '../entity/User'; import {UserService} from '../service/UserService'; export class AuthenticationController { static async isLoggedIn(request: Request, response: Response, next: NextFun...
eXsiLe95/timetracker_server
src/controller/WorkPlaceController.ts
import {Request, Response} from "express"; import {WorkPlaceService} from "../service/WorkPlaceService"; import {WorkPlace} from "../entity/WorkPlace"; import {Connection} from "typeorm"; import {User} from '../entity/User'; import {UserService} from '../service/UserService'; import {Project} from '../entity/Project'; ...
eXsiLe95/timetracker_server
src/entity/WorkPlace.ts
import {Entity, PrimaryGeneratedColumn, Column, ManyToMany, OneToMany} from "typeorm"; import {User} from "./User"; import {Project} from "./Project"; @Entity() export class WorkPlace { @PrimaryGeneratedColumn() id: number; @Column() name: string; @OneToMany(type => Project, project => project.w...
eXsiLe95/timetracker_server
src/entity/Project.ts
<reponame>eXsiLe95/timetracker_server import {Entity, PrimaryGeneratedColumn, Column, ManyToMany, ManyToOne, OneToMany} from "typeorm"; import {User} from "./User"; import {WorkPlace} from "./WorkPlace"; import {Activity} from "./Activity"; @Entity() export class Project { @PrimaryGeneratedColumn() id: number...
viniciusvts/imcCalculo
src/directives/calculos/calculos.ts
import { Directive } from '@angular/core'; /** * Generated class for the CalculoCalculosDirective directive. * * See https://angular.io/docs/ts/latest/api/core/index/DirectiveMetadata-class.html * for more info on Angular Directives. */ @Directive({ selector: '[calculos]' // Attribute selector }) export class C...
viniciusvts/imcCalculo
src/directives/directives.module.ts
<reponame>viniciusvts/imcCalculo<filename>src/directives/directives.module.ts import { NgModule } from '@angular/core'; import { CalculosDirective } from './calculos/calculos'; @NgModule({ declarations: [CalculosDirective], imports: [], exports: [CalculosDirective] }) export class DirectivesModule {}
viniciusvts/imcCalculo
src/pages/home/home.ts
import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { CalculosDirective } from '../../directives/calculos/calculos'; //import { DirectivesModule } from '../../directives/directives.module'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class Ho...
demidyuk/recycling-react-carousel
src/hooks/index.ts
<filename>src/hooks/index.ts export * from './useCursor';
demidyuk/recycling-react-carousel
stories/RCarousel/btns/ExampleNextBtn.tsx
<filename>stories/RCarousel/btns/ExampleNextBtn.tsx<gh_stars>1-10 import React from 'react'; import IconBtn from './IconBtn'; import ArrowRight from './arrows/right.svg'; const ExampleNextBtn = ({ ...props }) => ( <IconBtn {...props}> <ArrowRight width={32} height={32} /> </IconBtn> ); export default ExampleN...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/clampCursor.ts
<reponame>demidyuk/recycling-react-carousel<gh_stars>1-10 import clamp from 'lodash/clamp'; export const clampCursor = (cursor: number, from = 0, to = 0) => { return clamp(cursor, from, to < 0 ? 0 : to); };
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/patchCreateEvent.ts
<reponame>demidyuk/recycling-react-carousel<filename>src/RCarousel/__tests__/tools/patchCreateEvent.ts import { createEvent } from '@testing-library/react'; Object.keys(createEvent) .filter((key) => key.includes('pointer')) .forEach((key) => { const ce = createEvent as any; const fn = ce[key.replace('point...
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/testCarousel.tsx
<filename>src/RCarousel/__tests__/tools/testCarousel.tsx import React from 'react'; import RCarousel, { RCarouselProps } from '../..'; export function getTestSlides(count: number) { const items = Array(count) .fill(undefined) .map((_, i) => `slide${i + 1}`); return items.map((item) => ( <div key={item}...
demidyuk/recycling-react-carousel
src/RCarousel/index.ts
<reponame>demidyuk/recycling-react-carousel export { RCarousel as default } from './RCarousel'; export * from './RCarousel';
demidyuk/recycling-react-carousel
src/RCarousel/hooks/useRCalc.ts
import { useRef } from 'react'; import { usePrevious } from './usePrevious'; import { clampCursor, calcActors, CalcResult } from '../helpers'; interface RCalcProps { cursor: number; visibleItemsCount: number; childrenCount: number; min: number; max: number; } const initResult = { actors: [], actorsState...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/animTo.ts
<reponame>demidyuk/recycling-react-carousel<filename>src/RCarousel/helpers/animTo.ts export function animTo({ curRoles, nextRoles, totalItemsCount, delta, relocated, }: any) { return (index: number) => { const visibleActors = totalItemsCount / 3; const d = nextRoles.indexOf(index) - visibleActors; ...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/__mocks__/animTo.ts
<reponame>demidyuk/recycling-react-carousel<filename>src/RCarousel/helpers/__mocks__/animTo.ts const { animTo: originalAnimTo } = jest.requireActual('../animTo'); export function animTo(options: any) { const originalTo = originalAnimTo(options); return (index: number) => { return { ...originalTo(index), immedi...
demidyuk/recycling-react-carousel
src/RCarousel/RCarousel.tsx
import React, { useEffect, useRef, useCallback, Children, useState, useMemo, } from 'react'; import { animated, useSprings, SpringConfig, config } from 'react-spring'; import { useDrag } from 'react-use-gesture'; import styles from './RCarousel.module.css'; import invariant from 'tiny-invariant'; import inR...
demidyuk/recycling-react-carousel
src/RCarousel/hooks/index.ts
export * from './useOnResize'; export * from './usePrevious'; export * from './useWindowWidth'; export * from './useForceUpdate'; export * from './useShouldUpdate'; export * from './useRCalc';
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/render.ts
<filename>src/RCarousel/__tests__/tools/render.ts<gh_stars>1-10 import { render as tlRender } from '@testing-library/react'; import { finishAnim } from './springConfig'; export const render = ((...args: any[]) => { const renderResult = finishAnim(() => // @ts-ignore tlRender(...args) ); const originalRer...
demidyuk/recycling-react-carousel
stories/RCarousel/btns/index.ts
<filename>stories/RCarousel/btns/index.ts import ExampleBackBtn from './ExampleBackBtn'; import ExampleNextBtn from './ExampleNextBtn'; export { ExampleBackBtn, ExampleNextBtn };
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/index.ts
export * from './testCarousel'; export * from './render'; export * from './springConfig'; export * from './swipe';
demidyuk/recycling-react-carousel
src/hooks/useCursor.ts
<reponame>demidyuk/recycling-react-carousel import { useCallback, useMemo, useReducer } from 'react'; import { clampCursor, getLocalIndex } from '../RCarousel/helpers'; export interface CursorProps { init?: number; step?: number; } export interface GoToOptions { length?: number; } type CursorState = { global...
demidyuk/recycling-react-carousel
stories/RCarousel/btns/ExampleBackBtn.tsx
<filename>stories/RCarousel/btns/ExampleBackBtn.tsx import React from 'react'; import IconBtn from './IconBtn'; import ArrowLeft from './arrows/left.svg'; const ExampleBackBtn = ({ ...props }) => ( <IconBtn {...props}> <ArrowLeft width={32} height={32} /> </IconBtn> ); export default ExampleBackBtn;
demidyuk/recycling-react-carousel
src/RCarousel/helpers/unit.ts
<gh_stars>1-10 import { Unit, UnitValue } from './types'; const supportedUnits = [Unit.PX, Unit.PCT]; export const parsePx = (value: UnitValue, totalPx: number = 0) => { if (typeof value === 'number') return value; const valueStr = value + ''; const [unit] = supportedUnits.filter((unit) => valueStr.includes(uni...
demidyuk/recycling-react-carousel
test-config/setupTests.ts
<reponame>demidyuk/recycling-react-carousel import '@testing-library/jest-dom'; import './setupPointerEvent'; import snapshotDiff, { toMatchDiffSnapshot } from 'snapshot-diff'; expect.extend({ toMatchDiffSnapshot }); expect.addSnapshotSerializer(snapshotDiff.getSnapshotDiffSerializer());
demidyuk/recycling-react-carousel
src/RCarousel/helpers/classNames.ts
export function classNames(classNames: any[] = []) { classNames = Array.from(new Set(classNames).values()); return classNames .reduce<string[]>((acc, cn) => { if (cn && (cn = cn.toString().trim())) { acc.push(cn); } return acc; }, []) .join(' '); }
demidyuk/recycling-react-carousel
src/RCarousel/hooks/useWindowWidth.ts
import { useEffect } from 'react'; import debounce from 'lodash/debounce'; import { useForceUpdate } from './useForceUpdate'; export function useWindowWidth() { const forceUpdate = useForceUpdate(); useEffect(() => { const resizeListener = debounce(() => forceUpdate(), 60); window.addEventListener('resize...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/index.ts
export * from './animTo'; export * from './clampCursor'; export * from './classNames'; export * from './getLocalIndex'; export * from './getSnapshot'; export * from './unit'; export * from './calcActors'; export * from './getDisplayedSlidesCount'; export * from './types';
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/RCarousel.test.tsx
import React from 'react'; import { buildTestCarousel, getTestSlides, swipe, render } from './tools'; import { useOnResize as mockedUseOnResize } from '../hooks/useOnResize'; import './tools/patchCreateEvent'; jest.mock('../hooks/useOnResize'); // jest.mock('../helpers/animTo'); const useOnResize = mockedUseOnResize...
demidyuk/recycling-react-carousel
src/index.ts
export { useCursor } from './hooks/useCursor'; export * from './RCarousel'; export { default } from './RCarousel';
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/springConfig.ts
import createMockRaf from '@react-spring/mock-raf'; //@ts-ignore import { Globals } from 'react-spring'; const mockRaf = createMockRaf(); Globals.injectFrame(mockRaf.raf, mockRaf.cancel); Globals.injectNow(mockRaf.now); export function finishAnim<T>(fn: () => T): T { const result = fn(); mockRaf.flush(); retur...
demidyuk/recycling-react-carousel
src/RCarousel/hooks/useShouldUpdate.ts
import { usePrevious } from './usePrevious'; import isEqual from 'lodash/isEqual'; export function useShouldUpdate(...curDeps: any[]) { const prevDeps = usePrevious(curDeps); return !isEqual(curDeps, prevDeps); }
demidyuk/recycling-react-carousel
stories/RCarousel/btns/IconBtn.tsx
import React from 'react'; const IconBtn = ({ children, ...rest }: React.HTMLAttributes<HTMLButtonElement>) => { return ( <button className="btn" style={{ zIndex: 1 }} {...rest}> {children} </button> ); }; export default IconBtn;
demidyuk/recycling-react-carousel
src/RCarousel/helpers/types.ts
export interface DisplayRule { breakpoint?: number; slidesToSwipe?: number; value: number; } export enum ChangeReason { USER_SWIPE = 'user_swipe', SHIFT = 'shift', } export type Actor = { globalChildIndex: number; anim: { d: number; immediate: boolean; }; }; export type CalcResult = { actor...
demidyuk/recycling-react-carousel
src/RCarousel/SlideWrapper.tsx
import React, { useLayoutEffect, useRef } from 'react'; export interface SlideWrapperProps extends React.HTMLAttributes<HTMLElement> { observer?: { add: (ref: React.RefObject<HTMLElement>) => void; remove: (ref: React.RefObject<HTMLElement>) => void; }; } const SlideWrapper = ({ observer, children, ...pro...
demidyuk/recycling-react-carousel
src/RCarousel/hooks/useOnResize.ts
import { useEffect, useState, useRef, RefObject, useCallback } from 'react'; type Size = { width: number; height: number; }; export function useOnResize(staticRefs: RefObject<HTMLElement | null>[] = []) { const [sizes, setSizes] = useState<Size[]>([]); const refs = useRef(staticRefs); const observeRef = use...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/getDisplayedSlidesCount.ts
import { DisplayRule } from './types'; export const getDisplayedSlidesCount = ( displayAtOnce: number | undefined | DisplayRule[], windowWidth: number ): DisplayRule | undefined => { const targetRule = { value: 1 }; if (Array.isArray(displayAtOnce)) { const displayRule = displayAtOnce.reduce<DisplayRule>( ...
demidyuk/recycling-react-carousel
stories/RCarousel/RCarousel.stories.tsx
<reponame>demidyuk/recycling-react-carousel import React from 'react'; import { Meta, Story } from '@storybook/react'; import RCarousel, { useCursor, RCarouselProps } from 'recycling-react-carousel'; import ExampleCard from './ExampleCard'; import { ExampleBackBtn, ExampleNextBtn } from './btns'; export default { ti...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/calcActors.ts
import clamp from 'lodash/clamp'; import times from 'lodash/times'; import { animTo } from './animTo'; import { getSnapshot } from './getSnapshot'; import { CalcResult } from './types'; export interface CalcActorsInput { cursor: number; visibleItemsCount: number; shift: number; } export function calcActors( p...
demidyuk/recycling-react-carousel
src/RCarousel/hooks/useForceUpdate.ts
import { useReducer } from 'react'; export function useForceUpdate() { const [, forceUpdate] = useReducer((x) => x + 1, 0); return forceUpdate; }
demidyuk/recycling-react-carousel
src/RCarousel/__tests__/tools/swipe.ts
import { fireEvent } from '@testing-library/react'; let _curEventTimeStamp = 1; function inc() { return _curEventTimeStamp++; } export function swipe(element: Element, ...points: number[][]) { fireEvent.pointerDown(element, { _curEventTimeStamp: inc() }); points.forEach(([clientX = 0, clientY = 0]) => { fi...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/getSnapshot.ts
export function getSnapshot( cursor: number, delta: number, totalItemsCount: number ) { const snapshot = []; const deltaSign = Math.sign(delta); const visibleItemsCount = totalItemsCount / 3; const offset = deltaSign > 0 ? totalItemsCount - visibleItemsCount : -visibleItemsCount - 1; con...
demidyuk/recycling-react-carousel
stories/RCarousel/ExampleCard.tsx
import React from 'react'; const ExampleCard = ({ children, ...rest }: React.HTMLAttributes<HTMLDivElement>) => { return ( <div className="card shadow-sm h-100" {...rest}> <div className="d-flex align-items-center justify-content-center card-body p-2"> <h1 className="text-dark m-0">{children}</...
demidyuk/recycling-react-carousel
src/RCarousel/helpers/getLocalIndex.ts
export const getLocalIndex = (globalIndex: number, length: number) => { return length && ((globalIndex % length) + length) % length; };
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/dto/create-restaurant.dto.ts
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsDefined, IsEmail, IsOptional, IsString } from 'class-validator'; export class CreateRestaurantDto { @ApiProperty() @IsString() @IsDefined() name: string; @ApiProperty() @IsString() @IsEmail() email: string; @ApiPropertyO...
Arwaabdelrahem/RestaurantApi-nestjs
src/city/city.model.ts
import * as mongoose from 'mongoose'; export const citySchema = new mongoose.Schema({ name: { type: String, trim: true, required: true, }, }); citySchema.set('toJSON', { transform(doc, ret, options) { ret.id = ret._id; delete ret._id; delete ret.__v; }, }); export interface City exten...
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/auth.module.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs<filename>src/auth/auth.module.ts import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { JwtModule } from '@nestjs/jwt'; import { InjectModel, MongooseModule } from '@nestjs/mongoose'; import { PassportModule } from '@...
Arwaabdelrahem/RestaurantApi-nestjs
src/common/common.module.ts
import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { JwtGuard } from './guards/jwt.guard'; import { RolesGuard } from './guards/roles.guard'; @Module({ imports: [ConfigModule], providers: [JwtGuard, RolesGuard], }) export class CommonModule {}
Arwaabdelrahem/RestaurantApi-nestjs
src/city/city.service.ts
import { BadRequestException, Injectable, NotFoundException, } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { City } from './city.model'; import { CreateCityDto } from './dto/create-city.dto'; import { UpdateCityDto } from './dto/update-city.dto';...
Arwaabdelrahem/RestaurantApi-nestjs
src/common/decorators/IsDuplicated.ts
<filename>src/common/decorators/IsDuplicated.ts import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { registerDecorator, ValidationArguments, ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, } from 'class-validator'; import { Model } from 'm...
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/auth.service.ts
import { BadRequestException, Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { SignUpDto } from './dto/sign-up.dto'; import * as bcrypt from 'bcrypt'; import { SignInDto } from './dto/sign-in.dto'; import { JwtPayload } from './jwt-payload.in...
Arwaabdelrahem/RestaurantApi-nestjs
src/app.module.ts
<filename>src/app.module.ts import * as Joi from '@hapi/joi'; import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { MongooseModule } from '@nestjs/mongoose'; import { AuthModule } from './auth/auth.module'; import { CityModule } from './city/city.module'; import...
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/dto/update-restaurant.dto.spec.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs<gh_stars>0 import { UpdateRestaurantDto } from './update-restaurant.dto'; describe('UpdateRestaurantDto', () => { it('should be defined', () => { expect(new UpdateRestaurantDto()).toBeDefined(); }); });
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/restaurant.service.ts
<gh_stars>0 import { BadRequestException, ConflictException, Injectable, NotFoundException, } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { City } from 'src/city/city.model'; import { CloudinaryService } from 'src/cloudinary/cloudinary.service'...
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/restaurant.module.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs import { BullModule } from '@nestjs/bull'; import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { MongooseModule } from '@nestjs/mongoose'; import { MulterModule } from '@nestjs/platform-express'; import { diskStorage...
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/jwt-strategy.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs<gh_stars>0 import { Injectable, UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { InjectModel } from '@nestjs/mongoose'; import { PassportStrategy } from '@nestjs/passport'; import { Model } from 'mongoose'; import { Ext...
Arwaabdelrahem/RestaurantApi-nestjs
src/cloudinary/cloudinary.ts
<filename>src/cloudinary/cloudinary.ts import { ConfigService } from '@nestjs/config'; import { v2 } from 'cloudinary'; import { CLOUDINARY } from './constats'; export const CloudinaryProvider = { provide: CLOUDINARY, useFactory: (configService: ConfigService) => { return v2.config({ cloud_name: process....
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/restaurant.controller.ts
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post, Query, UploadedFile, UseGuards, UseInterceptors, } from '@nestjs/common'; import { FileInterceptor } from '@nestjs/platform-express'; import { ApiBadRequestResponse, ApiBearerAuth, ApiBody, ApiConflictRes...
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/file-consumer.ts
import { Process, Processor } from '@nestjs/bull'; import { Job } from 'bull'; import * as fs from 'fs'; @Processor('fileOperation') export class FileConsumer { @Process('delete-file') async fileDeletionJob(job: Job<unknown>) { const jobData: any = job.data; await fs.unlinkSync(jobData.filePath); } }
Arwaabdelrahem/RestaurantApi-nestjs
src/city/dto/update-city.dto.spec.ts
<gh_stars>0 import { UpdateCityDto } from './update-city.dto'; describe('UpdateCityDto', () => { it('should be defined', () => { expect(new UpdateCityDto()).toBeDefined(); }); });
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/restaurant.model.ts
import * as mongoose from 'mongoose'; export const restaurantSchema = new mongoose.Schema({ name: { type: String, trim: true, required: true, }, email: { type: String, trim: true, required: true, unique: true, }, image: { type: String, trim: true, }, city: { type: ...
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/file-producer.service.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs import { InjectQueue } from '@nestjs/bull'; import { Injectable } from '@nestjs/common'; import { Queue } from 'bull'; @Injectable() export class FileProducerService { constructor(@InjectQueue('fileOperation') private queue: Queue) {} async deleteFile(file: Express.Mu...
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/auth.model.ts
<gh_stars>0 import * as mongoose from 'mongoose'; export enum Role { Admin = 'admin', User = 'user', } export const userSchema = new mongoose.Schema({ name: { type: String, required: true, trim: true, }, email: { type: String, trim: true, required: true, unique: true, }, pass...
Arwaabdelrahem/RestaurantApi-nestjs
src/restaurant/dto/create-restaurant.dto.spec.ts
import { CreateRestaurantDto } from './create-restaurant.dto'; describe('CreateRestaurantDto', () => { it('should be defined', () => { expect(new CreateRestaurantDto()).toBeDefined(); }); });
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/dto/sign-up.dto.ts
import { ApiProperty } from '@nestjs/swagger'; import { IsEmail, IsString } from 'class-validator'; import { IsDuplicated } from '../../common/decorators/IsDuplicated'; export class SignUpDto { @IsString() @ApiProperty({ example: 'arwa' }) name: string; @ApiProperty({ example: '<EMAIL>' }) @IsString() @Is...
Arwaabdelrahem/RestaurantApi-nestjs
src/auth/auth.controller.ts
<reponame>Arwaabdelrahem/RestaurantApi-nestjs<filename>src/auth/auth.controller.ts import { Body, Controller, HttpCode, HttpStatus, Post, Request, UseGuards, } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { ApiBadRequestResponse, ApiCreatedResponse, ApiOkResponse, Ap...
Arwaabdelrahem/RestaurantApi-nestjs
src/cloudinary/cloudinary.service.ts
import { Injectable } from '@nestjs/common'; import { v2 } from 'cloudinary'; @Injectable() export class CloudinaryService { async uploadImage(file) { return new Promise((resolve) => { v2.uploader.upload(file, { resource_type: 'auto' }, (error, result) => { resolve({ image: result.url }); });...
Arwaabdelrahem/RestaurantApi-nestjs
src/city/city.module.ts
<filename>src/city/city.module.ts import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { MongooseModule } from '@nestjs/mongoose'; import { AuthModule } from 'src/auth/auth.module'; import authConfig from 'src/auth/config/auth.config'; import { CommonModule } from 'src/common/c...
Arwaabdelrahem/RestaurantApi-nestjs
src/city/city.controller.ts
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post, UseGuards, } from '@nestjs/common'; import { ApiBadRequestResponse, ApiBearerAuth, ApiCreatedResponse, ApiNoContentResponse, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiTags, } from '@nestjs/sw...
Arwaabdelrahem/RestaurantApi-nestjs
src/city/dto/create-city.dto.spec.ts
<gh_stars>0 import { CreateCityDto } from './create-city.dto'; describe('CreateCityDto', () => { it('should be defined', () => { expect(new CreateCityDto()).toBeDefined(); }); });
MicroFocus/srf.reporter.jasmine
lib/core/srf-reporter-types.ts
/*! (c) Copyright 2015 - 2018 Micro Focus or one of its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // You may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Apache License 2...
MicroFocus/srf.reporter.jasmine
lib/core/sync-request/request-worker.ts
<reponame>MicroFocus/srf.reporter.jasmine<filename>lib/core/sync-request/request-worker.ts /*! (c) Copyright 2015 - 2018 Micro Focus or one of its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // You may not use this file except in compliance with the License. // You may obtain a cop...
MicroFocus/srf.reporter.jasmine
lib/suite.ts
/*! (c) Copyright 2015 - 2018 Micro Focus or one of its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // You may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Apache License 2...