@epip/crud
Advanced tools
Comparing version
import { to } from "await-to-js"; | ||
import { DeepPartial, IsNull, Repository } from "typeorm"; | ||
import { IResponse, IResponseAll } from "../types"; | ||
import { Request } from "express"; | ||
@@ -8,3 +9,3 @@ export class BaseService<T> { | ||
public async getAll(): Promise<IResponseAll<T>> { | ||
public async getAll(req: Request): Promise<IResponseAll<T>> { | ||
const [err, results] = await to(this.repo.find({ | ||
@@ -29,3 +30,3 @@ where:{ | ||
public async get(id: number): Promise<IResponse<T>> { | ||
public async get(req: Request, id: number): Promise<IResponse<T>> { | ||
const [err, result] = await to( | ||
@@ -53,3 +54,3 @@ this.repo.findOne({ | ||
public async post(entity: T): Promise<IResponse<T>> { | ||
public async post(req: Request, entity: T): Promise<IResponse<T>> { | ||
(entity as any).insertedAt=new Date() | ||
@@ -71,5 +72,5 @@ const [err, result] = await to(this.repo.save(entity)); | ||
public async put(id: number, entity: T): Promise<IResponse<T>> { | ||
public async put(req: Request, id: number, entity: T): Promise<IResponse<T>> { | ||
(entity as any).insertedAt=new Date() | ||
let [err, results] = await to(this.get(id)); | ||
let [err, results] = await to(this.get(req, id)); | ||
if (err) { | ||
@@ -121,4 +122,4 @@ return { | ||
public async patch(id: number, entity: T): Promise<IResponse<T>> { | ||
let [err, results] = await to(this.get(id)); | ||
public async patch(req: Request, id: number, entity: T): Promise<IResponse<T>> { | ||
let [err, results] = await to(this.get(req, id)); | ||
if (err) { | ||
@@ -169,4 +170,4 @@ return { | ||
public async delete(id: number): Promise<IResponse<T>> { | ||
let [err, results] = await to(this.get(id)); | ||
public async delete(req: Request, id: number): Promise<IResponse<T>> { | ||
let [err, results] = await to(this.get(req, id)); | ||
if (err) { | ||
@@ -173,0 +174,0 @@ return { |
{ | ||
"name": "@epip/crud", | ||
"version": "1.0.53", | ||
"version": "1.0.54", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/common": "^8.0.6", | ||
"@nestjs/swagger": "^5.0.9", | ||
"@types/browserify": "latest", | ||
"@types/express": "^4.17.13", | ||
"await-to-js": "^3.0.0", | ||
"browserify": "latest", | ||
"typeorm": "^0.2.37", | ||
"typescript": "^4.4.2", | ||
"browserify": "latest", | ||
"@types/browserify": "latest" | ||
"typescript": "^4.4.2" | ||
}, | ||
@@ -16,0 +19,0 @@ "scripts": { |
258711
0.08%909
0.11%1
Infinity%8
14.29%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added