Skip to content

Commit

Permalink
Merge pull request #7 from philippebeck/dev
Browse files Browse the repository at this point in the history
Release 0.1.5-alpha
  • Loading branch information
philippebeck authored Dec 6, 2023
2 parents b6aff4f + 0658cfd commit 47d138c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
12 changes: 10 additions & 2 deletions controller/ProductCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ exports.setImage = (name, newFilename) => {
exports.listProducts = (req, res) => {
Product
.findAll()
.then((products) => res.status(200).json(products))
.then((products) => {
for (const product of products) {
product.options = JSON.parse(product.options).join(",");
}
res.status(200).json(products);
})
.catch(() => res.status(404).json({ message: process.env.PRODUCTS_NOT_FOUND }));
};

Expand All @@ -163,7 +168,10 @@ exports.listProducts = (req, res) => {
exports.readProduct = (req, res) => {
Product
.findByPk(parseInt(req.params.id))
.then((product) => res.status(200).json(product))
.then((product) => {
product.options = JSON.parse(product.options).join(",");
res.status(200).json(product);
})
.catch(() => res.status(404).json({ message: process.env.PRODUCT_NOT_FOUND }));
}

Expand Down
5 changes: 1 addition & 4 deletions model/ImageModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

const { Sequelize, DataTypes } = require("sequelize");

const db = require("../model");
const Gallery = db.gallery;

/**
* ? IMAGE MODEL
* * Define the Image Model
Expand Down Expand Up @@ -37,7 +34,7 @@ module.exports = (Sequelize, DataTypes) => {
type: DataTypes.SMALLINT.UNSIGNED,
allowNull: false,
references: {
model: Gallery,
model: "Gallery",
key: "id",
}
}
Expand Down
5 changes: 1 addition & 4 deletions model/OrderModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

const { Sequelize, DataTypes } = require("sequelize");

const db = require("../model");
const User = db.user;

/**
* ? ORDER MODEL
* * Define the Order Model
Expand Down Expand Up @@ -47,7 +44,7 @@ module.exports = (Sequelize, DataTypes) => {
type: DataTypes.SMALLINT.UNSIGNED,
allowNull: false,
references: {
model: User,
model: "User",
key: "id",
},
},
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nens",
"version": "0.1.4-alpha",
"version": "0.1.5-alpha",
"description": "API with Node, Express, NemJS & SQL",
"keywords": [
"api",
Expand Down

0 comments on commit 47d138c

Please sign in to comment.