UNPKG

coddyger

Version:

Coddyger est une bibliothèque JavaScript/TypeScript qui fournit des fonctions communes et des plugins pour la gestion des données, la communication entre services, et des utilitaires avancés pour le développement d'applications.

202 lines (187 loc) 5.26 kB
export interface IErrorObject { error: boolean; data: any; message?: string; } export interface IApi { status?: number; message: string | object; data?: any; } export interface IData<T> { save(item: T): Promise<T> | IErrorObject; saveMany(items: []): Promise<T[]> | IErrorObject; update(params: any, item: T | any): Promise<T | null> | IErrorObject; updateMany(params: any, item: T | any): Promise<T | null> | IErrorObject; select(params?: any): Promise<Array<T> | null | IErrorObject>; selectOne(params: any, fields?: string): Promise<Array<T> | null> | IErrorObject; selectLatest(status?: string): Promise<Array<T> | null> | IErrorObject; selectLatestWithParams(params: any, excludeFields?: string): Promise<Array<T> | null> | IErrorObject; count(params: any): Promise<number | null> | IErrorObject; exist(params?: any): Promise<boolean> | IErrorObject; aggregate(params: any): Promise<any> | IErrorObject; selectHug(params?: any): Promise<Array<T> | null> | IErrorObject; remove(params: any): Promise<T> | IErrorObject; removeMany(params: any): Promise<T> | IErrorObject; // --- Méthodes ajoutées, facultatives pour compatibilité Mongo --- findByPk?(id: any, options?: any): Promise<T | null> | IErrorObject; findAll?(options?: any): Promise<Array<T> | null> | IErrorObject; increment?(params: any, field: string, by?: number): Promise<any> | IErrorObject; decrement?(params: any, field: string, by?: number): Promise<any> | IErrorObject; upsert?(data: any, options?: any): Promise<any> | IErrorObject; restore?(params: any): Promise<any> | IErrorObject; } export interface IEnvironment { appName: string; mode: string; domain?: string; description?: string; server: { port: number | string; apiVersion: string; serverPath: string; origins: string; swaggerHost: string; }; database: { useDatabase: string; connectionString?: string; dialect?: string; storage?: string; name?: string; }; transporter: { broker: string; client: string; topic: string; group: string; foreigners: string; }; jwt: { secret?: string; secretAuth?: string; public?: string; expire: string; expireRefresh: string; }; paths: { logger?: string; }; cache?: { type: 'redis' | 'memory' | 'memcached' | string; host?: string; port?: number | string; password?: string; db?: number; ttl?: number; // durée de vie par défaut en secondes url?: string; // pour les connexions Redis via URL [key: string]: any; // pour l'extensibilité }; } export interface IDefines { status: { // Codes de Succès (2xx) requestOK: number; created: number; accepted: number; noContent: number; // Codes de Redirection (3xx) movedPerm: number; found: number; seeOther: number; notModified: number; tempRedirect: number; permRedirect: number; // Codes d'Erreur Client (4xx) badRequest: number; authError: number; forbidden: number; notFound: number; notAllowed: number; notAcceptable: number; conflict: number; gone: number; lengthReq: number; precondFailed: number; payloadLarge: number; uriTooLong: number; unsupported: number; rangeInvalid: number; clientError: number; locked: number; tooEarly: number; tooMany: number; headerLarge: number; legalReasons: number; unauthorized: number; // Codes d'Erreur Serveur (5xx) serverError: number; notImpl: number; badGateway: number; unavailable: number; gatewayTimeout: number; httpVersion: number; variantAlso: number; insuffStorage: number; loopDetected: number; bandwidthLimit: number; }; message: { // Messages Génériques tryCatch: string; validation: string; timeout: string; // Messages 2xx requestOK: string; created: string; accepted: string; noContent: string; // Messages 3xx movedPerm: string; found: string; seeOther: string; notModified: string; // Messages 4xx badRequest: string; unauthorized: string; authError: string; forbidden: string; notFound: string; notAllowed: string; notAcceptable: string; conflict: string; gone: string; lengthReq: string; precondFailed: string; payloadLarge: string; uriTooLong: string; unsupported: string; rangeInvalid: string; clientError: string; locked: string; tooEarly: string; tooMany: string; headerLarge: string; legalReasons: string; // Messages 5xx serverError: string; notImpl: string; badGateway: string; unavailable: string; gatewayTimeout: string; httpVersion: string; variantAlso: string; insuffStorage: string; loopDetected: string; bandwidthLimit: string; }; tryCatchObject: (data: any) => { data: any; error: boolean; message: string; }; controlerTryCatchObject: { status: number; message: string; }; }