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.35 to 1.0.36

12

core/decorators/swg-crud.decorator.ts

@@ -65,2 +65,14 @@ import { applyDecorators, Get, Type } from "@nestjs/common";

export const ApiPatch = <TModel extends Type<any>>(
model: TModel,
path?: string
) => {
return applyDecorators(
Get(path || "/"),
ApiOkResponse({
type: model,
})
);
};
export const ApiDelete = <TModel extends Type<any>>(

@@ -67,0 +79,0 @@ model: TModel,

@@ -143,2 +143,37 @@ import { to } from "await-to-js";

}
public async delete(id: number): Promise<IResponse<DeepPartial<T>>> {
let [err, results] = await to(this.get(id));
if (err) {
return {
status: 500,
message: err.message,
} as IResponse<T>;
}
let data: DeepPartial<T>;
if (results?.results) {
data = results?.results;
let [errDelete, resultsDelete] = await to(this.repo.softDelete(data));
if(errDelete){
return {
status: 500,
message: "not found record",
} as IResponse<T>;
}else{
return {
status: 200,
message: "ok",
results:resultsDelete
} as IResponse<T>;
}
}else{
return {
status: 404,
message: "not found record",
} as IResponse<T>;
}
}
}

1

dist/decorators/swg-crud.decorator.d.ts

@@ -6,3 +6,4 @@ import { Type } from "@nestjs/common";

export declare const ApiPut: <TModel extends Type<any>>(model: TModel, path?: string | undefined) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
export declare const ApiPatch: <TModel extends Type<any>>(model: TModel, path?: string | undefined) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
export declare const ApiDelete: <TModel extends Type<any>>(model: TModel, path?: string | undefined) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
//# sourceMappingURL=swg-crud.decorator.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiDelete = exports.ApiPut = exports.ApiPost = exports.ApiGet = exports.ApiGetAll = void 0;
exports.ApiDelete = exports.ApiPatch = exports.ApiPut = exports.ApiPost = exports.ApiGet = exports.ApiGetAll = void 0;
var common_1 = require("@nestjs/common");

@@ -43,2 +43,8 @@ var swagger_1 = require("@nestjs/swagger");

exports.ApiPut = ApiPut;
var ApiPatch = function (model, path) {
return (0, common_1.applyDecorators)((0, common_1.Get)(path || "/"), (0, swagger_1.ApiOkResponse)({
type: model,
}));
};
exports.ApiPatch = ApiPatch;
var ApiDelete = function (model, path) {

@@ -45,0 +51,0 @@ return (0, common_1.applyDecorators)((0, common_1.Get)(path || "/"), (0, swagger_1.ApiOkResponse)({

@@ -11,3 +11,4 @@ import { DeepPartial, Repository } from "typeorm";

patch(id: number, entity: DeepPartial<T>): Promise<IResponse<DeepPartial<T>>>;
delete(id: number): Promise<IResponse<DeepPartial<T>>>;
}
//# sourceMappingURL=base.service.d.ts.map

@@ -214,2 +214,44 @@ "use strict";

};
BaseService.prototype.delete = function (id) {
return __awaiter(this, void 0, void 0, function () {
var _a, err, results, data, _b, errDelete, resultsDelete;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, (0, await_to_js_1.to)(this.get(id))];
case 1:
_a = _c.sent(), err = _a[0], results = _a[1];
if (err) {
return [2, {
status: 500,
message: err.message,
}];
}
if (!(results === null || results === void 0 ? void 0 : results.results)) return [3, 3];
data = results === null || results === void 0 ? void 0 : results.results;
return [4, (0, await_to_js_1.to)(this.repo.softDelete(data))];
case 2:
_b = _c.sent(), errDelete = _b[0], resultsDelete = _b[1];
if (errDelete) {
return [2, {
status: 500,
message: "not found record",
}];
}
else {
return [2, {
status: 200,
message: "ok",
results: resultsDelete
}];
}
return [3, 4];
case 3: return [2, {
status: 404,
message: "not found record",
}];
case 4: return [2];
}
});
});
};
return BaseService;

@@ -216,0 +258,0 @@ }());

4

package.json
{
"name": "@epip/crud",
"version": "1.0.35",
"version": "1.0.36",
"description": "",

@@ -18,3 +18,3 @@ "main": "index.js",

"build": "tsc -p tsconfig.json",
"app": "tsc -p tsconfig.json && npm version patch && npm publish --access public"
"pub": "tsc -p tsconfig.json && npm version patch && npm publish --access public"
},

@@ -21,0 +21,0 @@ "repository": {

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

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