create-craftjs 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,7 +61,7 @@ cd my-app
61
61
  ```bash
62
62
  npm install
63
63
  node craft key:generate
64
- node craft generate
64
+ node craft db:generate
65
65
  node craft db:migrate
66
66
  node craft dev
67
67
  ```
package/bin/index.js CHANGED
@@ -66,6 +66,12 @@ const ask = (question) => {
66
66
  console.log(`\n🚧 Creating project in ./${projectName}...`);
67
67
  copyRecursiveSync(templatePath, targetPath);
68
68
 
69
+ const logsPath = path.join(targetPath, "logs");
70
+ if (!fs.existsSync(logsPath)) {
71
+ fs.mkdirSync(logsPath, { recursive: true });
72
+ console.log("šŸ“ Generating logs folder...");
73
+ }
74
+
69
75
  const packageJsonPath = path.join(targetPath, "package.json");
70
76
  if (fs.existsSync(packageJsonPath)) {
71
77
  const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-craftjs",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A starter kit backend framework powered by Express, TypeScript, EJS Engine, and Prisma — designed for rapid development, simplicity, and scalability.",
5
5
  "bin": {
6
6
  "create-craftjs": "bin/index.js"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "craftjs",
3
3
  "description": "A starter kit backend framework powered by Express, TypeScript, EJS Engine, and Prisma — designed for rapid development, simplicity, and scalability.",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "keywords": [
6
6
  "express",
7
7
  "typescript",
@@ -25,47 +25,7 @@ export const prismaClient = new PrismaClient({
25
25
  ],
26
26
  });
27
27
 
28
- prismaClient.$use(async (params, next) => {
29
- const result = await next(params);
30
28
 
31
- const convertToYourTimeZone = (date: unknown): string => {
32
- if (!(date instanceof Date) || isNaN(date.getTime())) {
33
- return "";
34
- }
35
-
36
- return DateTime.fromJSDate(date)
37
- .setZone(env.TZ || "UTC")
38
- .toFormat(env.DATETIME_FORMAT);
39
- };
40
-
41
- const transformDates = (item: any): any => {
42
- if (!item) return item;
43
-
44
- if (Array.isArray(item)) {
45
- return item.map(transformDates);
46
- }
47
-
48
- if (typeof item === "object") {
49
- const newItem: any = { ...item };
50
- for (const key in newItem) {
51
- const value = newItem[key];
52
- if (
53
- ["created_at", "updated_at", "deleted_at"].includes(key) &&
54
- value instanceof Date
55
- ) {
56
- newItem[key] = convertToYourTimeZone(value);
57
- } else if (typeof value === "object" && value !== null) {
58
- newItem[key] = transformDates(value);
59
- }
60
- }
61
- return newItem;
62
- }
63
-
64
- return item;
65
- };
66
-
67
- return transformDates(result);
68
- });
69
29
 
70
30
  prismaClient.$on("query", (e) => {
71
31
  dbLogger.info(`${e.query} - ${e.params}`);
@@ -0,0 +1,10 @@
1
+ import { DateTime } from "luxon";
2
+ import { env } from "../config/env";
3
+
4
+ export function formatTime(date: Date): string {
5
+ if (!(date instanceof Date)) return "";
6
+
7
+ return DateTime.fromJSDate(date, { zone: "utc" })
8
+ .setZone(env.TZ)
9
+ .toFormat(env.DATETIME_FORMAT);
10
+ }