UNPKG

@capimjs/library-auth

Version:

Professional API using Clean Architecture and TDD. to group validators

1 lines 803 B
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:all[name]})}_export(exports,{ok:()=>ok,badRequest:()=>badRequest,unauthorized:()=>unauthorized,notFound:()=>notFound,forbidden:()=>forbidden,serverError:()=>serverError});const _errors=require("../errors");const ok=data=>({statusCode:200,data});const badRequest=error=>({statusCode:400,data:error});const unauthorized=()=>({statusCode:401,data:new _errors.UnauthorizedError});const notFound=()=>({statusCode:401,data:new _errors.NotFoundError});const forbidden=()=>({statusCode:403,data:new _errors.ForbiddenError});const serverError=error=>({statusCode:500,data:new _errors.ServerError(error instanceof Error?error:undefined)});