create cases table

This commit is contained in:
Takeshi Kimata
2024-02-12 18:47:39 +09:00
parent b23922c8e5
commit 291bad6d56
9 changed files with 255 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
const express = require("express");
const router = express.Router();
const defineCase = require("../../models/cases");
const { DataTypes } = require("sequelize");
module.exports = function (sequelize) {
const Case = defineCase(sequelize, DataTypes);
router.post("/", async (req, res) => {
try {
const { title, state, priority, type, automationStatus, description, template, preConditions, expectedResults, folderId } = req.body;
if (!title || !state || !priority || !type || !automationStatus || !template || !folderId) {
return res.status(400).json({ error: "Title, state, priority, type, automationStatus, template, and folderId are required" });
}
const newCase = await Case.create({
title,
state,
priority,
type,
automationStatus,
description,
template,
preConditions,
expectedResults,
folderId,
});
res.json(newCase);
} catch (error) {
res.status(500).json({ error: "Internal server error" });
}
});
return router;
};