create runs table
This commit is contained in:
33
backend/routes/runs/new.js
Normal file
33
backend/routes/runs/new.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const { DataTypes } = require("sequelize");
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
router.post("/", async (req, res) => {
|
||||
try {
|
||||
const { name, configurations, description, state, projectId } = req.body;
|
||||
if (!name || !projectId) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Name and projectId are required" });
|
||||
}
|
||||
|
||||
const newRun = await Run.create({
|
||||
name,
|
||||
configurations,
|
||||
description,
|
||||
state,
|
||||
projectId,
|
||||
});
|
||||
|
||||
res.json(newRun);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Internal server error" });
|
||||
}
|
||||
});
|
||||
|
||||
return router;
|
||||
};
|
||||
Reference in New Issue
Block a user