diff --git a/.env.compile b/.env.compile index 4eb0025..2b866df 100644 --- a/.env.compile +++ b/.env.compile @@ -141,10 +141,10 @@ ROUTE_USER = "/users" SQL_OK = "Connexion au serveur reussie !" SQL_KO = "Connexion au serveur echouée !" -STRING_MAX = 200 +STRING_MAX = 250 STRING_MIN = 2 -TEXT_MAX = 10000 +TEXT_MAX = 65000 TEXT_MIN = 5 USER_CREATED = "User created !" diff --git a/controller/ArticleCtrl.js b/controller/ArticleCtrl.js index 62a4946..3ffb234 100644 --- a/controller/ArticleCtrl.js +++ b/controller/ArticleCtrl.js @@ -35,9 +35,9 @@ exports.checkArticleData = (name, text, alt, cat, res) => { const IS_NAME_CHECKED = nem.checkRange(name, STRING_MIN, STRING_MAX); const IS_TEXT_CHECKED = nem.checkRange(text, TEXT_MIN, TEXT_MAX); const IS_ALT_CHECKED = nem.checkRange(alt, STRING_MIN, STRING_MAX); - const ID_CAT_CHECKED = nem.checkRange(cat, STRING_MIN, STRING_MAX); + const IS_CAT_CHECKED = nem.checkRange(cat, STRING_MIN, STRING_MAX); - if (!IS_NAME_CHECKED || !IS_TEXT_CHECKED || !IS_ALT_CHECKED || !ID_CAT_CHECKED) { + if (!IS_NAME_CHECKED || !IS_TEXT_CHECKED || !IS_ALT_CHECKED || !IS_CAT_CHECKED) { return res.status(403).json({ message: CHECK_CAT || CHECK_NAME || CHECK_TEXT || CHECK_NAME }); diff --git a/data/DBTables.sql b/data/DBTables.sql index 7d5a025..654869c 100644 --- a/data/DBTables.sql +++ b/data/DBTables.sql @@ -5,56 +5,56 @@ USE nens; CREATE TABLE Articles( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, + name VARCHAR(250) NOT NULL UNIQUE, text TEXT NOT NULL UNIQUE, - image VARCHAR(200) NOT NULL UNIQUE, - alt VARCHAR(200) NOT NULL, + image VARCHAR(250) NOT NULL UNIQUE, + alt VARCHAR(250) NOT NULL, likes TEXT NOT NULL, - cat VARCHAR(20) NOT NULL, + cat VARCHAR(25) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE Galleries( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, - author VARCHAR(200) NOT NULL, - cover VARCHAR(200) NOT NULL UNIQUE) + name VARCHAR(250) NOT NULL UNIQUE, + author VARCHAR(250) NOT NULL, + cover VARCHAR(250) NOT NULL UNIQUE) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE Images( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, - description VARCHAR(200) NOT NULL, + name VARCHAR(250) NOT NULL UNIQUE, + description VARCHAR(250) NOT NULL, galleryId SMALLINT UNSIGNED NOT NULL, CONSTRAINT fk_galleryId FOREIGN KEY (galleryId) REFERENCES Galleries(id)) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE Links( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, - url VARCHAR(200) NOT NULL UNIQUE, - cat VARCHAR(20) NOT NULL) + name VARCHAR(250) NOT NULL UNIQUE, + url VARCHAR(250) NOT NULL UNIQUE, + cat VARCHAR(25) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE Products( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, + name VARCHAR(250) NOT NULL UNIQUE, description TEXT NOT NULL UNIQUE, - image VARCHAR(200) NOT NULL UNIQUE, - alt VARCHAR(200) NOT NULL, + image VARCHAR(250) NOT NULL UNIQUE, + alt VARCHAR(250) NOT NULL, price DECIMAL NOT NULL, options TEXT NOT NULL, - cat VARCHAR(20) NOT NULL) + cat VARCHAR(25) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE Users( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(200) NOT NULL UNIQUE, - email VARCHAR(200) NOT NULL UNIQUE, - image VARCHAR(200) NOT NULL UNIQUE, - pass VARCHAR(200) NOT NULL, - role VARCHAR(20) NOT NULL, + name VARCHAR(250) NOT NULL UNIQUE, + email VARCHAR(250) NOT NULL UNIQUE, + image VARCHAR(250) NOT NULL UNIQUE, + pass VARCHAR(250) NOT NULL, + role VARCHAR(25) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8; @@ -63,8 +63,8 @@ CREATE TABLE Orders( id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, products TEXT NOT NULL, total DECIMAL NOT NULL, - paymentId VARCHAR(200) NOT NULL UNIQUE, - status VARCHAR(20) NOT NULL, + paymentId VARCHAR(250) NOT NULL UNIQUE, + status VARCHAR(25) NOT NULL, userId SMALLINT UNSIGNED NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, diff --git a/model/ArticleModel.js b/model/ArticleModel.js index caa35f9..aa39036 100644 --- a/model/ArticleModel.js +++ b/model/ArticleModel.js @@ -18,7 +18,7 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, @@ -28,12 +28,12 @@ module.exports = (Sequelize, DataTypes) => { unique: true }, image: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, alt: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false }, likes: { @@ -41,7 +41,7 @@ module.exports = (Sequelize, DataTypes) => { defaultValue: "[]" }, cat: { - type: DataTypes.STRING(20), + type: DataTypes.STRING(25), allowNull: false }, }, { diff --git a/model/GalleryModel.js b/model/GalleryModel.js index 8788ef7..0e73193 100644 --- a/model/GalleryModel.js +++ b/model/GalleryModel.js @@ -18,16 +18,16 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, author: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false }, cover: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true } diff --git a/model/ImageModel.js b/model/ImageModel.js index 62e6a9b..e08ba86 100644 --- a/model/ImageModel.js +++ b/model/ImageModel.js @@ -18,12 +18,12 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, description: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false }, galleryId: { diff --git a/model/LinkModel.js b/model/LinkModel.js index 58c6246..0f7de79 100644 --- a/model/LinkModel.js +++ b/model/LinkModel.js @@ -18,17 +18,17 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, url: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, cat: { - type: DataTypes.STRING(20), + type: DataTypes.STRING(25), allowNull: false } }, { diff --git a/model/OrderModel.js b/model/OrderModel.js index edc5bf8..81b734a 100644 --- a/model/OrderModel.js +++ b/model/OrderModel.js @@ -26,12 +26,12 @@ module.exports = (Sequelize, DataTypes) => { allowNull: false }, paymentId: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, status: { - type: DataTypes.STRING(20), + type: DataTypes.STRING(25), allowNull: false }, userId: { diff --git a/model/ProductModel.js b/model/ProductModel.js index 8f688d3..5f8e2f7 100644 --- a/model/ProductModel.js +++ b/model/ProductModel.js @@ -18,7 +18,7 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, @@ -28,12 +28,12 @@ module.exports = (Sequelize, DataTypes) => { unique: true }, image: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, alt: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false }, price: { @@ -45,7 +45,7 @@ module.exports = (Sequelize, DataTypes) => { defaultValue: "" }, cat: { - type: DataTypes.STRING(20), + type: DataTypes.STRING(25), allowNull: false } }, { diff --git a/model/UserModel.js b/model/UserModel.js index 5347ab8..3c86589 100644 --- a/model/UserModel.js +++ b/model/UserModel.js @@ -18,26 +18,26 @@ module.exports = (Sequelize, DataTypes) => { autoIncrement: true }, name: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, email: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, image: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false, unique: true }, pass: { - type: DataTypes.STRING(200), + type: DataTypes.STRING(250), allowNull: false }, role: { - type: DataTypes.STRING(20), + type: DataTypes.STRING(25), allowNull: false }, }, { diff --git a/package-lock.json b/package-lock.json index 6132e7e..a09b0fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nens", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nens", - "version": "1.0.7", + "version": "1.0.8", "license": "Apache-2.0 License", "dependencies": { "bcrypt": "^5.1.0", diff --git a/package.json b/package.json index 31bd93f..38c5e2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nens", - "version": "1.0.7", + "version": "1.0.8", "description": "API with Node, Express, NemJS & SQL", "keywords": [ "api",