@techstream/quark-create-app 1.2.0 → 1.4.0
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/package.json +34 -33
- package/src/index.js +193 -56
- package/templates/base-project/apps/web/src/app/api/auth/register/route.js +17 -1
- package/templates/base-project/apps/web/src/app/api/error-handler.js +4 -2
- package/templates/base-project/apps/web/src/app/api/health/route.js +8 -3
- package/templates/base-project/apps/web/src/app/api/posts/[id]/route.js +9 -5
- package/templates/base-project/apps/web/src/app/api/posts/route.js +13 -5
- package/templates/base-project/apps/web/src/app/api/users/[id]/route.js +9 -9
- package/templates/base-project/apps/web/src/app/api/users/route.js +6 -6
- package/templates/base-project/apps/web/src/lib/auth-middleware.js +18 -1
- package/templates/base-project/apps/web/src/{middleware.js → proxy.js} +3 -3
- package/templates/base-project/apps/worker/package.json +1 -2
- package/templates/base-project/apps/worker/src/index.js +71 -19
- package/templates/base-project/docker-compose.yml +3 -6
- package/templates/base-project/package.json +16 -1
- package/templates/base-project/packages/db/package.json +10 -4
- package/templates/base-project/packages/db/prisma.config.ts +2 -2
- package/templates/base-project/packages/db/scripts/seed.js +1 -1
- package/templates/base-project/packages/db/src/client.js +41 -25
- package/templates/base-project/packages/db/src/queries.js +22 -9
- package/templates/base-project/packages/db/src/schemas.js +6 -1
- package/templates/base-project/turbo.json +17 -1
- package/templates/config/package.json +3 -1
- package/templates/config/src/app-url.js +71 -0
- package/templates/config/src/validate-env.js +104 -0
- package/templates/base-project/packages/db/src/generated/prisma/browser.ts +0 -53
- package/templates/base-project/packages/db/src/generated/prisma/client.ts +0 -82
- package/templates/base-project/packages/db/src/generated/prisma/commonInputTypes.ts +0 -649
- package/templates/base-project/packages/db/src/generated/prisma/enums.ts +0 -19
- package/templates/base-project/packages/db/src/generated/prisma/internal/class.ts +0 -305
- package/templates/base-project/packages/db/src/generated/prisma/internal/prismaNamespace.ts +0 -1428
- package/templates/base-project/packages/db/src/generated/prisma/internal/prismaNamespaceBrowser.ts +0 -217
- package/templates/base-project/packages/db/src/generated/prisma/models/Account.ts +0 -2098
- package/templates/base-project/packages/db/src/generated/prisma/models/AuditLog.ts +0 -1805
- package/templates/base-project/packages/db/src/generated/prisma/models/Job.ts +0 -1737
- package/templates/base-project/packages/db/src/generated/prisma/models/Post.ts +0 -1762
- package/templates/base-project/packages/db/src/generated/prisma/models/Session.ts +0 -1738
- package/templates/base-project/packages/db/src/generated/prisma/models/User.ts +0 -2298
- package/templates/base-project/packages/db/src/generated/prisma/models/VerificationToken.ts +0 -1450
- package/templates/base-project/packages/db/src/generated/prisma/models.ts +0 -18
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { syncNextAuthUrl } from "./app-url.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Environment variable validation schema
|
|
5
|
+
* Validates all required and optional environment variables on startup
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const envSchema = {
|
|
9
|
+
// Database
|
|
10
|
+
DATABASE_URL: {
|
|
11
|
+
required: false,
|
|
12
|
+
description: "PostgreSQL connection string",
|
|
13
|
+
},
|
|
14
|
+
POSTGRES_HOST: { required: false, description: "PostgreSQL host" },
|
|
15
|
+
POSTGRES_PORT: { required: false, description: "PostgreSQL port" },
|
|
16
|
+
POSTGRES_USER: { required: false, description: "PostgreSQL user" },
|
|
17
|
+
POSTGRES_PASSWORD: { required: false, description: "PostgreSQL password" },
|
|
18
|
+
POSTGRES_DB: { required: false, description: "PostgreSQL database name" },
|
|
19
|
+
|
|
20
|
+
// Redis
|
|
21
|
+
REDIS_URL: { required: false, description: "Redis connection string" },
|
|
22
|
+
REDIS_HOST: { required: false, description: "Redis host" },
|
|
23
|
+
REDIS_PORT: { required: false, description: "Redis port" },
|
|
24
|
+
|
|
25
|
+
// Mailhog
|
|
26
|
+
MAILHOG_SMTP_URL: { required: false, description: "Mailhog SMTP URL" },
|
|
27
|
+
MAILHOG_HOST: { required: false, description: "Mailhog host" },
|
|
28
|
+
MAILHOG_SMTP_PORT: { required: false, description: "Mailhog SMTP port" },
|
|
29
|
+
MAILHOG_UI_PORT: { required: false, description: "Mailhog UI port" },
|
|
30
|
+
|
|
31
|
+
// NextAuth
|
|
32
|
+
NEXTAUTH_SECRET: {
|
|
33
|
+
required: true,
|
|
34
|
+
description: "NextAuth secret for JWT signing",
|
|
35
|
+
},
|
|
36
|
+
NEXTAUTH_URL: {
|
|
37
|
+
required: false,
|
|
38
|
+
description: "NextAuth callback URL (derived from APP_URL if not set)",
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Application
|
|
42
|
+
APP_URL: {
|
|
43
|
+
required: false,
|
|
44
|
+
description:
|
|
45
|
+
"Canonical application URL — derives NEXTAUTH_URL and CORS origins",
|
|
46
|
+
},
|
|
47
|
+
NODE_ENV: {
|
|
48
|
+
required: false,
|
|
49
|
+
description: "Environment (development, test, production)",
|
|
50
|
+
},
|
|
51
|
+
PORT: { required: false, description: "Web server port" },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Validates environment variables against schema
|
|
56
|
+
* @throws {Error} If required environment variables are missing
|
|
57
|
+
* @returns {Object} Validated environment object
|
|
58
|
+
*/
|
|
59
|
+
export function validateEnv() {
|
|
60
|
+
const errors = [];
|
|
61
|
+
const validated = {};
|
|
62
|
+
|
|
63
|
+
for (const [key, config] of Object.entries(envSchema)) {
|
|
64
|
+
const value = process.env[key];
|
|
65
|
+
|
|
66
|
+
if (config.required && !value) {
|
|
67
|
+
errors.push(
|
|
68
|
+
`Missing required environment variable: ${key} (${config.description})`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (value) {
|
|
73
|
+
validated[key] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (errors.length > 0) {
|
|
78
|
+
const errorMessage = `Environment Validation Failed:\n${errors.join("\n")}`;
|
|
79
|
+
throw new Error(errorMessage);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Ensure NEXTAUTH_URL is derived from APP_URL when not explicitly set
|
|
83
|
+
syncNextAuthUrl();
|
|
84
|
+
|
|
85
|
+
// Include the (possibly derived) NEXTAUTH_URL in the validated object
|
|
86
|
+
if (process.env.NEXTAUTH_URL && !validated.NEXTAUTH_URL) {
|
|
87
|
+
validated.NEXTAUTH_URL = process.env.NEXTAUTH_URL;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return validated;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Loads and validates environment variables
|
|
95
|
+
* Call this function at application startup
|
|
96
|
+
*/
|
|
97
|
+
export function loadEnv() {
|
|
98
|
+
try {
|
|
99
|
+
return validateEnv();
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error(error.message);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
// biome-ignore-all lint: generated file
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
/*
|
|
6
|
-
* This file should be your main import to use Prisma-related types and utilities in a browser.
|
|
7
|
-
* Use it to get access to models, enums, and input types.
|
|
8
|
-
*
|
|
9
|
-
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
|
|
10
|
-
* See `client.ts` for the standard, server-side entry point.
|
|
11
|
-
*
|
|
12
|
-
* 🟢 You can import this file directly.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import * as Prisma from "./internal/prismaNamespaceBrowser.ts";
|
|
16
|
-
export { Prisma };
|
|
17
|
-
export * as $Enums from "./enums.ts";
|
|
18
|
-
export * from "./enums.ts";
|
|
19
|
-
/**
|
|
20
|
-
* Model User
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
export type User = Prisma.UserModel;
|
|
24
|
-
/**
|
|
25
|
-
* Model Post
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
export type Post = Prisma.PostModel;
|
|
29
|
-
/**
|
|
30
|
-
* Model Account
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
export type Account = Prisma.AccountModel;
|
|
34
|
-
/**
|
|
35
|
-
* Model Session
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
export type Session = Prisma.SessionModel;
|
|
39
|
-
/**
|
|
40
|
-
* Model VerificationToken
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
export type VerificationToken = Prisma.VerificationTokenModel;
|
|
44
|
-
/**
|
|
45
|
-
* Model Job
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
export type Job = Prisma.JobModel;
|
|
49
|
-
/**
|
|
50
|
-
* Model AuditLog
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export type AuditLog = Prisma.AuditLogModel;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
// biome-ignore-all lint: generated file
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
/*
|
|
6
|
-
* This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
|
|
7
|
-
* If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead.
|
|
8
|
-
*
|
|
9
|
-
* 🟢 You can import this file directly.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import * as path from "node:path";
|
|
13
|
-
import * as process from "node:process";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
-
|
|
16
|
-
globalThis["__dirname"] = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
|
|
18
|
-
import * as runtime from "@prisma/client/runtime/client";
|
|
19
|
-
import * as $Enums from "./enums.ts";
|
|
20
|
-
import * as $Class from "./internal/class.ts";
|
|
21
|
-
import * as Prisma from "./internal/prismaNamespace.ts";
|
|
22
|
-
|
|
23
|
-
export * as $Enums from "./enums.ts";
|
|
24
|
-
export * from "./enums.ts";
|
|
25
|
-
/**
|
|
26
|
-
* ## Prisma Client
|
|
27
|
-
*
|
|
28
|
-
* Type-safe database client for TypeScript
|
|
29
|
-
* @example
|
|
30
|
-
* ```
|
|
31
|
-
* const prisma = new PrismaClient()
|
|
32
|
-
* // Fetch zero or more Users
|
|
33
|
-
* const users = await prisma.user.findMany()
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
|
|
37
|
-
*/
|
|
38
|
-
export const PrismaClient = $Class.getPrismaClientClass();
|
|
39
|
-
export type PrismaClient<
|
|
40
|
-
LogOpts extends Prisma.LogLevel = never,
|
|
41
|
-
OmitOpts extends
|
|
42
|
-
Prisma.PrismaClientOptions["omit"] = Prisma.PrismaClientOptions["omit"],
|
|
43
|
-
ExtArgs extends
|
|
44
|
-
runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs,
|
|
45
|
-
> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>;
|
|
46
|
-
export { Prisma };
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Model User
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
export type User = Prisma.UserModel;
|
|
53
|
-
/**
|
|
54
|
-
* Model Post
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
export type Post = Prisma.PostModel;
|
|
58
|
-
/**
|
|
59
|
-
* Model Account
|
|
60
|
-
*
|
|
61
|
-
*/
|
|
62
|
-
export type Account = Prisma.AccountModel;
|
|
63
|
-
/**
|
|
64
|
-
* Model Session
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
export type Session = Prisma.SessionModel;
|
|
68
|
-
/**
|
|
69
|
-
* Model VerificationToken
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
export type VerificationToken = Prisma.VerificationTokenModel;
|
|
73
|
-
/**
|
|
74
|
-
* Model Job
|
|
75
|
-
*
|
|
76
|
-
*/
|
|
77
|
-
export type Job = Prisma.JobModel;
|
|
78
|
-
/**
|
|
79
|
-
* Model AuditLog
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
export type AuditLog = Prisma.AuditLogModel;
|