Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@epip/crud

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@epip/crud - npm Package Compare versions

Comparing version 1.0.44 to 1.0.45

53

core/services/base.service.ts
import { to } from "await-to-js";
import { DeepPartial, Repository } from "typeorm";
import { DeepPartial, IsNull, Repository } from "typeorm";
import { IResponse, IResponseAll } from "../types";

@@ -9,3 +9,7 @@

public async getAll(): Promise<IResponseAll<T>> {
const [err, results] = await to(this.repo.find({}));
const [err, results] = await to(this.repo.find({
where:{
deletedAt:IsNull()
}
}));
if (err) {

@@ -30,2 +34,3 @@ return {

id,
deletedAt:IsNull()
},

@@ -49,2 +54,3 @@ })

public async post(entity: T): Promise<IResponse<T>> {
(entity as any).insertedAt=new Date()
const [err, results] = await to(this.repo.save(entity));

@@ -66,2 +72,3 @@ if (err) {

public async put(id: number, entity: T): Promise<IResponse<T>> {
(entity as any).insertedAt=new Date()
let [err, results] = await to(this.get(id));

@@ -92,3 +99,4 @@ if (err) {

let res;
[err, res] = await to(this.repo.save(data));
(data as any).updatedAt=new Date();
[err, res] = await to(this.repo.update(id,data));
if (err) {

@@ -101,7 +109,13 @@ return {

return {
status: 200,
message: "ok",
results:res,
};
if(res?.affected){
return {
status: 200,
message: "ok",
};
}else{
return {
status: 500,
message: 'error !.',
} as IResponse<T>;
}
}

@@ -135,3 +149,4 @@

let res;
[err, res] = await to(this.repo.save(data));
(data as any).updatedAt=new Date();
[err, res] = await to(this.repo.update(id,data));
if (err) {

@@ -144,7 +159,13 @@ return {

return {
status: 200,
message: "ok",
results:res,
};
if(res?.affected){
return {
status: 200,
message: "ok",
};
}else{
return {
status: 500,
message: 'error !.',
} as IResponse<T>;
}
}

@@ -164,4 +185,4 @@

data = results?.results;
let [errDelete, resultsDelete] = await to(this.repo.softDelete(data));
(data as any).deletedAt=new Date();
let [errDelete, resultsDelete] = await to(this.repo.update(id,data));
if(errDelete){

@@ -168,0 +189,0 @@ return {

@@ -41,2 +41,3 @@ "use strict";

var await_to_js_1 = require("await-to-js");
var typeorm_1 = require("typeorm");
var BaseService = (function () {

@@ -51,3 +52,7 @@ function BaseService(repo) {

switch (_b.label) {
case 0: return [4, (0, await_to_js_1.to)(this.repo.find({}))];
case 0: return [4, (0, await_to_js_1.to)(this.repo.find({
where: {
deletedAt: (0, typeorm_1.IsNull)()
}
}))];
case 1:

@@ -78,2 +83,3 @@ _a = _b.sent(), err = _a[0], results = _a[1];

id: id,
deletedAt: (0, typeorm_1.IsNull)()
},

@@ -103,3 +109,5 @@ }))];

switch (_b.label) {
case 0: return [4, (0, await_to_js_1.to)(this.repo.save(entity))];
case 0:
entity.insertedAt = new Date();
return [4, (0, await_to_js_1.to)(this.repo.save(entity))];
case 1:

@@ -128,3 +136,5 @@ _a = _b.sent(), err = _a[0], results = _a[1];

switch (_c.label) {
case 0: return [4, (0, await_to_js_1.to)(this.get(id))];
case 0:
entity.insertedAt = new Date();
return [4, (0, await_to_js_1.to)(this.get(id))];
case 1:

@@ -153,3 +163,4 @@ _a = _c.sent(), err = _a[0], results = _a[1];

}
return [4, (0, await_to_js_1.to)(this.repo.save(data))];
data.updatedAt = new Date();
return [4, (0, await_to_js_1.to)(this.repo.update(id, data))];
case 2:

@@ -163,7 +174,15 @@ _b = _c.sent(), err = _b[0], res = _b[1];

}
return [2, {
status: 200,
message: "ok",
results: res,
}];
if (res === null || res === void 0 ? void 0 : res.affected) {
return [2, {
status: 200,
message: "ok",
}];
}
else {
return [2, {
status: 500,
message: 'error !.',
}];
}
return [2];
}

@@ -203,3 +222,4 @@ });

}
return [4, (0, await_to_js_1.to)(this.repo.save(data))];
data.updatedAt = new Date();
return [4, (0, await_to_js_1.to)(this.repo.update(id, data))];
case 2:

@@ -213,7 +233,15 @@ _b = _c.sent(), err = _b[0], res = _b[1];

}
return [2, {
status: 200,
message: "ok",
results: res,
}];
if (res === null || res === void 0 ? void 0 : res.affected) {
return [2, {
status: 200,
message: "ok",
}];
}
else {
return [2, {
status: 500,
message: 'error !.',
}];
}
return [2];
}

@@ -239,3 +267,4 @@ });

data = results === null || results === void 0 ? void 0 : results.results;
return [4, (0, await_to_js_1.to)(this.repo.softDelete(data))];
data.deletedAt = new Date();
return [4, (0, await_to_js_1.to)(this.repo.update(id, data))];
case 2:

@@ -242,0 +271,0 @@ _b = _c.sent(), errDelete = _b[0], resultsDelete = _b[1];

{
"name": "@epip/crud",
"version": "1.0.44",
"version": "1.0.45",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc