repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
jenkinsns/spfxwebparts
spfx-multiplewebparts/src/webparts/firstwebpart/IFirstwebpartWebPartProps.ts
<reponame>jenkinsns/spfxwebparts export interface IFirstwebpartWebPartProps { description: string; }
jenkinsns/spfxwebparts
spfx-webpartproperties/src/webparts/spfxpropertypane/SpfxpropertypaneWebPart.ts
import { BaseClientSideWebPart, IPropertyPaneSettings, IWebPartContext, PropertyPaneTextField, PropertyPaneCheckbox, PropertyPaneLabel, PropertyPaneLink, PropertyPaneSlider, PropertyPaneToggle, PropertyPaneDropdown } from '@microsoft/sp-client-preview'; import styles from './Spfxpropertypane.module...
jenkinsns/spfxwebparts
spfx-firstwebpart/src/webparts/spfxFirstwebpart/SpfxFirstwebpartWebPart.ts
import { BaseClientSideWebPart, IPropertyPaneSettings, IWebPartContext, PropertyPaneTextField } from '@microsoft/sp-client-preview'; import styles from './SpfxFirstwebpart.module.scss'; import * as strings from 'spfxFirstwebpartStrings'; import { ISpfxFirstwebpartWebPartProps } from './ISpfxFirstwebpartWebPart...
jenkinsns/spfxwebparts
spfx-multiplewebparts/src/webparts/firstwebpart/loc/mystrings.d.ts
<filename>spfx-multiplewebparts/src/webparts/firstwebpart/loc/mystrings.d.ts<gh_stars>0 declare interface IFirstwebpartStrings { PropertyPaneDescription: string; BasicGroupName: string; DescriptionFieldLabel: string; } declare module 'firstwebpartStrings' { const strings: IFirstwebpartStrings; export = strin...
jenkinsns/spfxwebparts
spfx-webpartproperties/src/webparts/spfxpropertypane/ISpfxpropertypaneWebPartProps.ts
export interface ISpfxpropertypaneWebPartProps { name: string; description: string; Slider:string; Toggle:string; dropdowm:string; checkbox:string; URL:string; textbox:string; }
jenkinsns/spfxwebparts
spfx-webpartproperties/src/webparts/spfxpropertypane/loc/mystrings.d.ts
declare interface ISpfxpropertypaneStrings { PropertyPaneDescription: string; BasicGroupName: string; DescriptionFieldLabel: string; } declare module 'spfxpropertypaneStrings' { const strings: ISpfxpropertypaneStrings; export = strings; }
jenkinsns/spfxwebparts
spfx-multiplewebparts/src/webparts/secondwebpart/SecondwebpartWebPart.ts
<filename>spfx-multiplewebparts/src/webparts/secondwebpart/SecondwebpartWebPart.ts<gh_stars>0 import { BaseClientSideWebPart, IPropertyPaneSettings, IWebPartContext, PropertyPaneTextField } from '@microsoft/sp-client-preview'; import styles from './Secondwebpart.module.scss'; import * as strings from 'secondwe...
djibril6/graphql-nodejs-boilerplate
tests/integration/user.test.ts
import faker from 'faker'; import moment from 'moment'; import bcrypt from 'bcryptjs'; import { EGender, EGraphQlErrorCode, ETokenType, EUserRole, IUser } from '../../src/types'; import { setupTestDB, setupTestServer, userUtil } from '../utils'; import server from '../../src/graphql'; import { gql } from 'apollo-server...
djibril6/graphql-nodejs-boilerplate
tests/utils/index.ts
export { default as setupTestDB } from './setupTestDB'; export { default as userUtil } from './users.util'; export { default as setupTestServer } from './setupTestServer';
djibril6/graphql-nodejs-boilerplate
src/graphql/schemas/auth.schema.ts
<gh_stars>1-10 import { gql } from 'apollo-server-express'; export default gql` type TTokenFormat { token: String! expires: String! } type TToken { access: TTokenFormat! refresh: TTokenFormat! } type TAuthSuccess { user: TUser! tokens: TToken! } # Queries # Mutations exte...
djibril6/graphql-nodejs-boilerplate
tests/services/auth.service.ts
import jwt from 'jsonwebtoken'; import moment, { Moment } from 'moment'; import { userService } from './'; import { Token } from '../../src/models'; import { config } from '../../src/config'; import { EGraphQlErrorCode, ETokenType, ITokenPayload } from '../../src/types'; import { GraphQlApiError } from '../../src/utils...
djibril6/graphql-nodejs-boilerplate
tests/integration/auth.test.ts
import faker from 'faker'; import moment from 'moment'; import bcrypt from 'bcryptjs'; import { EGender, EGraphQlErrorCode, ETokenType, EUserRole, IUser } from '../../src/types'; import { setupTestDB, setupTestServer, userUtil } from '../utils'; import server from '../../src/graphql'; import { gql } from 'apollo-server...
djibril6/graphql-nodejs-boilerplate
src/utils/index.ts
export { default as context } from './context'; export { default as GraphQlApiError } from './GraphQlApiError'; export { default as validate } from './validate'; export { default as catchReq } from './catchReq'; export { default as pick } from './pick'; export { default as emailSender } from './emailSender';
djibril6/graphql-nodejs-boilerplate
src/middlewares/index.ts
export { default as auth } from './auth.middleware';
djibril6/graphql-nodejs-boilerplate
src/utils/emailSender.ts
<gh_stars>1-10 import sgMail from '@sendgrid/mail'; import { config, logger } from '../config'; const sendEmail = async (to: string, from: string, subject: string, text: string, html: string) => { // using Twilio SendGrid's v3 Node.js Library // https://github.com/sendgrid/sendgrid-nodejs sgMail.setApiKey(confi...
djibril6/graphql-nodejs-boilerplate
src/graphql/schemas/user.schema.ts
import { gql } from 'apollo-server-express'; export default gql` type TUser { id: ID firstname: String lastname: String email: String gender: EGender role: EUserRole isEmailVerified: Boolean accountClosed: Boolean } type TPaginatedUsers { results: [TUser]! page: Int! ...
djibril6/graphql-nodejs-boilerplate
src/graphql/resolvers/user.resolver.ts
import { catchReq } from '../../utils'; import { EUserRole } from '../../types'; import { userValidation } from '../../validations'; import { auth } from '../../middlewares'; import { userController } from '../../controllers'; export default { Query: { user: auth(catchReq(userValidation.getUser, userController...
djibril6/graphql-nodejs-boilerplate
src/index.ts
import mongoose from 'mongoose'; import setup from './setup'; import { config, logger } from './config'; mongoose.connect(config.mongoose.url, config.mongoose.options).then(async () => { setup().then(app => { app.listen(config.port, () => { logger.info(`🚀 Server listening to port ${config.port}`); })...
djibril6/graphql-nodejs-boilerplate
src/validations/index.ts
<reponame>djibril6/graphql-nodejs-boilerplate export { default as userValidation } from './user.validation'; export { default as authValidation } from './auth.validation';
djibril6/graphql-nodejs-boilerplate
src/validations/auth.validation.ts
import Joi from 'joi'; import { EGender } from '../types'; import validation from './validation'; const register = Joi.object().keys({ firstname: Joi.string().required(), lastname: Joi.string().required(), email: Joi.string().required().email(), password: Joi.string().required().custom(validation.password), ...
djibril6/graphql-nodejs-boilerplate
src/setup.ts
import express, { Express } from 'express'; import cors from 'cors'; import helmet from 'helmet'; import xss from 'xss-clean'; import mongoSanitize from 'express-mongo-sanitize'; import compression from 'compression'; import { config } from './config'; import { ENodeEnv } from './types'; import apolloServer from './gr...
djibril6/graphql-nodejs-boilerplate
src/utils/validate.ts
<reponame>djibril6/graphql-nodejs-boilerplate<filename>src/utils/validate.ts import { UserInputError } from 'apollo-server-express'; import Joi from 'joi'; export default function<T> (schema: Joi.ObjectSchema<T>, data: T) { const { value, error } = schema.prefs({ errors: { label: 'key' } }).validate(data); if (err...
djibril6/graphql-nodejs-boilerplate
src/datasources/User.datasource.ts
import { MongoDataSource } from 'apollo-datasource-mongodb'; import { FilterQuery } from 'mongoose'; import { GraphQlApiError } from '../utils'; import { IUserDocument, IUser, IContext, IUserModel, IPaginateOption, EGraphQlErrorCode } from '../types'; export default class UserDataSource extends MongoDataSource<IUserDo...
djibril6/graphql-nodejs-boilerplate
tests/services/index.ts
export { default as userService } from './user.service'; export { default as authService } from './auth.service';
djibril6/graphql-nodejs-boilerplate
src/datasources/index.ts
export { default as UserDataSource } from './User.datasource'; export { default as TokenDataSource } from './Token.datasource';
djibril6/graphql-nodejs-boilerplate
src/controllers/auth.controller.ts
<reponame>djibril6/graphql-nodejs-boilerplate import { emailSender, GraphQlApiError } from '../utils'; import { EGraphQlErrorCode, ETokenType, EUserRole, IContext, IUser } from '../types'; async function register(data: IUser, ctx: IContext) { const registerData = data; registerData.role = EUserRole.USER; const u...
djibril6/graphql-nodejs-boilerplate
src/utils/context.ts
import { Request, Response } from 'express'; import { IContext } from '../types'; export default async ({ req, res, }: { req: Request; res?: Response; }): Promise<IContext> => { return { req, res, }; };
djibril6/graphql-nodejs-boilerplate
src/middlewares/auth.middleware.ts
import { GraphQlApiError } from '../utils'; import { EGraphQlErrorCode, ETokenType, EUserRole, IContext } from '../types'; /* eslint-disable @typescript-eslint/no-explicit-any */ export default ( fn: (parent: any, args: any, context: IContext) => any, requiredRights?: EUserRole[], ) => async (parent: any, args: an...
djibril6/graphql-nodejs-boilerplate
src/types/interfaces/app.interface.ts
import jwt from 'jsonwebtoken'; import { ETokenType, IUserDocument } from ".."; import { Request, Response } from "express" import { TokenDataSource, UserDataSource } from '../../datasources'; export interface ITokenPayload extends jwt.JwtPayload { type?: ETokenType } export interface IContext { req: Request; r...
djibril6/graphql-nodejs-boilerplate
src/graphql/index.ts
<reponame>djibril6/graphql-nodejs-boilerplate<gh_stars>1-10 import { ApolloServer } from 'apollo-server-express'; import { merge } from 'lodash'; import { Token, User } from '../models'; import { TokenDataSource, UserDataSource } from '../datasources'; import { context } from '../utils'; import { authResolver, userReso...
djibril6/graphql-nodejs-boilerplate
tests/utils/setupTestServer.ts
import { ApolloServer } from 'apollo-server-express'; import { merge } from 'lodash'; import { Request } from 'express'; import { TokenDataSource, UserDataSource } from '../../src/datasources'; import { authResolver, userResolver } from '../../src/graphql/resolvers'; import { AppSchema, AuthSchema, UserSchema } from '....
djibril6/graphql-nodejs-boilerplate
src/graphql/resolvers/auth.resolver.ts
import { catchReq } from '../../utils'; import { authValidation } from '../../validations'; import { auth } from '../../middlewares'; import { authController } from '../../controllers'; export default { Query: {}, Mutation: { register: catchReq(authValidation.register, authController.register), login: ca...
djibril6/graphql-nodejs-boilerplate
src/types/index.ts
export { ENodeEnv, EGender, EModelNames, EUserRole, ETokenType, EGraphQlErrorCode } from './enums/app.enum'; // interfaces export { IPaginateOption } from './interfaces/utils.interface'; export { IUserDocument, IUser, IUserModel } from './interfaces/user.interface'; export { ITokenDocument } fr...
djibril6/graphql-nodejs-boilerplate
src/datasources/Token.datasource.ts
<reponame>djibril6/graphql-nodejs-boilerplate import { MongoDataSource } from 'apollo-datasource-mongodb'; import { ITokenDocument, IContext, EGraphQlErrorCode } from '../types'; import jwt from 'jsonwebtoken'; import moment, { Moment } from 'moment'; import { config } from '../config'; import { GraphQlApiError } from ...
djibril6/graphql-nodejs-boilerplate
src/graphql/resolvers/index.ts
export { default as userResolver } from './user.resolver'; export { default as authResolver } from './auth.resolver';
djibril6/graphql-nodejs-boilerplate
src/utils/GraphQlApiError.ts
<filename>src/utils/GraphQlApiError.ts<gh_stars>1-10 import { ApolloError } from 'apollo-server-errors'; import { EGraphQlErrorCode } from '../types'; export default class GraphQlApiError extends ApolloError { constructor(message: string, code?: string) { super(message, code || EGraphQlErrorCode.INTERNAL_SERVER_...
djibril6/graphql-nodejs-boilerplate
src/validations/user.validation.ts
import Joi from 'joi'; import { EGender, EUserRole } from '../types'; import validation from './validation'; const createUser = Joi.object().keys({ firstname: Joi.string().required(), lastname: Joi.string().required(), email: Joi.string().required().email(), role: Joi.string().valid(EUserRole.ADMIN, EUserRole....
djibril6/graphql-nodejs-boilerplate
src/utils/catchReq.ts
<gh_stars>1-10 /* eslint-disable @typescript-eslint/no-explicit-any */ import Joi from 'joi'; import { validate } from '.'; import { IContext } from '../types'; export default function catchReq(schema: Joi.ObjectSchema<any>, fn: (data: any, ctx: IContext) => any) { return ( parent: any, args: any, ctx: ...
djibril6/graphql-nodejs-boilerplate
src/graphql/schemas/index.ts
export { default as AppSchema } from './app.schema'; export { default as AuthSchema } from './auth.schema'; export { default as UserSchema } from './user.schema';
djibril6/graphql-nodejs-boilerplate
src/controllers/user.controller.ts
import { GraphQlApiError, pick } from '../utils'; import { EGraphQlErrorCode, EUserRole, IContext, IUser } from '../types'; async function createUser(data: IUser, ctx: IContext) { data.password = '<PASSWORD>'; const user = await ctx.dataSources.users.createUser(data); return user; } interface IGetUserArgs { r...
djibril6/graphql-nodejs-boilerplate
tests/services/user.service.ts
import { FilterQuery } from 'mongoose'; import { User } from '../../src/models'; import { EGraphQlErrorCode, IPaginateOption, IUserDocument } from '../../src/types'; import { GraphQlApiError } from '../../src/utils'; const getUsers = async (filter: FilterQuery<IUserDocument>, options: IPaginateOption) => { const us...
djibril6/graphql-nodejs-boilerplate
src/graphql/schemas/app.schema.ts
import { gql } from 'apollo-server-express'; export default gql` enum EUserRole { admin user } enum EGender { female male } # Queries # type Query {} # Mutations # type Mutation {} `;
smileCris/YBao_admin_h5
src/components/Charts/index.d.ts
import * as numeral from 'numeral'; export { default as ChartCard } from './ChartCard'; export { default as Bar } from './Bar'; export { default as MiniProgress } from './MiniProgress'; declare const yuan: (value: number | string) => string; export { yuan };
operali/node-windows-ui
windows-ui/index.d.ts
<reponame>operali/node-windows-ui declare var dialog: { // message box for infomation info(title: string, msg: string): Promise<boolean>, // message box for choose OK or cancel okCancel(title: string, msg: string): Promise<boolean>, // open file dialog openfile(initPath: string, filter: string)...
operali/node-windows-ui
index.ts
import * as winUI from './windows-ui/index'; const test = async () => { console.log(await winUI.dialog.info('title', 'hello world, 你好世界')); console.log(await winUI.dialog.okCancel('title', 'hello world, 请选择')); console.log(await winUI.dialog.openfile('C:/Program Files (x86)', '*.*')); console.log(awai...
feego/react-form-hooks
src/schemaUtils.tsx
<reponame>feego/react-form-hooks<filename>src/schemaUtils.tsx<gh_stars>0 const FIELD_TYPE = Symbol('FIELD') const FORM_TYPE = Symbol('FORM') export const isField = (field: any) => field['#type'] === FIELD_TYPE export const isForm = (field: any) => field['#type'] === FORM_TYPE export const createField = (validators: a...
feego/react-form-hooks
src/useState.tsx
import { useState as useBaseState } from 'react' import { getInitialTouched, getInitialValues, getInitialVisited } from './utils' /** * Builds the state hooks that `useController` will use to store all form related data. * NOTE: `useFormController` already creates it's own state hooks internally by default, if we do...
feego/react-form-hooks
src/validate.tsx
<filename>src/validate.tsx import { getFields, isForm } from './schemaUtils' export const Errors = { Required: 'Required', InvalidType: 'InvalidType', FailedRegex: 'FailedRegex', Unexpected: 'Unexpected' } const typeCheckers: any = { number: (value: any) => Boolean(parseInt(value, 10)) } const identity = [...
feego/react-form-hooks
src/useController.tsx
<gh_stars>0 import { useCallback, useState, useMemo } from 'react' import { getAllFieldsTouched, getInitialValues, getInitialTouched, getValidationResult, getInitialVisited, stateFromSchema } from './utils' import defaultValidate from './validate' /** * The `useController` hook allows the parent component...
feego/react-form-hooks
src/utils.tsx
import defaultValidate from './validate' import { getFields, isForm } from './schemaUtils' export type ValidationResult = [true] | [false, any] export const stateFromSchema = (schema: any, state: any = {}) => getFields(schema).reduce((result: any, [name, field]: any) => { return { ...result, [name]:...
feego/react-form-hooks
src/useDirtyValues.tsx
import { useState, useCallback } from 'react' const recursivelyPopulateDirtyFields = (dirty = {} as any, eventMetadata: any): any => { const { fieldName, nestedFormEvent } = eventMetadata const nextDirtyValue = nestedFormEvent !== undefined ? recursivelyPopulateDirtyFields(dirty[fieldName], nestedFormEve...
feego/react-form-hooks
src/useGetPropsForField.tsx
<filename>src/useGetPropsForField.tsx import { useCallback } from 'react' import { getField } from './schemaUtils' export const buildEventMetadata = ( values: any, validationResult: any, fieldName: any, fieldSchema: any, nestedFormEvent?: any, nextValue?: any ) => ({ fieldName, fieldSchema, values, ...
feego/react-form-hooks
src/index.tsx
<reponame>feego/react-form-hooks export { default as useController } from './useController' export { default as useGetPropsForField } from './useGetPropsForField' export { default as useGetPropsForNestedForm } from './useGetPropsForNestedForm' export { createForm, createField, getField, getFields } from './schemaUtils'...
feego/react-form-hooks
src/useGetPropsForNestedForm.tsx
import { useCallback } from 'react' import { buildEventMetadata } from './useGetPropsForField' import { getField } from './schemaUtils' /** * Similar to `useController` for to generate the props for a nested form. * * @param {Object} props - Form props. * @returns {Object} Props for nested form `useController` hoo...
hingyeung/sbrick-drive-by-react
src/App.tsx
import 'bootstrap/dist/css/bootstrap-reboot.css'; import 'bootstrap/dist/css/bootstrap-grid.css'; import * as React from 'react'; import DriveByReact from './components/DriveByReact/DriveByReact'; import './App.css'; import LayoutContainer from './components/layout/LayoutContainer/LayoutContainer'; import Header from '...
hingyeung/sbrick-drive-by-react
src/components/DriveByReact/DriveByReact.tsx
<gh_stars>1-10 import * as React from 'react'; import { Component } from 'react'; import { DragDropContext, DragStart, DropResult } from 'react-beautiful-dnd'; import { Instruction } from '../../models/Instruction'; import TemplateInstructionList, { DROPPABLE_ID as InstructionSourceContainerDroppableId } from '../Tem...
hingyeung/sbrick-drive-by-react
src/components/InstructionCard/InstructionCard.tsx
<reponame>hingyeung/sbrick-drive-by-react<filename>src/components/InstructionCard/InstructionCard.tsx import * as React from 'react'; import { Draggable } from 'react-beautiful-dnd'; import { Instruction } from '../../models/Instruction'; import './InstructionCard.css'; import LayoutRow from '../layout/LayoutRow/Layout...
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutContainer/LayoutContainer.tsx
import * as React from 'react'; import * as classNames from 'classnames'; interface Props { className?: string; componentClass?: any; } const LayoutContainer: React.SFC<Props> = (props) => { const { className, componentClass: Component, ...otherProps } = props; return ( <Component {...other...
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutCol/LayoutCol.tsx
<filename>src/components/layout/LayoutCol/LayoutCol.tsx import * as React from 'react'; import * as classNames from 'classnames'; interface LayoutColComponentProps { // className?: string; componentClass?: any; sm?: number; md?: number; lg?: number; xl?: number; propsForComponent?: object; } const isVal...
hingyeung/sbrick-drive-by-react
src/components/PendingInstructionQueue/PendingInstructionQueue.tsx
import * as React from 'react'; import './PendingInstructionQueue.css'; import InstructionList from '../InstructionList/InstructionList'; import { PendingInstructionCard } from '../PendingInstructionCard/PendingInstructionCard'; import { Instruction } from '../../models/Instruction'; import DragNDropHelpMessage from '....
hingyeung/sbrick-drive-by-react
src/components/Button/ActiveButton.tsx
import * as React from 'react'; import Button, { ButtonProps } from './Button'; import * as classNames from 'classnames'; import './ActiveButton.css'; const ActiveButton: React.SFC<ButtonProps> = (props) => { const { className, ...otherProps } = props; return <Button {...otherProps} className={className...
hingyeung/sbrick-drive-by-react
src/components/DragNDropHelpMessage/DragNDropHelpMessage.tsx
<gh_stars>1-10 import * as React from 'react'; import './DragNDropHelpMessage.css'; // @ts-ignore import dragIcon from '../../assets/drop.svg'; const DragNDropHelpMessage: React.SFC<any> = (props) => { return ( <> <div className="dnd-help-message__icon"><img src={dragIcon}/></div> <div className="dnd...
hingyeung/sbrick-drive-by-react
src/models/Instruction.ts
<reponame>hingyeung/sbrick-drive-by-react import { SBrickCommand } from './SBrickCommand'; export interface Instruction { id: string; displayName: string; sBrickCommand: SBrickCommand; }
hingyeung/sbrick-drive-by-react
src/components/DriveByReact/DriveByReact.spec.tsx
<filename>src/components/DriveByReact/DriveByReact.spec.tsx<gh_stars>1-10 import * as React from 'react'; import DriveByReact, { State } from './DriveByReact'; import { DraggableId, DraggableLocation, DropResult } from 'react-beautiful-dnd'; import { mount } from 'enzyme'; import { DROPPABLE_ID as InstructionQueueDro...
hingyeung/sbrick-drive-by-react
src/models/SBrickCommand.ts
export enum SBrickCommand { forward, backward, left, right }
hingyeung/sbrick-drive-by-react
src/vendors.d.ts
<gh_stars>1-10 // https://www.typescriptlang.org/docs/handbook/modules.html // https://github.com/microsoft/typescript/issues/3019#issuecomment-363179994 declare module 'react-test-renderer'; declare module 'enzyme';
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutCol/LayoutCol.spec.tsx
import * as React from 'react'; import LayoutCol from './LayoutCol'; import { shallow } from 'enzyme'; describe('LayoutColComponent', () => { const hasClassWithPrefix = (wrapper: any, prefix: string) => { expect( wrapper.find('.hello').prop('className').trim().split(/\s+/).filter((thisClass: string) => ...
hingyeung/sbrick-drive-by-react
src/services/SBrickService/SBrickService.spec.ts
import { drive } from './SBrickService'; import axios from 'axios'; import { SBrickCommand } from '../../models/SBrickCommand'; jest.mock('axios'); describe('SBrickService', () => { it('should send GET request to server', function () { const noCacheHeader = {'Cache-Control': 'no-cache'}, expectedUrl = 'ht...
hingyeung/sbrick-drive-by-react
src/components/ControlPanel/ControlPanel.spec.tsx
import * as React from 'react'; import ControlPanel from './ControlPanel'; import { shallow } from 'enzyme'; describe('ControlPanel', () => { it('should call onPlayClick callback when play button is clicked', () => { const callback = jest.fn(); const wrapper = shallow(<ControlPanel onPlayClick={callback} onC...
hingyeung/sbrick-drive-by-react
src/commons/ListUtils.ts
// a little function to help us with reordering the result export const reorder = (list: any[], startIndex: number, endIndex: number) => { const result = Array.from(list); const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); return result; }; export const insert = (list: any[], ...
hingyeung/sbrick-drive-by-react
src/components/InstructionList/InstructionList.tsx
import { Droppable, DroppableProvided } from 'react-beautiful-dnd'; import * as React from 'react'; import * as classNames from 'classnames'; import './InstructionList.css'; import LayoutRow from '../layout/LayoutRow/LayoutRow'; import LayoutCol from '../layout/LayoutCol/LayoutCol'; export interface Props { droppabl...
hingyeung/sbrick-drive-by-react
src/services/ConfigService/ConfigService.ts
export const getConfigForEnv = () => { const defaultConfig = require('configs/default.json'); return Object.assign({}, defaultConfig, require(`configs/${process.env.NODE_ENV}.json`)); };
hingyeung/sbrick-drive-by-react
src/components/InstructionCard/InstructionCard.spec.tsx
<filename>src/components/InstructionCard/InstructionCard.spec.tsx import * as React from 'react'; import { Instruction } from '../../models/Instruction'; // https://github.com/facebook/jest/issues/936#issuecomment-214556122 // rbd is used to mock 'react-beautiful-dnd' import * as rbd from 'react-beautiful-dnd'; import ...
hingyeung/sbrick-drive-by-react
src/components/Header/Header.tsx
<gh_stars>1-10 import * as React from 'react'; import LayoutCol from '../layout/LayoutCol/LayoutCol'; import './header.css'; import LayoutRow from '../layout/LayoutRow/LayoutRow'; // @ts-ignore import SBrickLogo from '../../assets/sbrick_logo_400x400.png'; export default () => { return ( <LayoutRow className="he...
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutContainer/LayoutContainer.spec.tsx
<gh_stars>1-10 import { shallow } from 'enzyme'; import * as React from 'react'; import LayoutContainer from './LayoutContainer'; import LayoutRow from '../LayoutRow/LayoutRow'; import LayoutCol from '../LayoutCol/LayoutCol'; describe('LayoutContainer', () => { it('should render className in props', () => { cons...
hingyeung/sbrick-drive-by-react
src/components/ControlPanel/ControlPanel.tsx
import * as React from 'react'; import LayoutRow from '../layout/LayoutRow/LayoutRow'; import LayoutCol from '../layout/LayoutCol/LayoutCol'; import './ControlPanel.css'; import ActiveButton from '../Button/ActiveButton'; // @ts-ignore import playIcon from '../../assets/play.svg'; import Button from '../Button/Button';...
hingyeung/sbrick-drive-by-react
src/components/TemplateInstructionCard/TemplateInstructionCard.tsx
<reponame>hingyeung/sbrick-drive-by-react import * as React from 'react'; import InstructionCard, { Props as InstructionCardProps } from '../InstructionCard/InstructionCard'; import './TemplateInstructionCard.css'; import { getIconForSBrickCommand } from '../../commons/IconUtils'; export const TemplateInstructionCard...
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutRow/LayoutRow.spec.tsx
import LayoutRow from './LayoutRow'; import { shallow } from 'enzyme'; import * as React from 'react'; import LayoutCol from '../LayoutCol/LayoutCol'; describe('LayoutRow', () => { it('should render className in props', () => { const wrapper = shallow(<LayoutRow className="my-row"><LayoutCol className="my-...
hingyeung/sbrick-drive-by-react
src/commons/IconUtils.ts
import { SBrickCommand } from '../models/SBrickCommand'; // @ts-ignore import ForwardIcon from '../assets/up-arrow.svg'; // @ts-ignore import BackwardIcon from '../assets/down-arrow.svg'; // @ts-ignore import LeftIcon from '../assets/left-arrow.svg'; // @ts-ignore import RightIcon from '../assets/right-arrow.svg'; // @...
hingyeung/sbrick-drive-by-react
src/commons/ListUtils.spec.ts
import { insert, remove, reorder } from './ListUtils'; describe('ListUtils', function () { let listToModify: number[]; beforeEach(() => { listToModify = [0, 1, 2, 3]; }); describe('reorder', function () { it('should reorder items at the front', function () { expect(reorder(listToModify, 0, 1))....
hingyeung/sbrick-drive-by-react
src/components/Button/Button.tsx
<reponame>hingyeung/sbrick-drive-by-react import * as React from 'react'; import { ButtonHTMLAttributes } from 'react'; import * as classNames from 'classnames'; import './Button.css'; // const buildIconDOM = (icon: any): JSX.Element => { // if (icon) { // return ( // <img src={icon}/> // ); // } // ...
hingyeung/sbrick-drive-by-react
src/components/Footer/Footer.tsx
import * as React from 'react'; import LayoutRow from '../layout/LayoutRow/LayoutRow'; import LayoutCol from '../layout/LayoutCol/LayoutCol'; import './Footer.css'; export default (props: any) => ( <LayoutRow className="footer justify-content-end"> <LayoutCol sm={2} className="footer__credit" componentClass={'fo...
hingyeung/sbrick-drive-by-react
src/components/layout/LayoutRow/LayoutRow.tsx
import * as React from 'react'; import * as classNames from 'classnames'; interface Props { className?: string; componentClass?: any; propsForComponent?: object; ref?: any; } const LayoutRow: React.SFC<Props> = (props) => { const { componentClass: Component, propsForComponent, className, ......
hingyeung/sbrick-drive-by-react
src/services/SBrickService/SBrickService.ts
import { SBrickCommand } from '../../models/SBrickCommand'; import { getConfigForEnv } from '../ConfigService/ConfigService'; import axios from 'axios'; const sendRequest = (url: string) => (resolve: any, reject: any) => { axios.get(url, {headers: {'Cache-Control': 'no-cache'}}).then((response) => { resolve(re...
hingyeung/sbrick-drive-by-react
src/components/TemplateInstructionList/TemplateInstructionList.tsx
import * as React from 'react'; import './TemplateInstructionList.css'; import InstructionList from '../InstructionList/InstructionList'; export const DROPPABLE_ID = 'template-instruction-list-droppable'; interface Props { decorateForDragInProgress: boolean; children: any; } export default (props: Props) => ( ...
bit-mask/g_bot
src/helpers/equation.ts
<gh_stars>1-10 import { Equation } from '../models' const sha256 = require('sha256') const secret = process.env.G_TG_VERIFY_SECRET; export function generateEquation() { const code = `q=${getRandomInt()}` const question = `Go to go/tg-verify?${code} and enter the value here.` const timestamp = Math.floor((new Da...
JulianMiranda/compraBackend
src/modules/notifications/notifications.controller.ts
import { Controller } from '@nestjs/common'; import { NotificationsRepository } from './notifications.repository'; @Controller('notifications') export class NotificationsController { constructor(private notificationsRepository: NotificationsRepository) {} }
JulianMiranda/compraBackend
src/modules/subcategory/subcategory.module.ts
<filename>src/modules/subcategory/subcategory.module.ts import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import SubcategorySchema from '../../schemas/subcategory.schema'; import { ImageModule } from '../image/image.module'; import { NotificationsModule } from '../notifications...
JulianMiranda/compraBackend
src/dto/mongo-query.dto.ts
import { IsArray, IsNumber, IsObject } from 'class-validator'; export class MongoQuery { @IsObject() filter: object; @IsObject() projection: object; @IsObject() sort: object; @IsNumber() limit: number; @IsNumber() page: number; @IsNumber() skip: number; @IsArray() population: any[]; }...
JulianMiranda/compraBackend
src/modules/notifications/notifications.module.ts
<filename>src/modules/notifications/notifications.module.ts import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { NotificationSchema } from 'src/schemas/notification.schema'; import SubcategorySchema from 'src/schemas/subcategory.schema'; import OrderSchema from 'src/schem...
JulianMiranda/compraBackend
src/modules/role/role.controller.ts
import { Controller, Get } from '@nestjs/common'; import { RoleRepository } from './role.repository'; @Controller() /* @UseGuards(AuthenticationGuard) */ export class RoleController { constructor(private roleRepository: RoleRepository) {} @Get('/getRoles') getRoles(): Promise<any> { return this.roleReposito...
JulianMiranda/compraBackend
src/modules/user/user.module.ts
import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import UserSchema from '../../schemas/user.schema'; import { ImageModule } from '../image/image.module'; import { UserController } from './user.controller'; import { UserRepository } from './user.repository'; @Module({ import...
JulianMiranda/compraBackend
src/enums/notification.enum.ts
export enum NOTIFICATION { NEW_SUBCATEGORY = 'NEW_SUBCATEGORY', UPDATE_SUBCATEGORY = 'UPDATE_SUBCATEGORY', ORDER = 'ORDER', }
JulianMiranda/compraBackend
src/modules/subcategory/subcategory.repository.ts
import { Injectable, InternalServerErrorException, NotFoundException, } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { NOTIFICATION } from 'src/enums/notification.enum'; import { Image } from '../../dto/image.dto'; import { MongoQuery } from '../....
JulianMiranda/compraBackend
src/schemas/order.schema.ts
<reponame>JulianMiranda/compraBackend import * as mongoose from 'mongoose'; import { schemaOptions } from '../utils/index'; const OrderSchema = new mongoose.Schema( { status: { type: Boolean, default: true, index: true }, owner: { type: String, default: 'Compra' }, user: { type: mongoose.Schema.Types.Obj...
JulianMiranda/compraBackend
src/modules/subcategory/subcategory.controller.ts
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards, UsePipes, } from '@nestjs/common'; import { Subcategory } from 'src/dto/subcategory.dto'; import { AuthenticationGuard } from 'src/guards/authentication.guard'; import { MongoQuery } from '../../dto/mongo-query.dto'; import { ENTITY ...
JulianMiranda/compraBackend
src/schemas/user.schema.ts
import * as mongoose from 'mongoose'; import { THEME } from 'src/enums/theme.enum'; import { schemaOptions } from '../utils/index'; const UserSchema = new mongoose.Schema( { firebaseId: String, name: { type: String, index: true }, email: String, phone: String, role: String, defaultImage: Stri...
JulianMiranda/compraBackend
src/services/firebase.service.ts
<reponame>JulianMiranda/compraBackend<gh_stars>0 import { Injectable, InternalServerErrorException, Logger, } from '@nestjs/common'; import * as admin from 'firebase-admin'; import { splitArray } from 'src/utils/util'; @Injectable() export class FirebaseService { private static readonly logger = new Logger(Fir...
JulianMiranda/compraBackend
src/modules/user/user.repository.ts
<filename>src/modules/user/user.repository.ts import { Injectable, InternalServerErrorException, NotFoundException, } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { FirebaseService } from 'src/services/firebase.service'; import { Image } from '../...
JulianMiranda/compraBackend
src/modules/notifications/notifications.repository.ts
import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { FirebaseService } from 'src/services/firebase.service'; import { flatten } from 'src/utils/util'; import { Order } from '../../dto/order.dto'; import { Us...