@moudle/-product 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/api/create-product.d.ts +3 -0
- package/dist/module/api/create-product.d.ts.map +1 -0
- package/dist/module/api/create-product.js +41 -0
- package/dist/module/api/create-product.js.map +1 -0
- package/dist/module/api/delete-product.d.ts +3 -0
- package/dist/module/api/delete-product.d.ts.map +1 -0
- package/dist/module/api/delete-product.js +37 -0
- package/dist/module/api/delete-product.js.map +1 -0
- package/dist/module/api/detail-product.d.ts +3 -0
- package/dist/module/api/detail-product.d.ts.map +1 -0
- package/dist/module/api/detail-product.js +36 -0
- package/dist/module/api/detail-product.js.map +1 -0
- package/dist/module/api/my-products.d.ts +3 -0
- package/dist/module/api/my-products.d.ts.map +1 -0
- package/dist/module/api/my-products.js +14 -0
- package/dist/module/api/my-products.js.map +1 -0
- package/dist/module/api/update-product.d.ts +3 -0
- package/dist/module/api/update-product.d.ts.map +1 -0
- package/dist/module/api/update-product.js +49 -0
- package/dist/module/api/update-product.js.map +1 -0
- package/dist/module/api.d.ts +13 -0
- package/dist/module/api.d.ts.map +1 -0
- package/dist/module/api.js +16 -0
- package/dist/module/api.js.map +1 -0
- package/dist/module/config-api.d.ts +9 -0
- package/dist/module/config-api.d.ts.map +1 -0
- package/dist/module/config-api.js +13 -0
- package/dist/module/config-api.js.map +1 -0
- package/dist/module/config-ui.d.ts +4 -0
- package/dist/module/config-ui.d.ts.map +1 -0
- package/dist/module/config-ui.js +9 -0
- package/dist/module/config-ui.js.map +1 -0
- package/dist/module/db.d.ts +11 -0
- package/dist/module/db.d.ts.map +1 -0
- package/dist/module/db.js +55 -0
- package/dist/module/db.js.map +1 -0
- package/dist/module/page/CreateProductPage.d.ts +2 -0
- package/dist/module/page/CreateProductPage.d.ts.map +1 -0
- package/dist/module/page/CreateProductPage.js +38 -0
- package/dist/module/page/CreateProductPage.js.map +1 -0
- package/dist/module/page/MyProductsPage.d.ts +2 -0
- package/dist/module/page/MyProductsPage.d.ts.map +1 -0
- package/dist/module/page/MyProductsPage.js +36 -0
- package/dist/module/page/MyProductsPage.js.map +1 -0
- package/dist/module/ui.d.ts +5 -0
- package/dist/module/ui.d.ts.map +1 -0
- package/dist/module/ui.js +11 -0
- package/dist/module/ui.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-product.d.ts","sourceRoot":"","sources":["../../../module/api/create-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK5C,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,iBA6BxE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create_product = create_product;
|
|
7
|
+
const config_api_1 = require("../config-api");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
|
10
|
+
async function create_product(request, response) {
|
|
11
|
+
const CreateProductRequest = zod_1.default.object({
|
|
12
|
+
image_url: zod_1.default.string(),
|
|
13
|
+
name: zod_1.default.string(),
|
|
14
|
+
price: zod_1.default.number(),
|
|
15
|
+
description: zod_1.default.string().nullable(),
|
|
16
|
+
});
|
|
17
|
+
let create_product_request;
|
|
18
|
+
try {
|
|
19
|
+
create_product_request = CreateProductRequest.parse(request.body);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof zod_1.default.ZodError) {
|
|
23
|
+
response.status(400).send(error.message);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const user = await config_api_1.CONFIG_API_PRODUCT.getUserFromAuthHeader(request.headers.authorization || '');
|
|
28
|
+
if (!user) {
|
|
29
|
+
response.status(401).send('Unauthorized');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const product = new db_1.Product();
|
|
33
|
+
product.id_user = user.id;
|
|
34
|
+
product.image_url = create_product_request.image_url;
|
|
35
|
+
product.name = create_product_request.name;
|
|
36
|
+
product.price = create_product_request.price;
|
|
37
|
+
product.description = create_product_request.description || '';
|
|
38
|
+
await product.save();
|
|
39
|
+
response.send(product);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=create-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-product.js","sourceRoot":"","sources":["../../../module/api/create-product.ts"],"names":[],"mappings":";;;;;AAKA,wCA6BC;AAjCD,8CAAmD;AACnD,8BAAgC;AAChC,8CAAoB;AAEb,KAAK,UAAU,cAAc,CAAC,OAAgB,EAAE,QAAkB;IACvE,MAAM,oBAAoB,GAAG,aAAC,CAAC,MAAM,CAAC;QACpC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACnC,CAAC,CAAC;IACH,IAAI,sBAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,sBAAsB,GAAG,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IAAC,OAAM,KAAK,EAAC,CAAC;QACb,IAAG,KAAK,YAAY,aAAC,CAAC,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,+BAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,YAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC1B,OAAO,CAAC,SAAS,GAAG,sBAAuB,CAAC,SAAS,CAAC;IACtD,OAAO,CAAC,IAAI,GAAG,sBAAuB,CAAC,IAAI,CAAC;IAC5C,OAAO,CAAC,KAAK,GAAG,sBAAuB,CAAC,KAAK,CAAC;IAC9C,OAAO,CAAC,WAAW,GAAG,sBAAuB,CAAC,WAAW,IAAI,EAAE,CAAC;IAChE,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-product.d.ts","sourceRoot":"","sources":["../../../module/api/delete-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK5C,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,iBAyBxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.delete_product = delete_product;
|
|
7
|
+
const config_api_1 = require("../config-api");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
|
10
|
+
async function delete_product(request, response) {
|
|
11
|
+
const DeleteProductRequest = zod_1.default.object({
|
|
12
|
+
id: zod_1.default.number()
|
|
13
|
+
});
|
|
14
|
+
let detail_product_request;
|
|
15
|
+
try {
|
|
16
|
+
detail_product_request = DeleteProductRequest.parse(request.params);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof zod_1.default.ZodError) {
|
|
20
|
+
response.status(400).send(error.message);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const user = await config_api_1.CONFIG_API_PRODUCT.getUserFromAuthHeader(request.headers.authorization || '');
|
|
25
|
+
if (!user) {
|
|
26
|
+
response.status(401).send('Unauthorized');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const product = await db_1.Product.findOneBy({ id_user: user.id, id: detail_product_request.id });
|
|
30
|
+
if (!product) {
|
|
31
|
+
response.status(400).send('Product not found');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await product.remove();
|
|
35
|
+
response.send(true);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=delete-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-product.js","sourceRoot":"","sources":["../../../module/api/delete-product.ts"],"names":[],"mappings":";;;;;AAKA,wCAyBC;AA7BD,8CAAmD;AACnD,8BAAgC;AAChC,8CAAoB;AAEb,KAAK,UAAU,cAAc,CAAC,OAAgB,EAAE,QAAkB;IACvE,MAAM,oBAAoB,GAAG,aAAC,CAAC,MAAM,CAAC;QACpC,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE;KACf,CAAC,CAAC;IACH,IAAI,sBAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,sBAAsB,GAAG,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAAC,OAAM,KAAK,EAAC,CAAC;QACb,IAAG,KAAK,YAAY,aAAC,CAAC,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,+BAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,YAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,sBAAuB,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail-product.d.ts","sourceRoot":"","sources":["../../../module/api/detail-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK5C,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,iBAwBxE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.detail_product = detail_product;
|
|
7
|
+
const config_api_1 = require("../config-api");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
|
10
|
+
async function detail_product(request, response) {
|
|
11
|
+
const DetailProductRequest = zod_1.default.object({
|
|
12
|
+
id: zod_1.default.number()
|
|
13
|
+
});
|
|
14
|
+
let detail_product_request;
|
|
15
|
+
try {
|
|
16
|
+
detail_product_request = DetailProductRequest.parse(request.params);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof zod_1.default.ZodError) {
|
|
20
|
+
response.status(400).send(error.message);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const user = await config_api_1.CONFIG_API_PRODUCT.getUserFromAuthHeader(request.headers.authorization || '');
|
|
25
|
+
if (!user) {
|
|
26
|
+
response.status(401).send('Unauthorized');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const product = await db_1.Product.findOneBy({ id_user: user.id, id: detail_product_request.id });
|
|
30
|
+
if (!product) {
|
|
31
|
+
response.status(400).send('Product not found');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
response.send(product);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=detail-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail-product.js","sourceRoot":"","sources":["../../../module/api/detail-product.ts"],"names":[],"mappings":";;;;;AAKA,wCAwBC;AA5BD,8CAAmD;AACnD,8BAAgC;AAChC,8CAAoB;AAEb,KAAK,UAAU,cAAc,CAAC,OAAgB,EAAE,QAAkB;IACvE,MAAM,oBAAoB,GAAG,aAAC,CAAC,MAAM,CAAC;QACpC,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE;KACf,CAAC,CAAC;IACH,IAAI,sBAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,sBAAsB,GAAG,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAAC,OAAM,KAAK,EAAC,CAAC;QACb,IAAG,KAAK,YAAY,aAAC,CAAC,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,+BAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,YAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,sBAAuB,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"my-products.d.ts","sourceRoot":"","sources":["../../../module/api/my-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,iBAOrE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.my_products = my_products;
|
|
4
|
+
const config_api_1 = require("../config-api");
|
|
5
|
+
const db_1 = require("../db");
|
|
6
|
+
async function my_products(request, response) {
|
|
7
|
+
const user = await config_api_1.CONFIG_API_PRODUCT.getUserFromAuthHeader(request.headers.authorization || '');
|
|
8
|
+
if (!user) {
|
|
9
|
+
response.status(401).send('Unauthorized');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
response.send(await db_1.Product.findBy({ id_user: user.id }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=my-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"my-products.js","sourceRoot":"","sources":["../../../module/api/my-products.ts"],"names":[],"mappings":";;AAIA,kCAOC;AAVD,8CAAmD;AACnD,8BAAgC;AAEzB,KAAK,UAAU,WAAW,CAAC,OAAgB,EAAE,QAAkB;IACpE,MAAM,IAAI,GAAG,MAAM,+BAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,MAAM,YAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-product.d.ts","sourceRoot":"","sources":["../../../module/api/update-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK5C,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,iBAqCxE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.update_product = update_product;
|
|
7
|
+
const config_api_1 = require("../config-api");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
|
10
|
+
async function update_product(request, response) {
|
|
11
|
+
const UpdateProductPathRequest = zod_1.default.object({
|
|
12
|
+
id: zod_1.default.number()
|
|
13
|
+
});
|
|
14
|
+
const UpdateProductBodyRequest = zod_1.default.object({
|
|
15
|
+
image_url: zod_1.default.string().nullable(),
|
|
16
|
+
name: zod_1.default.string().nullable(),
|
|
17
|
+
price: zod_1.default.number().nullable(),
|
|
18
|
+
description: zod_1.default.string().nullable(),
|
|
19
|
+
});
|
|
20
|
+
let update_product_path_request;
|
|
21
|
+
let update_product_body_request;
|
|
22
|
+
try {
|
|
23
|
+
update_product_path_request = UpdateProductPathRequest.parse(request.params);
|
|
24
|
+
update_product_body_request = UpdateProductBodyRequest.parse(request.body);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof zod_1.default.ZodError) {
|
|
28
|
+
response.status(400).send(error.message);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const user = await config_api_1.CONFIG_API_PRODUCT.getUserFromAuthHeader(request.headers.authorization || '');
|
|
33
|
+
if (!user) {
|
|
34
|
+
response.status(401).send('Unauthorized');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const product = await db_1.Product.findOneBy({ id: update_product_path_request.id, id_user: user.id });
|
|
38
|
+
if (!product) {
|
|
39
|
+
response.status(400).send('Product not found');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
product.image_url = update_product_body_request.image_url || product.image_url;
|
|
43
|
+
product.name = update_product_body_request.name || product.name;
|
|
44
|
+
product.price = update_product_body_request.price || product.price;
|
|
45
|
+
product.description = update_product_body_request.description || product.description;
|
|
46
|
+
await product.save();
|
|
47
|
+
response.send(product);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=update-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-product.js","sourceRoot":"","sources":["../../../module/api/update-product.ts"],"names":[],"mappings":";;;;;AAKA,wCAqCC;AAzCD,8CAAmD;AACnD,8BAAgC;AAChC,8CAAoB;AAEb,KAAK,UAAU,cAAc,CAAC,OAAgB,EAAE,QAAkB;IACvE,MAAM,wBAAwB,GAAG,aAAC,CAAC,MAAM,CAAC;QACxC,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE;KACf,CAAC,CAAC;IACH,MAAM,wBAAwB,GAAG,aAAC,CAAC,MAAM,CAAC;QACxC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,WAAW,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACnC,CAAC,CAAC;IACH,IAAI,2BAA2B,CAAC;IAChC,IAAI,2BAA2B,CAAC;IAChC,IAAI,CAAC;QACH,2BAA2B,GAAG,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7E,2BAA2B,GAAG,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAAC,OAAM,KAAK,EAAC,CAAC;QACb,IAAG,KAAK,YAAY,aAAC,CAAC,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,+BAAkB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,YAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,2BAA4B,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACnG,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IACD,OAAO,CAAC,SAAS,GAAG,2BAA4B,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;IAChF,OAAO,CAAC,IAAI,GAAG,2BAA4B,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IACjE,OAAO,CAAC,KAAK,GAAG,2BAA4B,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IACpE,OAAO,CAAC,WAAW,GAAG,2BAA4B,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IACtF,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { create_product } from "./api/create-product";
|
|
2
|
+
import { delete_product } from "./api/delete-product";
|
|
3
|
+
import { detail_product } from "./api/detail-product";
|
|
4
|
+
import { my_products } from "./api/my-products";
|
|
5
|
+
import { update_product } from "./api/update-product";
|
|
6
|
+
export declare const LIST_API_PRODUCT: {
|
|
7
|
+
'POST /api/product': typeof create_product;
|
|
8
|
+
'PUT /api/product/:id': typeof update_product;
|
|
9
|
+
'GET /api/product/:id': typeof detail_product;
|
|
10
|
+
'DELETE /api/product/:id': typeof delete_product;
|
|
11
|
+
'GET /api/products': typeof my_products;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../module/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIST_API_PRODUCT = void 0;
|
|
4
|
+
const create_product_1 = require("./api/create-product");
|
|
5
|
+
const delete_product_1 = require("./api/delete-product");
|
|
6
|
+
const detail_product_1 = require("./api/detail-product");
|
|
7
|
+
const my_products_1 = require("./api/my-products");
|
|
8
|
+
const update_product_1 = require("./api/update-product");
|
|
9
|
+
exports.LIST_API_PRODUCT = {
|
|
10
|
+
'POST /api/product': create_product_1.create_product,
|
|
11
|
+
'PUT /api/product/:id': update_product_1.update_product,
|
|
12
|
+
'GET /api/product/:id': detail_product_1.detail_product,
|
|
13
|
+
'DELETE /api/product/:id': delete_product_1.delete_product,
|
|
14
|
+
'GET /api/products': my_products_1.my_products,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../module/api.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AACtD,yDAAsD;AACtD,yDAAsD;AACtD,mDAAgD;AAChD,yDAAsD;AAEzC,QAAA,gBAAgB,GAAG;IAC9B,mBAAmB,EAAE,+BAAc;IACnC,sBAAsB,EAAE,+BAAc;IACtC,sBAAsB,EAAE,+BAAc;IACtC,yBAAyB,EAAE,+BAAc;IACzC,mBAAmB,EAAE,yBAAW;CACjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-api.d.ts","sourceRoot":"","sources":["../../module/config-api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AACD,eAAO,IAAI,kBAAkB;yCACgB,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAOzE,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_API_PRODUCT = void 0;
|
|
4
|
+
exports.CONFIG_API_PRODUCT = {
|
|
5
|
+
async getUserFromAuthHeader(authorization) {
|
|
6
|
+
return {
|
|
7
|
+
id: 1,
|
|
8
|
+
name: 'Andi',
|
|
9
|
+
email: 'andi@aa.aa'
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=config-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-api.js","sourceRoot":"","sources":["../../module/config-api.ts"],"names":[],"mappings":";;;AAKW,QAAA,kBAAkB,GAAG;IAC9B,KAAK,CAAC,qBAAqB,CAAC,aAAqB;QAC/C,OAAO;YACL,EAAE,EAAE,CAAC;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-ui.d.ts","sourceRoot":"","sources":["../../module/config-ui.ts"],"names":[],"mappings":"AAAA,eAAO,IAAI,iBAAiB;qBACT,MAAM;CAGxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-ui.js","sourceRoot":"","sources":["../../module/config-ui.ts"],"names":[],"mappings":";;;AAAW,QAAA,iBAAiB,GAAG;IAC7B,aAAa;QACX,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEntity } from "typeorm";
|
|
2
|
+
export declare class Product extends BaseEntity {
|
|
3
|
+
id: number;
|
|
4
|
+
id_user: number;
|
|
5
|
+
image_url: string;
|
|
6
|
+
name: string;
|
|
7
|
+
price: number;
|
|
8
|
+
description?: string;
|
|
9
|
+
created_at: Date;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../module/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,UAAU,EAAoB,MAAM,SAAS,CAAA;AAE9F,qBACa,OAAQ,SAAQ,UAAU;IAErC,EAAE,EAAG,MAAM,CAAC;IAGZ,OAAO,EAAG,MAAM,CAAC;IAGjB,SAAS,EAAG,MAAM,CAAC;IAGnB,IAAI,EAAG,MAAM,CAAC;IAGd,KAAK,EAAG,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,UAAU,EAAG,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Product = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let Product = class Product extends typeorm_1.BaseEntity {
|
|
15
|
+
id;
|
|
16
|
+
id_user;
|
|
17
|
+
image_url;
|
|
18
|
+
name;
|
|
19
|
+
price;
|
|
20
|
+
description;
|
|
21
|
+
created_at;
|
|
22
|
+
};
|
|
23
|
+
exports.Product = Product;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], Product.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ type: 'bigint' }),
|
|
30
|
+
__metadata("design:type", Number)
|
|
31
|
+
], Product.prototype, "id_user", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500 }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], Product.prototype, "image_url", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500 }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], Product.prototype, "name", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ type: 'bigint' }),
|
|
42
|
+
__metadata("design:type", Number)
|
|
43
|
+
], Product.prototype, "price", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], Product.prototype, "description", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
50
|
+
__metadata("design:type", Date)
|
|
51
|
+
], Product.prototype, "created_at", void 0);
|
|
52
|
+
exports.Product = Product = __decorate([
|
|
53
|
+
(0, typeorm_1.Entity)()
|
|
54
|
+
], Product);
|
|
55
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../module/db.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA8F;AAGvF,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,oBAAU;IAErC,EAAE,CAAU;IAGZ,OAAO,CAAU;IAGjB,SAAS,CAAU;IAGnB,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAAU;IAGrB,UAAU,CAAQ;CACnB,CAAA;AArBY,0BAAO;AAElB;IADC,IAAA,gCAAsB,GAAE;;mCACb;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;wCACV;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;0CACtB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;qCAC3B;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;sCACZ;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACpB;AAGrB;IADC,IAAA,0BAAgB,GAAE;8BACN,IAAI;2CAAC;kBApBP,OAAO;IADnB,IAAA,gBAAM,GAAE;GACI,OAAO,CAqBnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateProductPage.d.ts","sourceRoot":"","sources":["../../../module/page/CreateProductPage.tsx"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,4CAgEhC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateProductPage = CreateProductPage;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const config_ui_1 = require("../config-ui");
|
|
11
|
+
function CreateProductPage() {
|
|
12
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
13
|
+
const [new_product, setNewProduct] = (0, react_1.useState)({
|
|
14
|
+
image_url: '',
|
|
15
|
+
name: '',
|
|
16
|
+
price: 0
|
|
17
|
+
});
|
|
18
|
+
async function createProduct() {
|
|
19
|
+
try {
|
|
20
|
+
setLoading(true);
|
|
21
|
+
const res = await axios_1.default.post('/api/product', new_product, {
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: config_ui_1.CONFIG_UI_PRODUCT.getAuthHeader()
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
alert('Success');
|
|
27
|
+
window.location.href = '/my-products';
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
alert(err?.response.data.toString());
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
setLoading(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("input", { value: new_product.name, onChange: e => setNewProduct({ ...new_product, name: e.target.value }), placeholder: "Product Name" }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("input", { value: new_product.image_url, onChange: e => setNewProduct({ ...new_product, image_url: e.target.value }), placeholder: "Image URL" }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("input", { value: new_product.price, onChange: e => setNewProduct({ ...new_product, price: e.target.valueAsNumber }), placeholder: "Price", type: "number" }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("input", { value: new_product.description, onChange: e => setNewProduct({ ...new_product, description: e.target.value }), placeholder: "Description (optional)" }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("button", { onClick: createProduct, children: loading ? 'Loading' : 'Submit' }) })] }));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=CreateProductPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateProductPage.js","sourceRoot":"","sources":["../../../module/page/CreateProductPage.tsx"],"names":[],"mappings":";;;;;AAIA,8CAgEC;;AApED,kDAA0B;AAC1B,iCAA4C;AAC5C,4CAAiD;AAEjD,SAAgB,iBAAiB;IAC/B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAK1C;QACD,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;IAEH,KAAK,UAAU,aAAa;QAC1B,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE;gBACxD,OAAO,EAAE;oBACP,aAAa,EAAE,6BAAiB,CAAC,aAAa,EAAE;iBACjD;aACF,CAAC,CAAC;YACH,KAAK,CAAC,SAAS,CAAC,CAAC;YACjB,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,cAAc,CAAC;QACxC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvC,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,CACL,4CACE,0CACE,kCACE,KAAK,EAAE,WAAW,CAAC,IAAI,EACvB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EACtE,WAAW,EAAC,cAAc,GAAG,GAC3B,EACN,0CACE,kCACE,KAAK,EAAE,WAAW,CAAC,SAAS,EAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAC3E,WAAW,EAAC,WAAW,GAAG,GACxB,EACN,0CACE,kCACE,KAAK,EAAE,WAAW,CAAC,KAAK,EACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,EAC/E,WAAW,EAAC,OAAO,EACnB,IAAI,EAAC,QAAQ,GAAG,GACd,EACN,0CACE,kCACE,KAAK,EAAE,WAAW,CAAC,WAAW,EAC9B,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAC7E,WAAW,EAAC,wBAAwB,GAAG,GACrC,EACN,0CACE,mCAAQ,OAAO,EAAE,aAAa,YAC3B,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,GACxB,GACL,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MyProductsPage.d.ts","sourceRoot":"","sources":["../../../module/page/MyProductsPage.tsx"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,4CAgC7B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MyProductsPage = MyProductsPage;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const config_ui_1 = require("../config-ui");
|
|
11
|
+
function MyProductsPage() {
|
|
12
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
13
|
+
const [products, setProducts] = (0, react_1.useState)([]);
|
|
14
|
+
async function getData() {
|
|
15
|
+
try {
|
|
16
|
+
setLoading(true);
|
|
17
|
+
const res = await axios_1.default.get('/api/products', {
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: config_ui_1.CONFIG_UI_PRODUCT.getAuthHeader()
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
setProducts(res.data);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
alert(err?.response.data.toString());
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
getData();
|
|
33
|
+
}, []);
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("a", { href: '/create-product', children: "+ Create Product" }) }), (0, jsx_runtime_1.jsx)("pre", { style: { fontSize: 10 }, children: JSON.stringify(products, null, 2) })] }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=MyProductsPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MyProductsPage.js","sourceRoot":"","sources":["../../../module/page/MyProductsPage.tsx"],"names":[],"mappings":";;;;;AAIA,wCAgCC;;AApCD,kDAA0B;AAC1B,iCAA4C;AAC5C,4CAAiD;AAEjD,SAAgB,cAAc;IAC5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IAE7C,KAAK,UAAU,OAAO;QACpB,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,eAAe,EAAE;gBAC3C,OAAO,EAAE;oBACP,aAAa,EAAE,6BAAiB,CAAC,aAAa,EAAE;iBACjD;aACF,CAAC,CAAC;YACH,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvC,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,4CACE,0CACE,8BAAG,IAAI,EAAE,iBAAiB,iCAAsB,GAC5C,EACN,gCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,IACnE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../module/ui.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB;;;CAG7B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIST_PAGE_PRODUCT = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const CreateProductPage_1 = require("./page/CreateProductPage");
|
|
6
|
+
const MyProductsPage_1 = require("./page/MyProductsPage");
|
|
7
|
+
exports.LIST_PAGE_PRODUCT = {
|
|
8
|
+
'/my-products': (0, jsx_runtime_1.jsx)(MyProductsPage_1.MyProductsPage, {}),
|
|
9
|
+
'/create-product': (0, jsx_runtime_1.jsx)(CreateProductPage_1.CreateProductPage, {})
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../module/ui.tsx"],"names":[],"mappings":";;;;AAAA,gEAA6D;AAC7D,0DAAuD;AAE1C,QAAA,iBAAiB,GAAG;IAC/B,cAAc,EAAE,uBAAC,+BAAc,KAAG;IAClC,iBAAiB,EAAE,uBAAC,qCAAiB,KAAG;CACzC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moudle/-product",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/lib.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "npm run build && node dist",
|
|
11
|
+
"build": "rm -rf dist && tsc",
|
|
12
|
+
"typeorm": "typeorm-ts-node-commonjs",
|
|
13
|
+
"generate-migration": "npm run typeorm migration:generate -- $1 -d ./data-source.ts",
|
|
14
|
+
"migrate": "npm run typeorm migration:run -- -d ./data-source.ts"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/module",
|
|
18
|
+
"package.json"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@react-router/dev": "^7.15.1",
|
|
25
|
+
"@types/bcrypt": "^6.0.0",
|
|
26
|
+
"@types/cors": "^2.8.19",
|
|
27
|
+
"@types/express": "^5.0.6",
|
|
28
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
29
|
+
"@types/node": "^25.8.0",
|
|
30
|
+
"@types/react": "^19.2.14",
|
|
31
|
+
"@types/react-dom": "^19.2.3",
|
|
32
|
+
"@types/react-router-dom": "^5.3.3",
|
|
33
|
+
"ts-node": "^10.9.2",
|
|
34
|
+
"typescript": "^6.0.3"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@moudle/start": "^0.0.3",
|
|
38
|
+
"@react-router/express": "^7.15.1",
|
|
39
|
+
"axios": "^1.16.1",
|
|
40
|
+
"bcrypt": "^6.0.0",
|
|
41
|
+
"cors": "^2.8.6",
|
|
42
|
+
"express": "^5.2.1",
|
|
43
|
+
"jsonwebtoken": "^9.0.3",
|
|
44
|
+
"mysql2": "^3.22.3",
|
|
45
|
+
"react-dom": "^19.2.6",
|
|
46
|
+
"react-router-dom": "^7.15.1",
|
|
47
|
+
"reflect-metadata": "^0.2.2",
|
|
48
|
+
"typeorm": "^0.3.29",
|
|
49
|
+
"zod": "^4.4.3"
|
|
50
|
+
}
|
|
51
|
+
}
|