Merge branch 'main' of https://github.com/Wind-Explorer/ecoconnect
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Post = sequelize.define("Post", {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
allowNull: false,
|
||||
primaryKey: true,
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false
|
||||
},
|
||||
postImage: {
|
||||
type: DataTypes.BLOB("long"),
|
||||
allowNull: true,
|
||||
},
|
||||
content: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
|
||||
@@ -3,6 +3,8 @@ const router = express.Router();
|
||||
const { Post } = require('../models');
|
||||
const { Op, where } = require("sequelize");
|
||||
const yup = require("yup");
|
||||
const multer = require("multer");
|
||||
const sharp = require("sharp");
|
||||
|
||||
// Profanity function
|
||||
const Filter = require('bad-words'); // Import the bad-words library
|
||||
@@ -19,7 +21,8 @@ router.post("/", async (req, res) => {
|
||||
// Validate request body
|
||||
let validationSchema = yup.object({
|
||||
title: yup.string().trim().min(3).max(200).required(), // yup object to define validation schema
|
||||
content: yup.string().trim().min(3).max(500).required()
|
||||
content: yup.string().trim().min(3).max(500).required(),
|
||||
postImage: yup.string().trim().max(255),
|
||||
});
|
||||
try {
|
||||
data = await validationSchema.validate(data, // validate() method is used to validate data against the schema and returns the valid data and any applied transformations
|
||||
|
||||
Reference in New Issue
Block a user