Skip to content

Commit 551f5a7

Browse files
committed
Refactor code structure for improved readability and maintainability
fixed planneritem return type
1 parent 7de889c commit 551f5a7

File tree

12 files changed

+6082
-4875
lines changed

12 files changed

+6082
-4875
lines changed

generateMigration.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
const { execSync } = require('child_process');
2-
const { format } = require('date-fns');
3-
const path = require('path');
4-
const fs = require('fs');
1+
const { execSync } = require("child_process");
2+
const { format } = require("date-fns");
3+
const path = require("path");
4+
const fs = require("fs");
55

66
try {
7-
const timestamp = format(new Date(), 'yyyyMMdd_HHmmss');
8-
const outputFile = path.join('migrations', `${timestamp}_update_schema.sql`);
9-
const command = `bunx prisma migrate diff --from-schema-datamodel ./src/prisma/schema.previous.prisma --to-schema-datamodel ./src/prisma/schema.prisma --script --output ${outputFile}`;
7+
const timestamp = format(new Date(), "yyyyMMdd_HHmmss");
8+
const outputFile = path.join("migrations", `${timestamp}_update_schema.sql`);
9+
const command = `bunx prisma migrate diff --from-schema-datamodel ./src/prisma/schema.previous.prisma --to-schema-datamodel ./src/prisma/schema.prisma --script --output ${outputFile}`;
1010

11-
execSync(command, { stdio: 'inherit' });
12-
console.log(`Generated migration file: ${outputFile}`);
13-
// copy schema.prisma to schema.previous.prisma
14-
const src = path.resolve(__dirname, 'src/prisma/schema.prisma');
15-
const dest = path.resolve(__dirname, 'src/prisma/schema.previous.prisma');
16-
fs.copyFileSync(src, dest);
17-
console.log('Updated schema.previous.prisma with the current schema.prisma');
11+
execSync(command, { stdio: "inherit" });
12+
console.log(`Generated migration file: ${outputFile}`);
13+
// copy schema.prisma to schema.previous.prisma
14+
const src = path.resolve(__dirname, "src/prisma/schema.prisma");
15+
const dest = path.resolve(__dirname, "src/prisma/schema.previous.prisma");
16+
fs.copyFileSync(src, dest);
17+
console.log("Updated schema.previous.prisma with the current schema.prisma");
1818
} catch (error) {
19-
console.error('Error generating migration:', error.message);
20-
process.exit(1);
21-
}
19+
console.error("Error generating migration:", error.message);
20+
process.exit(1);
21+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
"peerDependencies": {
4444
"typescript": "^5"
4545
}
46-
}
46+
}

prisma.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as path from 'path'
2-
import type { PrismaConfig } from 'prisma'
1+
import * as path from "path";
2+
import type { PrismaConfig } from "prisma";
33

44
export default {
5-
earlyAccess: true,
6-
schema: path.join('src', 'prisma', 'schema.prisma'),
7-
} satisfies PrismaConfig
5+
earlyAccess: true,
6+
schema: path.join("src", "prisma", "schema.prisma"),
7+
} satisfies PrismaConfig;

src/aca-calendar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const app = new Hono()
4444
"Failed to fetch data " + res.status + (await res.text()),
4545
);
4646
}
47-
const resJson = await res.json() as any;
47+
const resJson = (await res.json()) as any;
4848
if (resJson.success === false) {
4949
throw new Error("Failed to fetch data " + resJson.result);
5050
}

src/headless-ais/inthu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const app = new Hono()
9999
}),
100100
keepalive: true,
101101
});
102-
const json = await response.json() as any;
102+
const json = (await response.json()) as any;
103103
const myHeaders = new Headers();
104104
myHeaders.append("Authorization", `Bearer ${json.Data.AccessToken}`);
105105
myHeaders.append("DeviceID", uuid);

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import planner from "./planner-replication";
1313
import type { D1Database } from "@cloudflare/workers-types";
1414

1515
export type Bindings = {
16-
DB: D1Database
17-
}
16+
DB: D1Database;
17+
};
1818

1919
export const app = new Hono<{ Bindings: Bindings }>()
2020
.use(

src/issue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const getInstallationAccessToken = async (
107107
},
108108
},
109109
);
110-
const data = await response.json() as { token: string; expires_at: string };
110+
const data = (await response.json()) as { token: string; expires_at: string };
111111

112112
return data.token;
113113
};
@@ -151,7 +151,7 @@ const app = new Hono()
151151
body: JSON.stringify({ title, body, labels }),
152152
},
153153
);
154-
const data = await response.json() as GithubIssue;
154+
const data = (await response.json()) as GithubIssue;
155155
return c.json(data);
156156
},
157157
)

0 commit comments

Comments
 (0)