create-atsdc-stack 1.0.1 → 1.2.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/.claude/settings.local.json +3 -1
- package/CLAUDE.md +236 -0
- package/CONTRIBUTING.md +342 -342
- package/INSTALLATION.md +359 -359
- package/LICENSE +201 -201
- package/README.md +405 -405
- package/app/.env.example +17 -17
- package/app/.github/labeler.yml +61 -0
- package/app/.github/workflows/browser-tests.yml +101 -0
- package/app/.github/workflows/check.yml +24 -0
- package/app/.github/workflows/greetings.yml +16 -0
- package/app/.github/workflows/label.yml +22 -0
- package/app/.github/workflows/stale.yml +27 -0
- package/app/.github/workflows/summary.yml +34 -0
- package/app/.stylelintrc.json +8 -0
- package/app/README.md +251 -251
- package/app/astro.config.mjs +83 -83
- package/app/drizzle.config.ts +16 -16
- package/app/package.json +66 -52
- package/app/playwright.config.ts +27 -0
- package/app/public/manifest.webmanifest +36 -36
- package/app/pwa-assets.config.ts +8 -0
- package/app/src/components/Card.astro +36 -36
- package/app/src/db/initialize.ts +107 -107
- package/app/src/db/schema.ts +72 -72
- package/app/src/db/validations.ts +158 -158
- package/app/src/layouts/Layout.astro +63 -63
- package/app/src/lib/config.ts +36 -36
- package/app/src/lib/content-converter.ts +141 -141
- package/app/src/lib/dom-utils.ts +230 -230
- package/app/src/lib/exa-search.ts +269 -269
- package/app/src/pages/api/chat.ts +91 -91
- package/app/src/pages/api/posts.ts +350 -350
- package/app/src/pages/index.astro +87 -87
- package/app/src/styles/components/button.scss +152 -152
- package/app/src/styles/components/card.scss +180 -180
- package/app/src/styles/components/form.scss +240 -240
- package/app/src/styles/global.scss +141 -141
- package/app/src/styles/pages/index.scss +80 -80
- package/app/src/styles/reset.scss +83 -83
- package/app/src/styles/variables/globals.scss +96 -96
- package/app/src/styles/variables/mixins.scss +238 -238
- package/app/tests/browser.test.nopause.ts +10 -0
- package/app/tests/browser.test.ts +13 -0
- package/bin/cli.js +1151 -1138
- package/package.json +8 -6
- package/app/.astro/settings.json +0 -5
- package/app/.astro/types.d.ts +0 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import type { APIRoute } from 'astro';
|
|
2
|
-
import { streamText } from 'ai';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Vercel AI SDK Chat API Route
|
|
7
|
-
* Uses AI Gateway pattern - no provider-specific packages needed!
|
|
8
|
-
* Just pass model strings like 'openai/gpt-4o' or 'anthropic/claude-3-5-sonnet-20241022'
|
|
9
|
-
*
|
|
10
|
-
* Environment variables required:
|
|
11
|
-
* - OPENAI_API_KEY: Your OpenAI API key (or other provider keys)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Validate request schema
|
|
15
|
-
const requestSchema = z.object({
|
|
16
|
-
messages: z.array(
|
|
17
|
-
z.object({
|
|
18
|
-
role: z.enum(['user', 'assistant', 'system']),
|
|
19
|
-
content: z.string(),
|
|
20
|
-
})
|
|
21
|
-
),
|
|
22
|
-
model: z.string().optional().default('openai/gpt-4o'),
|
|
23
|
-
temperature: z.number().min(0).max(2).optional().default(0.7),
|
|
24
|
-
maxTokens: z.number().positive().optional().default(1000),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const POST: APIRoute = async ({ request }) => {
|
|
28
|
-
try {
|
|
29
|
-
// Validate API key
|
|
30
|
-
if (!import.meta.env.OPENAI_API_KEY && !process.env.OPENAI_API_KEY) {
|
|
31
|
-
return new Response(
|
|
32
|
-
JSON.stringify({
|
|
33
|
-
error: 'OPENAI_API_KEY is not configured',
|
|
34
|
-
}),
|
|
35
|
-
{
|
|
36
|
-
status: 500,
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Parse and validate request body
|
|
45
|
-
const body = await request.json();
|
|
46
|
-
const validatedData = requestSchema.parse(body);
|
|
47
|
-
|
|
48
|
-
// Stream the response using Vercel AI SDK with AI Gateway
|
|
49
|
-
const result = streamText({
|
|
50
|
-
model: validatedData.model, // Use model string directly (e.g., 'openai/gpt-4o')
|
|
51
|
-
messages: validatedData.messages,
|
|
52
|
-
temperature: validatedData.temperature,
|
|
53
|
-
maxTokens: validatedData.maxTokens,
|
|
54
|
-
apiKey: import.meta.env.OPENAI_API_KEY || process.env.OPENAI_API_KEY,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Return the stream response
|
|
58
|
-
return result.toDataStreamResponse();
|
|
59
|
-
} catch (error) {
|
|
60
|
-
// Handle Zod validation errors
|
|
61
|
-
if (error instanceof z.ZodError) {
|
|
62
|
-
return new Response(
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
error: 'Validation error',
|
|
65
|
-
details: error.errors,
|
|
66
|
-
}),
|
|
67
|
-
{
|
|
68
|
-
status: 400,
|
|
69
|
-
headers: {
|
|
70
|
-
'Content-Type': 'application/json',
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Handle other errors
|
|
77
|
-
console.error('Chat API error:', error);
|
|
78
|
-
return new Response(
|
|
79
|
-
JSON.stringify({
|
|
80
|
-
error: 'Internal server error',
|
|
81
|
-
message: error instanceof Error ? error.message : 'Unknown error',
|
|
82
|
-
}),
|
|
83
|
-
{
|
|
84
|
-
status: 500,
|
|
85
|
-
headers: {
|
|
86
|
-
'Content-Type': 'application/json',
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
1
|
+
import type { APIRoute } from 'astro';
|
|
2
|
+
import { streamText } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Vercel AI SDK Chat API Route
|
|
7
|
+
* Uses AI Gateway pattern - no provider-specific packages needed!
|
|
8
|
+
* Just pass model strings like 'openai/gpt-4o' or 'anthropic/claude-3-5-sonnet-20241022'
|
|
9
|
+
*
|
|
10
|
+
* Environment variables required:
|
|
11
|
+
* - OPENAI_API_KEY: Your OpenAI API key (or other provider keys)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Validate request schema
|
|
15
|
+
const requestSchema = z.object({
|
|
16
|
+
messages: z.array(
|
|
17
|
+
z.object({
|
|
18
|
+
role: z.enum(['user', 'assistant', 'system']),
|
|
19
|
+
content: z.string(),
|
|
20
|
+
})
|
|
21
|
+
),
|
|
22
|
+
model: z.string().optional().default('openai/gpt-4o'),
|
|
23
|
+
temperature: z.number().min(0).max(2).optional().default(0.7),
|
|
24
|
+
maxTokens: z.number().positive().optional().default(1000),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const POST: APIRoute = async ({ request }) => {
|
|
28
|
+
try {
|
|
29
|
+
// Validate API key
|
|
30
|
+
if (!import.meta.env.OPENAI_API_KEY && !process.env.OPENAI_API_KEY) {
|
|
31
|
+
return new Response(
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
error: 'OPENAI_API_KEY is not configured',
|
|
34
|
+
}),
|
|
35
|
+
{
|
|
36
|
+
status: 500,
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Parse and validate request body
|
|
45
|
+
const body = await request.json();
|
|
46
|
+
const validatedData = requestSchema.parse(body);
|
|
47
|
+
|
|
48
|
+
// Stream the response using Vercel AI SDK with AI Gateway
|
|
49
|
+
const result = streamText({
|
|
50
|
+
model: validatedData.model, // Use model string directly (e.g., 'openai/gpt-4o')
|
|
51
|
+
messages: validatedData.messages,
|
|
52
|
+
temperature: validatedData.temperature,
|
|
53
|
+
maxTokens: validatedData.maxTokens,
|
|
54
|
+
apiKey: import.meta.env.OPENAI_API_KEY || process.env.OPENAI_API_KEY,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Return the stream response
|
|
58
|
+
return result.toDataStreamResponse();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
// Handle Zod validation errors
|
|
61
|
+
if (error instanceof z.ZodError) {
|
|
62
|
+
return new Response(
|
|
63
|
+
JSON.stringify({
|
|
64
|
+
error: 'Validation error',
|
|
65
|
+
details: error.errors,
|
|
66
|
+
}),
|
|
67
|
+
{
|
|
68
|
+
status: 400,
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Handle other errors
|
|
77
|
+
console.error('Chat API error:', error);
|
|
78
|
+
return new Response(
|
|
79
|
+
JSON.stringify({
|
|
80
|
+
error: 'Internal server error',
|
|
81
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
82
|
+
}),
|
|
83
|
+
{
|
|
84
|
+
status: 500,
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
};
|