create-kyro 0.1.3 → 0.1.5
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/dist/index.js +20 -69
- package/package.json +2 -2
- package/my-kyro-app/README.md +0 -14
- package/my-kyro-app/SPEC.md +0 -21
- package/my-kyro-app/astro.config.mjs +0 -20
- package/my-kyro-app/kyro.config.ts +0 -15
- package/my-kyro-app/package-lock.json +0 -6919
- package/my-kyro-app/package.json +0 -31
package/dist/index.js
CHANGED
|
@@ -86,12 +86,14 @@ async function promptUser() {
|
|
|
86
86
|
{
|
|
87
87
|
title: "tRPC",
|
|
88
88
|
description: "End-to-end typesafe APIs, great for TypeScript",
|
|
89
|
-
value: "trpc"
|
|
89
|
+
value: "trpc",
|
|
90
|
+
selected: true
|
|
90
91
|
},
|
|
91
92
|
{
|
|
92
93
|
title: "WebSocket",
|
|
93
94
|
description: "Real-time bidirectional communication",
|
|
94
|
-
value: "websocket"
|
|
95
|
+
value: "websocket",
|
|
96
|
+
selected: true
|
|
95
97
|
}
|
|
96
98
|
]
|
|
97
99
|
},
|
|
@@ -494,18 +496,15 @@ Visit [https://kyro.cms](https://kyro.cms) for full documentation.
|
|
|
494
496
|
|
|
495
497
|
${answers.database === "sqlite" ? "# SQLite (local) - no additional config needed" : answers.database === "postgres" || answers.database === "mysql" ? "# Database connection (PostgreSQL/MySQL)\nDATABASE_URL=postgresql://user:password@localhost:5432/kyro_cms\nDATABASE_SSL=false" : "# MongoDB connection\nMONGODB_URI=mongodb://localhost:27017/kyro_cms"}
|
|
496
498
|
|
|
497
|
-
${answers.auth ? `# Authentication (
|
|
499
|
+
${answers.auth ? `# Authentication (uses SQLite at ./data/auth.db - no Redis needed)
|
|
498
500
|
JWT_SECRET=change-this-to-a-random-32-character-string
|
|
499
501
|
JWT_EXPIRES_IN=24h
|
|
500
502
|
|
|
501
|
-
#
|
|
502
|
-
|
|
503
|
-
KYRO_ADMIN_PASSWORD=SecurePass123!
|
|
504
|
-
KYRO_ADMIN_ROLE=super_admin
|
|
503
|
+
# Registration control (set to false to disable public registration after first user)
|
|
504
|
+
KYRO_ALLOW_REGISTRATION=true
|
|
505
505
|
|
|
506
|
-
# Optional:
|
|
507
|
-
#
|
|
508
|
-
# REDIS_TLS=false
|
|
506
|
+
# Optional: Custom auth database path (default: ./data/auth.db)
|
|
507
|
+
# KYRO_AUTH_DB_PATH=./data/auth.db
|
|
509
508
|
|
|
510
509
|
# Optional: SMTP for emails
|
|
511
510
|
# SMTP_HOST=smtp.example.com
|
|
@@ -626,20 +625,15 @@ import config from '../../../kyro.config';
|
|
|
626
625
|
}
|
|
627
626
|
}
|
|
628
627
|
function generateLoginEndpoint(database) {
|
|
629
|
-
const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
|
|
630
|
-
const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
|
|
631
|
-
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
632
|
-
tls: process.env.REDIS_TLS === "true",
|
|
633
|
-
});`;
|
|
634
628
|
return `import type { APIRoute } from "astro";
|
|
635
|
-
|
|
629
|
+
import { SQLiteAuthAdapter } from "@kyro-cms/core";
|
|
636
630
|
import jwt from "jsonwebtoken";
|
|
637
631
|
|
|
638
632
|
const JWT_SECRET = process.env.JWT_SECRET || "change-me-in-production";
|
|
639
633
|
const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || "24h";
|
|
640
634
|
|
|
641
635
|
async function getAuthApi() {
|
|
642
|
-
|
|
636
|
+
return new SQLiteAuthAdapter({ path: "./data/auth.db" });
|
|
643
637
|
}
|
|
644
638
|
|
|
645
639
|
export const POST: APIRoute = async ({ request }) => {
|
|
@@ -721,28 +715,8 @@ export const POST: APIRoute = async ({ request }) => {
|
|
|
721
715
|
`;
|
|
722
716
|
}
|
|
723
717
|
function generateRegisterEndpoint(database) {
|
|
724
|
-
const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
|
|
725
|
-
const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
|
|
726
|
-
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
727
|
-
tls: process.env.REDIS_TLS === "true",
|
|
728
|
-
});`;
|
|
729
|
-
const isFirstUserCheck = database === "sqlite" ? ` const isFirstUser = !(await adapter.hasAnyUsers());` : ` const isFirstUser = await checkIsFirstUser(adapter);`;
|
|
730
|
-
const isFirstUserFn = database === "sqlite" ? "" : `
|
|
731
|
-
|
|
732
|
-
async function checkIsFirstUser(adapter: RedisAuthAdapter): Promise<boolean> {
|
|
733
|
-
try {
|
|
734
|
-
const redis = (adapter as any).redis;
|
|
735
|
-
if (!redis) return true;
|
|
736
|
-
const pattern = "kyro:auth:users:email:*";
|
|
737
|
-
const result = await redis.scan("0", "MATCH", pattern, "COUNT", "1");
|
|
738
|
-
const keys = result[1];
|
|
739
|
-
return keys.length === 0;
|
|
740
|
-
} catch {
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
}`;
|
|
744
718
|
return `import type { APIRoute } from "astro";
|
|
745
|
-
|
|
719
|
+
import { SQLiteAuthAdapter } from "@kyro-cms/core";
|
|
746
720
|
import jwt from "jsonwebtoken";
|
|
747
721
|
|
|
748
722
|
const JWT_SECRET = process.env.JWT_SECRET || "change-me-in-production";
|
|
@@ -750,7 +724,7 @@ const JWT_EXPIRES_IN = process.env.JWT_EXPIRES_IN || "24h";
|
|
|
750
724
|
const ALLOW_REGISTRATION = process.env.KYRO_ALLOW_REGISTRATION !== "false";
|
|
751
725
|
|
|
752
726
|
async function getAuthApi() {
|
|
753
|
-
|
|
727
|
+
return new SQLiteAuthAdapter({ path: "./data/auth.db" });
|
|
754
728
|
}
|
|
755
729
|
|
|
756
730
|
export const POST: APIRoute = async ({ request }) => {
|
|
@@ -802,7 +776,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|
|
802
776
|
);
|
|
803
777
|
}
|
|
804
778
|
|
|
805
|
-
|
|
779
|
+
const isFirstUser = !(await adapter.hasAnyUsers());
|
|
806
780
|
|
|
807
781
|
if (!isFirstUser && !ALLOW_REGISTRATION) {
|
|
808
782
|
await adapter.disconnect();
|
|
@@ -863,20 +837,15 @@ ${isFirstUserCheck}
|
|
|
863
837
|
headers: { "Content-Type": "application/json" },
|
|
864
838
|
});
|
|
865
839
|
}
|
|
866
|
-
}
|
|
840
|
+
};
|
|
867
841
|
`;
|
|
868
842
|
}
|
|
869
843
|
function generateLogoutEndpoint(database) {
|
|
870
|
-
const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
|
|
871
|
-
const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
|
|
872
|
-
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
873
|
-
tls: process.env.REDIS_TLS === "true",
|
|
874
|
-
});`;
|
|
875
844
|
return `import type { APIRoute } from "astro";
|
|
876
|
-
|
|
845
|
+
import { SQLiteAuthAdapter } from "@kyro-cms/core";
|
|
877
846
|
|
|
878
847
|
async function getAuthApi() {
|
|
879
|
-
|
|
848
|
+
return new SQLiteAuthAdapter({ path: "./data/auth.db" });
|
|
880
849
|
}
|
|
881
850
|
|
|
882
851
|
export const POST: APIRoute = async ({ request }) => {
|
|
@@ -945,29 +914,11 @@ export const GET: APIRoute = async ({ request }) => {
|
|
|
945
914
|
`;
|
|
946
915
|
}
|
|
947
916
|
function generateUsersEndpoint(database) {
|
|
948
|
-
const adapterImport = database === "sqlite" ? `import { SQLiteAuthAdapter } from "@kyro-cms/core";` : `import { RedisAuthAdapter } from "@kyro-cms/core";`;
|
|
949
|
-
const adapterInit = database === "sqlite" ? ` return new SQLiteAuthAdapter({ path: "./data.db" });` : ` return new RedisAuthAdapter({
|
|
950
|
-
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
951
|
-
tls: process.env.REDIS_TLS === "true",
|
|
952
|
-
});`;
|
|
953
|
-
const hasUsersCheck = database === "sqlite" ? ` const hasUsers = await adapter.hasAnyUsers();` : ` const redis = (adapter as any).redis;
|
|
954
|
-
if (!redis) {
|
|
955
|
-
await adapter.disconnect();
|
|
956
|
-
return new Response(JSON.stringify({ hasUsers: false }), {
|
|
957
|
-
status: 200,
|
|
958
|
-
headers: { "Content-Type": "application/json" },
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
const pattern = "kyro:auth:users:email:*";
|
|
963
|
-
const result = await redis.scan("0", "MATCH", pattern, "COUNT", "1");
|
|
964
|
-
const keys = result[1];
|
|
965
|
-
const hasUsers = keys.length > 0;`;
|
|
966
917
|
return `import type { APIRoute } from "astro";
|
|
967
|
-
|
|
918
|
+
import { SQLiteAuthAdapter } from "@kyro-cms/core";
|
|
968
919
|
|
|
969
920
|
async function getAuthApi() {
|
|
970
|
-
|
|
921
|
+
return new SQLiteAuthAdapter({ path: "./data/auth.db" });
|
|
971
922
|
}
|
|
972
923
|
|
|
973
924
|
export const GET: APIRoute = async () => {
|
|
@@ -975,7 +926,7 @@ export const GET: APIRoute = async () => {
|
|
|
975
926
|
const adapter = await getAuthApi();
|
|
976
927
|
await adapter.connect();
|
|
977
928
|
|
|
978
|
-
|
|
929
|
+
const hasUsers = await adapter.hasAnyUsers();
|
|
979
930
|
|
|
980
931
|
await adapter.disconnect();
|
|
981
932
|
|
package/package.json
CHANGED
package/my-kyro-app/README.md
DELETED
package/my-kyro-app/SPEC.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# my-kyro-app
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This project uses Kyro CMS - an Astro-native headless CMS.
|
|
6
|
-
|
|
7
|
-
## Configuration
|
|
8
|
-
|
|
9
|
-
- **Database**: SQLite (local-first)
|
|
10
|
-
- **APIs**: rest, graphql
|
|
11
|
-
- **Styling**: tailwind
|
|
12
|
-
- **Auth**: Disabled
|
|
13
|
-
- **Versioning**: Enabled
|
|
14
|
-
- **Admin**: Included
|
|
15
|
-
- **Template**: blog
|
|
16
|
-
|
|
17
|
-
## Collections
|
|
18
|
-
|
|
19
|
-
- Posts
|
|
20
|
-
- Categories
|
|
21
|
-
- Media
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "astro/config";
|
|
2
|
-
import react from "@astrojs/react";
|
|
3
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
4
|
-
import node from "@astrojs/node";
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
output: "server",
|
|
8
|
-
adapter: node({
|
|
9
|
-
mode: "standalone",
|
|
10
|
-
}),
|
|
11
|
-
|
|
12
|
-
integrations: [react()],
|
|
13
|
-
vite: {
|
|
14
|
-
plugins: [tailwindcss()],
|
|
15
|
-
},
|
|
16
|
-
server: {
|
|
17
|
-
port: 4321,
|
|
18
|
-
host: true,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "@kyro-cms/core";
|
|
2
|
-
import { createLocalAdapter } from "@kyro-cms/core";
|
|
3
|
-
import { blogCollections } from "@kyro-cms/core";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
name: "my-kyro-app",
|
|
7
|
-
prefix: "/api",
|
|
8
|
-
adapter: createLocalAdapter({ path: "./data.db" }),
|
|
9
|
-
|
|
10
|
-
collections: Object.values(blogCollections),
|
|
11
|
-
|
|
12
|
-
api: {
|
|
13
|
-
rest: true,
|
|
14
|
-
},
|
|
15
|
-
});
|