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 makeStaircase = (value) => { | |
| const items = value.split(" ").filter(Boolean); | |
| if (items.length === 0) return value; | |
| let index = 0; | |
| let result = ""; | |
| let spaceSize = 0; | |
| for (let item of items) { | |
| let space = " ".repeat(spaceSize); |
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 fs from 'fs'; | |
| import path from 'path'; | |
| import { mkdirp } from '@/utils'; | |
| interface RequestSave { | |
| file: Express.Multer.File; | |
| directory: string; | |
| name: string; | |
| } |
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 Cpf { | |
| constructor(private readonly value: string) {} | |
| public toString(): string { | |
| return this.unmask(this.value); | |
| } | |
| public isValid(): boolean { | |
| const value = this.unmask(this.value); |
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 Cnpj { | |
| constructor(private readonly value: string) {} | |
| public toString(): string { | |
| return this.unmask(this.value); | |
| } | |
| public isValid(): boolean { | |
| const value = this.unmask(this.value); |
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 knex from 'knex'; | |
| export const database = knex({ | |
| client: require('knex/lib/dialects/postgres'), | |
| debug: process.env.DB_DEBUG !== 'off', | |
| log: { enableColors: true }, | |
| connection: { | |
| host: process.env.DB_HOST, | |
| port: Number(process.env.DB_PORT), | |
| database: process.env.DB_NAME, |
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
| type Listener<T = any> = () => Promise<T> | T; | |
| class EventManager { | |
| protected listeners: Record<string, Listener[]> = {}; | |
| public on<T = any>(eventName: string, listener: Listener<T>) { | |
| if (typeof this.listeners[eventName] !== 'object') { | |
| this.listeners[eventName] = []; | |
| } |
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 getFirstLastName = (name: string) => { | |
| const slitName = name.split(' '); | |
| return { | |
| firstName: slitName[0], | |
| lastName: slitName | |
| .slice(1) | |
| .map(row => row.trim()) | |
| .join(' ') | |
| .trim(), |
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 { Request } from 'express'; | |
| import multer from 'multer'; | |
| import { ForbiddenError } from '@src/errors'; | |
| export const multerFileFilter = | |
| (mimeTypes: string[]) => | |
| ( | |
| _: Request, | |
| file: Express.Multer.File, |
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 https, { RequestOptions } from 'https'; | |
| export interface HttpRequest extends RequestOptions { | |
| url: string; | |
| body?: string; | |
| method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS'; | |
| } | |
| interface Response<T = Buffer | any> { | |
| body: 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
| <?php | |
| if (!function_exists('array_find')) { | |
| /** | |
| * @param array $array | |
| * @param callable $callback | |
| * | |
| * @return mixed|null | |
| */ | |
| function array_find(array $array, callable $callback) |
NewerOlder