Introduce prettier

This commit is contained in:
Takeshi Kimata
2024-05-19 21:04:45 +09:00
parent cbb5993276
commit 75eeebefda
89 changed files with 872 additions and 944 deletions

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineStep = require("../../models/steps");
const defineCaseStep = require("../../models/caseSteps");
const { DataTypes, Op } = require("sequelize");
const defineStep = require('../../models/steps');
const defineCaseStep = require('../../models/caseSteps');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const Step = defineStep(sequelize, DataTypes);
const CaseStep = defineCaseStep(sequelize, DataTypes);
router.delete("/:stepId", async (req, res) => {
router.delete('/:stepId', async (req, res) => {
const stepId = req.params.stepId;
// TODO The caseId should not be specified from the front end, but should be traced from stepId by association.
const caseId = req.query.parentCaseId;
@@ -19,7 +19,7 @@ module.exports = function (sequelize) {
const step = await Step.findByPk(stepId);
if (!step) {
await t.rollback();
return res.status(404).send("Step not found");
return res.status(404).send('Step not found');
}
// Get caseStep to be deleted.
@@ -32,7 +32,7 @@ module.exports = function (sequelize) {
// Decrease stepNo for all caseSteps with greater than the caseStep to be deleted.
await CaseStep.update(
{ stepNo: sequelize.literal("stepNo - 1") },
{ stepNo: sequelize.literal('stepNo - 1') },
{
where: {
CaseId: caseId,
@@ -51,7 +51,7 @@ module.exports = function (sequelize) {
} catch (error) {
console.error(error);
await t.rollback();
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});

View File

@@ -1,14 +1,14 @@
const express = require("express");
const express = require('express');
const router = express.Router();
const defineStep = require("../../models/steps");
const defineCaseStep = require("../../models/caseSteps");
const { DataTypes, Op } = require("sequelize");
const defineStep = require('../../models/steps');
const defineCaseStep = require('../../models/caseSteps');
const { DataTypes, Op } = require('sequelize');
module.exports = function (sequelize) {
const Step = defineStep(sequelize, DataTypes);
const CaseStep = defineCaseStep(sequelize, DataTypes);
router.post("/", async (req, res) => {
router.post('/', async (req, res) => {
const newStepNo = req.query.newStepNo;
const caseId = req.query.parentCaseId;
@@ -16,13 +16,13 @@ module.exports = function (sequelize) {
try {
// Update existing stepNo for steps with stepNo greater than or equal to newStepNo
const maxStepNo = await CaseStep.max("stepNo", {
const maxStepNo = await CaseStep.max('stepNo', {
where: { caseId: caseId },
transaction: t,
});
if (maxStepNo >= newStepNo) {
await CaseStep.update(
{ stepNo: sequelize.literal("stepNo + 1") },
{ stepNo: sequelize.literal('stepNo + 1') },
{
where: {
caseId: caseId,
@@ -35,8 +35,8 @@ module.exports = function (sequelize) {
const newStep = await Step.create(
{
step: "",
result: "",
step: '',
result: '',
},
{ transaction: t }
);
@@ -55,7 +55,7 @@ module.exports = function (sequelize) {
} catch (error) {
console.error(error);
await t.rollback();
res.status(500).send("Internal Server Error");
res.status(500).send('Internal Server Error');
}
});