create-craftjs 2.0.4 → 2.0.6

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/bin/index.js CHANGED
@@ -81,9 +81,9 @@ const ask = (question) => {
81
81
  }
82
82
 
83
83
  const envContent = `APP_NAME="${projectName}"
84
- APP_SECRET=
84
+ HOST="localhost"
85
85
  BASE_URL="http://localhost:4444"
86
- BASE_API_URL="http://localhost:4444/api"
86
+ APP_SECRET=
87
87
  NODE_ENV="development"
88
88
  TZ="Asia/Jakarta"
89
89
  DATETIME_FORMAT="dd-MM-yyyy HH:mm:ss"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-craftjs",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
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"
@@ -22,21 +22,22 @@ COPY . .
22
22
  # Generate Prisma client
23
23
  RUN npx prisma generate
24
24
 
25
- # Generate key (sesuaikan dengan perintahmu)
25
+ # Generate key
26
26
  RUN node craft key:generate
27
27
 
28
- # Build project (jika ada)
28
+ # Build project
29
29
  RUN node craft build
30
30
 
31
31
 
32
32
  # Build stage untuk copy hasil build
33
33
  FROM base AS build
34
34
 
35
- # Nothing extra, base sudah berisi semua
36
35
 
37
36
  # Production image
38
37
  FROM node:22-slim AS production
39
38
 
39
+ RUN apt-get update && apt-get install -y tzdata openssl
40
+
40
41
  WORKDIR /usr/src/app
41
42
 
42
43
  # Copy package files untuk install production dependencies
@@ -4,5 +4,5 @@ services:
4
4
  image: ${APP_NAME}_image
5
5
  build: .
6
6
  ports:
7
- - "${PORT}:4444"
7
+ - "${PORT}:${PORT}"
8
8
  restart: always
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "craftjs",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "craftjs",
9
- "version": "2.0.4",
9
+ "version": "2.0.6",
10
10
  "license": "UNLICENSED",
11
11
  "dependencies": {
12
12
  "@prisma/adapter-mariadb": "^7.2.0",
@@ -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": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "keywords": [
6
6
  "express",
7
7
  "typescript",
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import "dotenv/config";
3
3
 
4
4
  const envSchema = z.object({
5
+ HOST: z.string().default("localhost"),
5
6
  APP_NAME: z.string().default("Craft JS"),
6
7
  APP_SECRET: z.string(),
7
8
  NODE_ENV: z
@@ -18,7 +19,6 @@ const envSchema = z.object({
18
19
  DATABASE_NAME: z.string(),
19
20
  DATABASE_CONNECTION_LIMIT: z.coerce.number().default(4444),
20
21
  BASE_URL: z.string().url(),
21
- BASE_API_URL: z.string().url(),
22
22
  CLIENT_URL: z
23
23
  .string()
24
24
  .optional()
@@ -13,6 +13,7 @@ import { setupSwagger } from "@utils/swagger";
13
13
  import { mainRouter } from "@routes/main-route";
14
14
 
15
15
  export const web = express();
16
+ web.set("trust proxy", true);
16
17
  // EJS View Engine Setup
17
18
  // web.set("view engine", "ejs");
18
19
  // web.set("views", path.join(__dirname, "..", "views"));
@@ -33,7 +34,9 @@ web.use(express.static("public"));
33
34
  web.use(httpLogger);
34
35
 
35
36
  // Swagger Setup
36
- setupSwagger(web);
37
+ if (env.NODE_ENV !== "production") {
38
+ setupSwagger("/api/docs", web);
39
+ }
37
40
 
38
41
  // Routes
39
42
  web.use(mainRouter);
@@ -11,9 +11,11 @@ async function startServer() {
11
11
  process.exit(0);
12
12
  }
13
13
  await connectDatabase();
14
- web.listen(env.PORT, () => {
15
- logger.info(`🚀 Server is listening on: ${env.BASE_URL}`);
16
- logger.info(`🔗 API Docs available at: ${env.BASE_API_URL}/docs`);
14
+ web.listen(env.PORT, env.HOST, () => {
15
+ logger.info(`🚀 Server is listening on: http://${env.HOST}:${env.PORT}`);
16
+ logger.info(
17
+ `🔗 API Docs available at: http://${env.HOST}:${env.PORT}/api/docs`
18
+ );
17
19
  });
18
20
  } catch (error) {
19
21
  process.exit(0);
@@ -133,13 +133,16 @@ const swaggerOptions: swaggerJSDoc.Options = {
133
133
  const swaggerSpec = swaggerJSDoc(swaggerOptions);
134
134
  const theme = new SwaggerTheme();
135
135
  const themeCss = theme.getBuffer("dark-monokai" as any);
136
- export function setupSwagger(app: Express) {
136
+ export function setupSwagger(pathUrl: string, app: Express) {
137
137
  app.use(
138
- "/api/docs",
138
+ pathUrl,
139
139
  swaggerUi.serve,
140
140
  swaggerUi.setup(swaggerSpec, {
141
141
  customCss: themeCss,
142
142
  customSiteTitle: `${formatAppNameForTitle(env.APP_NAME)} Api Documentation`,
143
+ swaggerOptions: {
144
+ deepLinking: true,
145
+ },
143
146
  })
144
147
  );
145
148
  }