create-simone-app 0.1.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/README.md +70 -0
- package/bin/create-simone-app.ts +6 -0
- package/package.json +61 -0
- package/src/cli.ts +97 -0
- package/src/matrix.ts +39 -0
- package/src/options.ts +137 -0
- package/src/prompts.ts +108 -0
- package/src/scaffold.ts +304 -0
- package/src/templates.ts +77 -0
- package/templates/api/base/.agents/skills/ai-rules/SKILL.md +12 -0
- package/templates/api/base/.agents/skills/plan-feature/SKILL.md +13 -0
- package/templates/api/base/.agents/skills/review-diff/SKILL.md +12 -0
- package/templates/api/base/.agents/skills/tdd-step/SKILL.md +14 -0
- package/templates/api/base/.claude/agents/reviewer.md +20 -0
- package/templates/api/base/.claude/hooks/format.sh +22 -0
- package/templates/api/base/.claude/settings.json +38 -0
- package/templates/api/base/.codex/agents/reviewer.toml +7 -0
- package/templates/api/base/.codex/config.toml +10 -0
- package/templates/api/base/.codex/hooks.json +12 -0
- package/templates/api/base/.env.example +2 -0
- package/templates/api/base/.github/workflows/ci.yml +18 -0
- package/templates/api/base/.prettierignore +10 -0
- package/templates/api/base/.prettierrc +20 -0
- package/templates/api/base/CLAUDE.md +1 -0
- package/templates/api/base/README.md +43 -0
- package/templates/api/base/TASK.md.template +30 -0
- package/templates/api/base/_gitignore +8 -0
- package/templates/api/base/docs/agents/base.md +54 -0
- package/templates/api/base/eslint.config.js +21 -0
- package/templates/api/base/openapi.yaml +233 -0
- package/templates/api/base/package.json +41 -0
- package/templates/api/base/scripts/agents-build.ts +26 -0
- package/templates/api/base/scripts/rules-check.ts +48 -0
- package/templates/api/base/scripts/rules-sync.ts +35 -0
- package/templates/api/base/scripts/rules.config.ts +28 -0
- package/templates/api/base/scripts/seed-regen.ts +64 -0
- package/templates/api/base/src/data/orders.json +187 -0
- package/templates/api/base/src/data/products.json +142 -0
- package/templates/api/base/src/data/repository.ts +55 -0
- package/templates/api/base/src/data/schemas.ts +44 -0
- package/templates/api/base/src/data/users.json +352 -0
- package/templates/api/base/src/lib/appName.ts +2 -0
- package/templates/api/base/src/lib/http-error.ts +14 -0
- package/templates/api/base/src/lib/pagination.ts +55 -0
- package/templates/api/base/src/modules/orders/orders.repository.ts +26 -0
- package/templates/api/base/src/modules/orders/orders.schema.ts +11 -0
- package/templates/api/base/src/modules/products/products.repository.ts +17 -0
- package/templates/api/base/src/modules/products/products.schema.ts +21 -0
- package/templates/api/base/src/modules/stats/stats.repository.ts +37 -0
- package/templates/api/base/src/modules/users/users.repository.ts +26 -0
- package/templates/api/base/src/modules/users/users.schema.ts +15 -0
- package/templates/api/base/test/docs.test.ts +23 -0
- package/templates/api/base/test/health.test.ts +19 -0
- package/templates/api/base/test/orders.test.ts +82 -0
- package/templates/api/base/test/products.test.ts +54 -0
- package/templates/api/base/test/repository.test.ts +45 -0
- package/templates/api/base/test/smoke.test.ts +7 -0
- package/templates/api/base/test/stats.test.ts +40 -0
- package/templates/api/base/test/users.test.ts +84 -0
- package/templates/api/base/tsconfig.json +22 -0
- package/templates/api/base/vitest.config.ts +16 -0
- package/templates/api/variants/features/no-github-ci/variant.json +1 -0
- package/templates/api/variants/framework/express/docs/agents/framework-express.md +9 -0
- package/templates/api/variants/framework/express/src/app.ts +37 -0
- package/templates/api/variants/framework/express/src/middleware/errorHandler.ts +13 -0
- package/templates/api/variants/framework/express/src/middleware/validate.ts +59 -0
- package/templates/api/variants/framework/express/src/modules/docs/docs.router.ts +15 -0
- package/templates/api/variants/framework/express/src/modules/health/health.router.ts +7 -0
- package/templates/api/variants/framework/express/src/modules/orders/orders.router.ts +14 -0
- package/templates/api/variants/framework/express/src/modules/products/products.router.ts +24 -0
- package/templates/api/variants/framework/express/src/modules/stats/stats.router.ts +9 -0
- package/templates/api/variants/framework/express/src/modules/users/users.router.ts +24 -0
- package/templates/api/variants/framework/express/src/server.ts +8 -0
- package/templates/api/variants/framework/express/test/errorHandler.test.ts +89 -0
- package/templates/api/variants/framework/express/variant.json +15 -0
- package/templates/fe/base/.agents/skills/ai-rules/SKILL.md +12 -0
- package/templates/fe/base/.agents/skills/plan-feature/SKILL.md +13 -0
- package/templates/fe/base/.agents/skills/review-diff/SKILL.md +12 -0
- package/templates/fe/base/.agents/skills/tdd-step/SKILL.md +14 -0
- package/templates/fe/base/.claude/agents/reviewer.md +21 -0
- package/templates/fe/base/.claude/hooks/format.sh +22 -0
- package/templates/fe/base/.claude/settings.json +41 -0
- package/templates/fe/base/.codex/agents/reviewer.toml +7 -0
- package/templates/fe/base/.codex/config.toml +10 -0
- package/templates/fe/base/.codex/hooks.json +12 -0
- package/templates/fe/base/.env.example +2 -0
- package/templates/fe/base/.github/workflows/ci.yml +37 -0
- package/templates/fe/base/.prettierignore +14 -0
- package/templates/fe/base/.prettierrc +20 -0
- package/templates/fe/base/CLAUDE.md +1 -0
- package/templates/fe/base/README.md +37 -0
- package/templates/fe/base/TASK.md.template +31 -0
- package/templates/fe/base/_gitignore +11 -0
- package/templates/fe/base/docs/agents/base.md +69 -0
- package/templates/fe/base/e2e/users.spec.ts +82 -0
- package/templates/fe/base/eslint.config.js +169 -0
- package/templates/fe/base/index.html +13 -0
- package/templates/fe/base/package.json +63 -0
- package/templates/fe/base/playwright.config.ts +17 -0
- package/templates/fe/base/public/favicon.svg +1 -0
- package/templates/fe/base/public/icons.svg +24 -0
- package/templates/fe/base/scripts/agents-build.ts +26 -0
- package/templates/fe/base/scripts/rules-check.ts +48 -0
- package/templates/fe/base/scripts/rules-sync.ts +35 -0
- package/templates/fe/base/scripts/rules.config.ts +35 -0
- package/templates/fe/base/src/components/shared/EmptyState.tsx +23 -0
- package/templates/fe/base/src/components/shared/ErrorState.tsx +37 -0
- package/templates/fe/base/src/components/shared/PageHeader.tsx +21 -0
- package/templates/fe/base/src/features/users/UserSearch.tsx +48 -0
- package/templates/fe/base/src/features/users/UsersPage.tsx +58 -0
- package/templates/fe/base/src/features/users/UsersTable.tsx +245 -0
- package/templates/fe/base/src/features/users/UsersTableSkeleton.tsx +16 -0
- package/templates/fe/base/src/features/users/__tests__/UserSearch.test.tsx +30 -0
- package/templates/fe/base/src/features/users/__tests__/UsersPage.test.tsx +69 -0
- package/templates/fe/base/src/features/users/__tests__/UsersTable.test.tsx +120 -0
- package/templates/fe/base/src/features/users/__tests__/useUsers.test.tsx +62 -0
- package/templates/fe/base/src/features/users/useUsers.ts +22 -0
- package/templates/fe/base/src/features/users/users.api.ts +22 -0
- package/templates/fe/base/src/features/users/users.schema.ts +43 -0
- package/templates/fe/base/src/lib/apiClient.test.ts +56 -0
- package/templates/fe/base/src/lib/apiClient.ts +42 -0
- package/templates/fe/base/src/lib/appName.ts +2 -0
- package/templates/fe/base/src/lib/env.test.ts +21 -0
- package/templates/fe/base/src/lib/env.ts +26 -0
- package/templates/fe/base/src/lib/queryClient.ts +15 -0
- package/templates/fe/base/src/lib/router.ts +11 -0
- package/templates/fe/base/src/main.tsx +21 -0
- package/templates/fe/base/src/routeTree.gen.ts +77 -0
- package/templates/fe/base/src/routes/__root.tsx +83 -0
- package/templates/fe/base/src/routes/index.tsx +26 -0
- package/templates/fe/base/src/routes/users/index.tsx +24 -0
- package/templates/fe/base/src/stores/seam.test.ts +21 -0
- package/templates/fe/base/src/test/api-mock.ts +22 -0
- package/templates/fe/base/src/test/fixtures/users.ts +39 -0
- package/templates/fe/base/src/test/msw/handlers.ts +9 -0
- package/templates/fe/base/src/test/msw/server.ts +5 -0
- package/templates/fe/base/src/test/render.tsx +45 -0
- package/templates/fe/base/src/test/setup.ts +15 -0
- package/templates/fe/base/tsconfig.json +25 -0
- package/templates/fe/base/vite.config.ts +22 -0
- package/templates/fe/base/vitest.config.ts +21 -0
- package/templates/fe/variants/features/no-github-ci/variant.json +1 -0
- package/templates/fe/variants/features/no-msw/src/test/api-mock.ts +52 -0
- package/templates/fe/variants/features/no-msw/src/test/setup.ts +13 -0
- package/templates/fe/variants/features/no-msw/variant.json +4 -0
- package/templates/fe/variants/features/no-playwright/.github/workflows/ci.yml +19 -0
- package/templates/fe/variants/features/no-playwright/variant.json +5 -0
- package/templates/fe/variants/state/jotai/docs/agents/state-jotai.md +5 -0
- package/templates/fe/variants/state/jotai/src/stores/index.ts +15 -0
- package/templates/fe/variants/state/jotai/src/stores/ui.atoms.test.tsx +29 -0
- package/templates/fe/variants/state/jotai/src/stores/ui.atoms.ts +39 -0
- package/templates/fe/variants/state/jotai/variant.json +12 -0
- package/templates/fe/variants/state/zustand/docs/agents/state-zustand.md +5 -0
- package/templates/fe/variants/state/zustand/src/stores/index.ts +12 -0
- package/templates/fe/variants/state/zustand/src/stores/ui.store.test.ts +34 -0
- package/templates/fe/variants/state/zustand/src/stores/ui.store.ts +62 -0
- package/templates/fe/variants/state/zustand/variant.json +5 -0
- package/templates/fe/variants/ui/base-ui/components.json +25 -0
- package/templates/fe/variants/ui/base-ui/docs/agents/ui-base-ui.md +7 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/alert.tsx +75 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/button.tsx +57 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/input.tsx +19 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/skeleton.tsx +13 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/table.tsx +113 -0
- package/templates/fe/variants/ui/base-ui/src/index.css +130 -0
- package/templates/fe/variants/ui/base-ui/src/lib/utils.test.ts +10 -0
- package/templates/fe/variants/ui/base-ui/src/lib/utils.ts +1 -0
- package/templates/fe/variants/ui/base-ui/variant.json +23 -0
- package/templates/fe/variants/ui/radix/components.json +25 -0
- package/templates/fe/variants/ui/radix/docs/agents/ui-radix.md +7 -0
- package/templates/fe/variants/ui/radix/src/components/ui/alert.tsx +75 -0
- package/templates/fe/variants/ui/radix/src/components/ui/button.tsx +66 -0
- package/templates/fe/variants/ui/radix/src/components/ui/input.tsx +18 -0
- package/templates/fe/variants/ui/radix/src/components/ui/skeleton.tsx +13 -0
- package/templates/fe/variants/ui/radix/src/components/ui/table.tsx +113 -0
- package/templates/fe/variants/ui/radix/src/index.css +130 -0
- package/templates/fe/variants/ui/radix/src/lib/utils.test.ts +10 -0
- package/templates/fe/variants/ui/radix/src/lib/utils.ts +1 -0
- package/templates/fe/variants/ui/radix/variant.json +23 -0
- package/templates/fullstack/.github/workflows/ci.yml +18 -0
- package/templates/fullstack/AGENTS.md +7 -0
- package/templates/fullstack/CLAUDE.md +1 -0
- package/templates/fullstack/README.md +16 -0
- package/templates/fullstack/_gitignore +11 -0
- package/templates/fullstack/package.json +16 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "0d9b0fd3-2248-4649-9245-7c3890921ffc",
|
|
4
|
+
"name": "Nikita Crist",
|
|
5
|
+
"email": "nikita_crist44@gmail.com",
|
|
6
|
+
"role": "editor",
|
|
7
|
+
"createdAt": "2024-01-26T03:18:43.937Z"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "2fcfe9e1-3056-44d5-8482-c1fc30dbbc15",
|
|
11
|
+
"name": "Major Lockman",
|
|
12
|
+
"email": "major_lockman33@yahoo.com",
|
|
13
|
+
"role": "admin",
|
|
14
|
+
"createdAt": "2024-08-25T17:00:58.001Z"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "c8c78601-0a58-4e36-9c31-42ecadc2e8ce",
|
|
18
|
+
"name": "Stefan Ratke",
|
|
19
|
+
"email": "stefan.ratke@gmail.com",
|
|
20
|
+
"role": "viewer",
|
|
21
|
+
"createdAt": "2024-01-06T01:58:05.433Z"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "58b5ff47-4409-4804-be32-7f3ac3b5aa81",
|
|
25
|
+
"name": "Darren Weissnat",
|
|
26
|
+
"email": "darren.weissnat@gmail.com",
|
|
27
|
+
"role": "viewer",
|
|
28
|
+
"createdAt": "2024-01-13T03:01:00.717Z"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "e251ee4a-d883-41ee-8a55-beeca12e901a",
|
|
32
|
+
"name": "Lon Howe",
|
|
33
|
+
"email": "lon_howe@gmail.com",
|
|
34
|
+
"role": "admin",
|
|
35
|
+
"createdAt": "2025-06-04T14:28:19.422Z"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "91543f6e-ac89-473b-940a-2ffe50e6ffd4",
|
|
39
|
+
"name": "Monique Oberbrunner",
|
|
40
|
+
"email": "monique.oberbrunner@yahoo.com",
|
|
41
|
+
"role": "viewer",
|
|
42
|
+
"createdAt": "2025-05-23T19:08:47.614Z"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "ebbb54cc-de88-4cab-8ce5-6190784900d5",
|
|
46
|
+
"name": "Kristopher Leannon",
|
|
47
|
+
"email": "kristopher_leannon@hotmail.com",
|
|
48
|
+
"role": "admin",
|
|
49
|
+
"createdAt": "2024-02-07T18:42:14.766Z"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "c4710fdb-6224-48ba-94fb-89635c0100db",
|
|
53
|
+
"name": "Levi Larson-Hand",
|
|
54
|
+
"email": "levi.larson-hand47@gmail.com",
|
|
55
|
+
"role": "editor",
|
|
56
|
+
"createdAt": "2024-10-18T07:22:01.018Z"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "da21a09f-96a7-48f6-afe3-1101a15d0d41",
|
|
60
|
+
"name": "Andres Kuvalis",
|
|
61
|
+
"email": "andres_kuvalis@hotmail.com",
|
|
62
|
+
"role": "admin",
|
|
63
|
+
"createdAt": "2024-05-09T16:59:57.504Z"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "5ed6cc1e-8d5e-460e-815f-f9a745accc17",
|
|
67
|
+
"name": "Wyman Sanford",
|
|
68
|
+
"email": "wyman.sanford88@hotmail.com",
|
|
69
|
+
"role": "admin",
|
|
70
|
+
"createdAt": "2024-04-14T12:38:45.708Z"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "db11f55d-ffc6-41c8-b6e1-707011ab9f54",
|
|
74
|
+
"name": "Braeden Bins",
|
|
75
|
+
"email": "braeden_bins@gmail.com",
|
|
76
|
+
"role": "admin",
|
|
77
|
+
"createdAt": "2025-10-13T10:12:52.341Z"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "b7a9e04f-e794-4375-991f-fb84da2edfb9",
|
|
81
|
+
"name": "Arlie Ledner-Murphy",
|
|
82
|
+
"email": "arlie_ledner-murphy4@yahoo.com",
|
|
83
|
+
"role": "editor",
|
|
84
|
+
"createdAt": "2025-08-15T12:20:50.677Z"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "7640ddff-8cfd-4372-9f93-a951a8c8d88e",
|
|
88
|
+
"name": "Kenton Spinka-Smitham",
|
|
89
|
+
"email": "kenton.spinka-smitham@gmail.com",
|
|
90
|
+
"role": "viewer",
|
|
91
|
+
"createdAt": "2024-06-04T16:14:35.485Z"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "e58c69df-2e74-47f7-85a3-12222a25e7a2",
|
|
95
|
+
"name": "Flo Kertzmann",
|
|
96
|
+
"email": "flo.kertzmann27@gmail.com",
|
|
97
|
+
"role": "admin",
|
|
98
|
+
"createdAt": "2024-03-29T04:26:08.480Z"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "ca1de04c-b235-4795-97b0-4be881783460",
|
|
102
|
+
"name": "Georgette Batz",
|
|
103
|
+
"email": "georgette.batz@gmail.com",
|
|
104
|
+
"role": "editor",
|
|
105
|
+
"createdAt": "2025-05-11T10:10:15.235Z"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "6245a95f-9312-4322-b42e-186f16fdd42a",
|
|
109
|
+
"name": "Bernie Rodriguez",
|
|
110
|
+
"email": "bernie_rodriguez@hotmail.com",
|
|
111
|
+
"role": "admin",
|
|
112
|
+
"createdAt": "2024-08-24T14:37:42.361Z"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "92780521-f5c4-4ac9-b765-edf1bf21b9d2",
|
|
116
|
+
"name": "Delaney Green",
|
|
117
|
+
"email": "delaney.green@gmail.com",
|
|
118
|
+
"role": "editor",
|
|
119
|
+
"createdAt": "2025-01-17T08:39:34.801Z"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "74b83e68-e91f-4a52-8c98-ec243b09ce5d",
|
|
123
|
+
"name": "Hattie Hodkiewicz",
|
|
124
|
+
"email": "hattie.hodkiewicz@yahoo.com",
|
|
125
|
+
"role": "admin",
|
|
126
|
+
"createdAt": "2024-06-16T13:59:11.091Z"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "52e967f2-9890-4de9-bbeb-2996bee71fd1",
|
|
130
|
+
"name": "Linwood Fritsch",
|
|
131
|
+
"email": "linwood_fritsch59@yahoo.com",
|
|
132
|
+
"role": "admin",
|
|
133
|
+
"createdAt": "2024-09-02T00:42:01.131Z"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "55b73722-76e5-49a0-8a2f-261f891b3e33",
|
|
137
|
+
"name": "Ernest Waelchi",
|
|
138
|
+
"email": "ernest_waelchi@hotmail.com",
|
|
139
|
+
"role": "editor",
|
|
140
|
+
"createdAt": "2025-01-18T07:54:09.862Z"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "f54a602b-a033-4a01-8c2a-313bdd6a34e0",
|
|
144
|
+
"name": "Larissa Stoltenberg",
|
|
145
|
+
"email": "larissa.stoltenberg@gmail.com",
|
|
146
|
+
"role": "editor",
|
|
147
|
+
"createdAt": "2025-10-14T13:01:56.105Z"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "96864fc2-d7ec-4604-a8a4-2df8240e1948",
|
|
151
|
+
"name": "Devonte Gleichner",
|
|
152
|
+
"email": "devonte.gleichner1@yahoo.com",
|
|
153
|
+
"role": "viewer",
|
|
154
|
+
"createdAt": "2025-09-30T19:31:38.201Z"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "6802b193-645b-4497-9aeb-30490795c11b",
|
|
158
|
+
"name": "Manuel Johnston",
|
|
159
|
+
"email": "manuel.johnston@yahoo.com",
|
|
160
|
+
"role": "viewer",
|
|
161
|
+
"createdAt": "2025-05-22T19:45:16.890Z"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "f728dbca-bd37-43ff-90be-29e0b4eff7dd",
|
|
165
|
+
"name": "Gayle Collins",
|
|
166
|
+
"email": "gayle.collins59@yahoo.com",
|
|
167
|
+
"role": "admin",
|
|
168
|
+
"createdAt": "2024-02-26T06:04:01.012Z"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "c5ae930d-0d8f-4cf5-8c67-adfc66b31544",
|
|
172
|
+
"name": "Nathen Lindgren",
|
|
173
|
+
"email": "nathen.lindgren98@gmail.com",
|
|
174
|
+
"role": "editor",
|
|
175
|
+
"createdAt": "2025-05-11T19:43:54.260Z"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"id": "f792f3fa-9832-432c-a50f-eef26cb2d338",
|
|
179
|
+
"name": "Payton Thiel",
|
|
180
|
+
"email": "payton.thiel87@hotmail.com",
|
|
181
|
+
"role": "admin",
|
|
182
|
+
"createdAt": "2025-10-11T16:11:45.839Z"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"id": "654b713a-1d77-49d5-ba94-ecaddbdba9c2",
|
|
186
|
+
"name": "Reinhold Bogisich",
|
|
187
|
+
"email": "reinhold.bogisich82@yahoo.com",
|
|
188
|
+
"role": "editor",
|
|
189
|
+
"createdAt": "2025-06-27T12:06:31.111Z"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "9fa4a8c1-c8f5-4ae1-beb1-4b19590dffb2",
|
|
193
|
+
"name": "Rhoda Grant",
|
|
194
|
+
"email": "rhoda.grant32@gmail.com",
|
|
195
|
+
"role": "viewer",
|
|
196
|
+
"createdAt": "2025-05-14T11:44:02.031Z"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"id": "cb31aa4f-26f6-4a64-bf6e-330a5d7f2dcc",
|
|
200
|
+
"name": "Zoie Cruickshank",
|
|
201
|
+
"email": "zoie_cruickshank13@yahoo.com",
|
|
202
|
+
"role": "viewer",
|
|
203
|
+
"createdAt": "2025-03-26T18:30:46.608Z"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "37194c47-0167-494b-8dc0-713f279b8058",
|
|
207
|
+
"name": "Broderick Keeling",
|
|
208
|
+
"email": "broderick.keeling7@hotmail.com",
|
|
209
|
+
"role": "admin",
|
|
210
|
+
"createdAt": "2025-02-18T20:56:11.343Z"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "b0e08bdb-c5d1-4e8d-97a8-b1032d3f52ca",
|
|
214
|
+
"name": "Curtis Nienow",
|
|
215
|
+
"email": "curtis_nienow@hotmail.com",
|
|
216
|
+
"role": "viewer",
|
|
217
|
+
"createdAt": "2025-04-20T09:18:49.178Z"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "dbb655f0-d97b-47de-b649-e39ab2be23f2",
|
|
221
|
+
"name": "Angelina Koepp",
|
|
222
|
+
"email": "angelina.koepp87@hotmail.com",
|
|
223
|
+
"role": "editor",
|
|
224
|
+
"createdAt": "2024-09-19T14:23:24.479Z"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"id": "5c2f7312-85d6-439b-b220-ba7dc9d31408",
|
|
228
|
+
"name": "Gennaro O'Reilly",
|
|
229
|
+
"email": "gennaro.oreilly@gmail.com",
|
|
230
|
+
"role": "admin",
|
|
231
|
+
"createdAt": "2025-01-05T18:55:38.434Z"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"id": "ad787a20-4b3a-4f1a-87d2-bdfa79d90eba",
|
|
235
|
+
"name": "Yazmin Wilderman",
|
|
236
|
+
"email": "yazmin.wilderman65@hotmail.com",
|
|
237
|
+
"role": "editor",
|
|
238
|
+
"createdAt": "2025-12-31T13:42:50.859Z"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"id": "be65accc-6d18-4055-96b6-735319a976d8",
|
|
242
|
+
"name": "Jalyn Mante",
|
|
243
|
+
"email": "jalyn.mante38@gmail.com",
|
|
244
|
+
"role": "editor",
|
|
245
|
+
"createdAt": "2025-01-25T01:31:22.554Z"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"id": "0ae3e0e5-1744-44c8-949b-4612a28b194f",
|
|
249
|
+
"name": "Rex Auer-Dietrich",
|
|
250
|
+
"email": "rex_auer-dietrich@yahoo.com",
|
|
251
|
+
"role": "viewer",
|
|
252
|
+
"createdAt": "2025-03-15T18:40:39.380Z"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"id": "de53c4d6-a197-492b-9d31-0a983697f2b6",
|
|
256
|
+
"name": "Dallas Jenkins",
|
|
257
|
+
"email": "dallas_jenkins99@yahoo.com",
|
|
258
|
+
"role": "admin",
|
|
259
|
+
"createdAt": "2025-06-13T11:48:00.024Z"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"id": "535181c3-8ea8-455a-9fa8-b708f2b3817c",
|
|
263
|
+
"name": "Ben Dicki",
|
|
264
|
+
"email": "ben_dicki92@hotmail.com",
|
|
265
|
+
"role": "editor",
|
|
266
|
+
"createdAt": "2024-04-21T09:59:11.384Z"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"id": "1c2dcb04-451e-4846-b798-e7fd3e1d6edc",
|
|
270
|
+
"name": "Kris Mueller",
|
|
271
|
+
"email": "kris.mueller40@gmail.com",
|
|
272
|
+
"role": "viewer",
|
|
273
|
+
"createdAt": "2024-09-09T23:58:24.622Z"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"id": "79c28625-102f-48f6-a487-1a39a20c70f0",
|
|
277
|
+
"name": "Rigoberto Walker",
|
|
278
|
+
"email": "rigoberto.walker14@yahoo.com",
|
|
279
|
+
"role": "admin",
|
|
280
|
+
"createdAt": "2024-03-14T20:44:51.649Z"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"id": "49862e73-56db-4c06-9704-c28303fcf718",
|
|
284
|
+
"name": "Jayce Morar",
|
|
285
|
+
"email": "jayce.morar48@yahoo.com",
|
|
286
|
+
"role": "admin",
|
|
287
|
+
"createdAt": "2025-06-23T00:11:32.499Z"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "fc5b74d0-e7aa-4ea9-9182-b8a01b110fb5",
|
|
291
|
+
"name": "Haylie Toy",
|
|
292
|
+
"email": "haylie_toy66@hotmail.com",
|
|
293
|
+
"role": "admin",
|
|
294
|
+
"createdAt": "2024-03-12T22:15:11.704Z"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"id": "4c96319c-a80f-4c4f-899b-ca25e35679f3",
|
|
298
|
+
"name": "Dimitri Wisoky",
|
|
299
|
+
"email": "dimitri_wisoky64@gmail.com",
|
|
300
|
+
"role": "viewer",
|
|
301
|
+
"createdAt": "2025-09-21T15:52:29.917Z"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"id": "bca28fe0-22bd-438d-bb89-849bdac2703b",
|
|
305
|
+
"name": "Delta Spinka",
|
|
306
|
+
"email": "delta.spinka80@gmail.com",
|
|
307
|
+
"role": "editor",
|
|
308
|
+
"createdAt": "2025-06-19T21:00:09.410Z"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "c0b3f552-4ef5-47be-a966-b095c197a198",
|
|
312
|
+
"name": "Fidel Abshire",
|
|
313
|
+
"email": "fidel_abshire80@hotmail.com",
|
|
314
|
+
"role": "viewer",
|
|
315
|
+
"createdAt": "2024-12-30T05:23:51.184Z"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"id": "87256139-bfea-46ac-b16d-69925500d484",
|
|
319
|
+
"name": "Eva Schamberger",
|
|
320
|
+
"email": "eva.schamberger@gmail.com",
|
|
321
|
+
"role": "admin",
|
|
322
|
+
"createdAt": "2025-08-09T17:34:26.415Z"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"id": "6bc292ca-f104-443e-834c-7c1701e2865e",
|
|
326
|
+
"name": "Bianka Kunze",
|
|
327
|
+
"email": "bianka_kunze@hotmail.com",
|
|
328
|
+
"role": "admin",
|
|
329
|
+
"createdAt": "2024-11-02T03:18:35.545Z"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"id": "97f95123-4d88-41db-a1b8-1772fda76a80",
|
|
333
|
+
"name": "Willow Donnelly",
|
|
334
|
+
"email": "willow.donnelly@yahoo.com",
|
|
335
|
+
"role": "admin",
|
|
336
|
+
"createdAt": "2024-07-08T01:14:37.879Z"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"id": "ed37fc01-7e87-41ad-b6cf-384c9ac6e82b",
|
|
340
|
+
"name": "Nadine Thiel",
|
|
341
|
+
"email": "nadine_thiel90@gmail.com",
|
|
342
|
+
"role": "viewer",
|
|
343
|
+
"createdAt": "2024-04-12T20:38:34.832Z"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"id": "91ec8f6f-aa2e-4620-988b-e1b2dd8b57d7",
|
|
347
|
+
"name": "Sibyl Kiehn",
|
|
348
|
+
"email": "sibyl_kiehn33@hotmail.com",
|
|
349
|
+
"role": "viewer",
|
|
350
|
+
"createdAt": "2025-08-26T18:57:41.524Z"
|
|
351
|
+
}
|
|
352
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Error carrying an HTTP status; errorHandler turns it into `{ error, details }`. */
|
|
2
|
+
export class HttpError extends Error {
|
|
3
|
+
constructor(
|
|
4
|
+
readonly status: number,
|
|
5
|
+
message: string,
|
|
6
|
+
readonly details?: unknown,
|
|
7
|
+
) {
|
|
8
|
+
super(message)
|
|
9
|
+
this.name = 'HttpError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const notFound = (resource: string, id: string): HttpError =>
|
|
14
|
+
new HttpError(404, `${resource} ${id} not found`)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const MAX_LIMIT = 100
|
|
4
|
+
|
|
5
|
+
/** Shared list contract: `{ data, page, limit, total }` — the FE table relies on it. */
|
|
6
|
+
export interface Page<T> {
|
|
7
|
+
data: T[]
|
|
8
|
+
page: number
|
|
9
|
+
limit: number
|
|
10
|
+
total: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PaginationQuerySchema = z.object({
|
|
14
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
15
|
+
limit: z.coerce.number().int().min(1).max(MAX_LIMIT).default(20),
|
|
16
|
+
})
|
|
17
|
+
export type PaginationQuery = z.infer<typeof PaginationQuerySchema>
|
|
18
|
+
|
|
19
|
+
/** `sort=name` ascending, `sort=-name` descending; only whitelisted fields. */
|
|
20
|
+
export const sortSchema = <const F extends readonly [string, ...string[]]>(
|
|
21
|
+
fields: F,
|
|
22
|
+
) =>
|
|
23
|
+
z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(
|
|
26
|
+
new RegExp(`^-?(${fields.join('|')})$`),
|
|
27
|
+
`sort must be one of ${fields.join(', ')} (prefix - for desc)`,
|
|
28
|
+
)
|
|
29
|
+
.optional()
|
|
30
|
+
|
|
31
|
+
export const paginate = <T>(
|
|
32
|
+
rows: readonly T[],
|
|
33
|
+
{ page, limit }: PaginationQuery,
|
|
34
|
+
): Page<T> => ({
|
|
35
|
+
data: rows.slice((page - 1) * limit, page * limit),
|
|
36
|
+
page,
|
|
37
|
+
limit,
|
|
38
|
+
total: rows.length,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export const applySort = <T extends object>(
|
|
42
|
+
rows: readonly T[],
|
|
43
|
+
sort: string | undefined,
|
|
44
|
+
): T[] => {
|
|
45
|
+
if (!sort) return [...rows]
|
|
46
|
+
const desc = sort.startsWith('-')
|
|
47
|
+
const field = (desc ? sort.slice(1) : sort) as keyof T
|
|
48
|
+
const dir = desc ? -1 : 1
|
|
49
|
+
return [...rows].sort((a, b) => {
|
|
50
|
+
const x = a[field]
|
|
51
|
+
const y = b[field]
|
|
52
|
+
if (typeof x === 'number' && typeof y === 'number') return (x - y) * dir
|
|
53
|
+
return String(x).localeCompare(String(y)) * dir
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ordersRepository,
|
|
3
|
+
productsRepository,
|
|
4
|
+
usersRepository,
|
|
5
|
+
} from '../../data/repository'
|
|
6
|
+
import { notFound } from '../../lib/http-error'
|
|
7
|
+
import type { CreateOrderBody, Order } from './orders.schema'
|
|
8
|
+
|
|
9
|
+
const money = (n: number): number => Math.round(n * 100) / 100
|
|
10
|
+
|
|
11
|
+
/** Resolves prices server-side; throws 404 for unknown user/product. */
|
|
12
|
+
export const createOrder = ({ userId, items }: CreateOrderBody): Order => {
|
|
13
|
+
if (!usersRepository.findById(userId)) throw notFound('User', userId)
|
|
14
|
+
const priced = items.map(({ productId, qty }) => {
|
|
15
|
+
const product = productsRepository.findById(productId)
|
|
16
|
+
if (!product) throw notFound('Product', productId)
|
|
17
|
+
return { productId, qty, unitPrice: product.price }
|
|
18
|
+
})
|
|
19
|
+
return ordersRepository.insert({
|
|
20
|
+
id: crypto.randomUUID(),
|
|
21
|
+
userId,
|
|
22
|
+
items: priced,
|
|
23
|
+
total: money(priced.reduce((sum, i) => sum + i.qty * i.unitPrice, 0)),
|
|
24
|
+
createdAt: new Date().toISOString(),
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export { OrderSchema, type Order } from '../../data/schemas'
|
|
4
|
+
|
|
5
|
+
export const CreateOrderBodySchema = z.object({
|
|
6
|
+
userId: z.string().min(1),
|
|
7
|
+
items: z
|
|
8
|
+
.array(z.object({ productId: z.string().min(1), qty: z.int().min(1) }))
|
|
9
|
+
.min(1),
|
|
10
|
+
})
|
|
11
|
+
export type CreateOrderBody = z.infer<typeof CreateOrderBodySchema>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { productsRepository } from '../../data/repository'
|
|
2
|
+
import { type Page, applySort, paginate } from '../../lib/pagination'
|
|
3
|
+
import type { Product, ProductsQuery } from './products.schema'
|
|
4
|
+
|
|
5
|
+
export const searchProducts = ({
|
|
6
|
+
category,
|
|
7
|
+
sort,
|
|
8
|
+
page,
|
|
9
|
+
limit,
|
|
10
|
+
}: ProductsQuery): Page<Product> => {
|
|
11
|
+
const all = productsRepository.all()
|
|
12
|
+
const filtered = category ? all.filter((p) => p.category === category) : all
|
|
13
|
+
return paginate(applySort(filtered, sort), { page, limit })
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const findProduct = (id: string): Product | undefined =>
|
|
17
|
+
productsRepository.findById(id)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { PRODUCT_CATEGORIES } from '../../data/schemas'
|
|
4
|
+
import { PaginationQuerySchema, sortSchema } from '../../lib/pagination'
|
|
5
|
+
|
|
6
|
+
export { ProductSchema, type Product } from '../../data/schemas'
|
|
7
|
+
|
|
8
|
+
export const PRODUCT_SORT_FIELDS = [
|
|
9
|
+
'name',
|
|
10
|
+
'category',
|
|
11
|
+
'price',
|
|
12
|
+
'stock',
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const ProductsQuerySchema = PaginationQuerySchema.extend({
|
|
16
|
+
category: z.enum(PRODUCT_CATEGORIES).optional(),
|
|
17
|
+
sort: sortSchema(PRODUCT_SORT_FIELDS),
|
|
18
|
+
})
|
|
19
|
+
export type ProductsQuery = z.infer<typeof ProductsQuerySchema>
|
|
20
|
+
|
|
21
|
+
export const ProductIdParamsSchema = z.object({ id: z.string().min(1) })
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ordersRepository,
|
|
3
|
+
productsRepository,
|
|
4
|
+
usersRepository,
|
|
5
|
+
} from '../../data/repository'
|
|
6
|
+
|
|
7
|
+
export interface Stats {
|
|
8
|
+
users: number
|
|
9
|
+
products: number
|
|
10
|
+
orders: number
|
|
11
|
+
revenue: number
|
|
12
|
+
topCategory: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const computeStats = (): Stats => {
|
|
16
|
+
const orders = ordersRepository.all()
|
|
17
|
+
const revenueByCategory = new Map<string, number>()
|
|
18
|
+
for (const order of orders) {
|
|
19
|
+
for (const item of order.items) {
|
|
20
|
+
const category =
|
|
21
|
+
productsRepository.findById(item.productId)?.category ?? 'unknown'
|
|
22
|
+
revenueByCategory.set(
|
|
23
|
+
category,
|
|
24
|
+
(revenueByCategory.get(category) ?? 0) + item.qty * item.unitPrice,
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const top = [...revenueByCategory.entries()].sort((a, b) => b[1] - a[1])[0]
|
|
29
|
+
return {
|
|
30
|
+
users: usersRepository.all().length,
|
|
31
|
+
products: productsRepository.all().length,
|
|
32
|
+
orders: orders.length,
|
|
33
|
+
revenue:
|
|
34
|
+
Math.round(orders.reduce((sum, o) => sum + o.total, 0) * 100) / 100,
|
|
35
|
+
topCategory: top?.[0] ?? null,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { usersRepository } from '../../data/repository'
|
|
2
|
+
import { type Page, applySort, paginate } from '../../lib/pagination'
|
|
3
|
+
import type { User, UsersQuery } from './users.schema'
|
|
4
|
+
|
|
5
|
+
const matches = (user: User, q: string): boolean => {
|
|
6
|
+
const needle = q.toLowerCase()
|
|
7
|
+
return (
|
|
8
|
+
user.name.toLowerCase().includes(needle) ||
|
|
9
|
+
user.email.toLowerCase().includes(needle)
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const searchUsers = ({
|
|
14
|
+
q,
|
|
15
|
+
sort,
|
|
16
|
+
page,
|
|
17
|
+
limit,
|
|
18
|
+
}: UsersQuery): Page<User> => {
|
|
19
|
+
const filtered = q
|
|
20
|
+
? usersRepository.all().filter((u) => matches(u, q))
|
|
21
|
+
: usersRepository.all()
|
|
22
|
+
return paginate(applySort(filtered, sort), { page, limit })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const findUser = (id: string): User | undefined =>
|
|
26
|
+
usersRepository.findById(id)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { PaginationQuerySchema, sortSchema } from '../../lib/pagination'
|
|
4
|
+
|
|
5
|
+
export { UserSchema, type User } from '../../data/schemas'
|
|
6
|
+
|
|
7
|
+
export const USER_SORT_FIELDS = ['name', 'email', 'role', 'createdAt'] as const
|
|
8
|
+
|
|
9
|
+
export const UsersQuerySchema = PaginationQuerySchema.extend({
|
|
10
|
+
q: z.string().trim().min(1).optional(),
|
|
11
|
+
sort: sortSchema(USER_SORT_FIELDS),
|
|
12
|
+
})
|
|
13
|
+
export type UsersQuery = z.infer<typeof UsersQuerySchema>
|
|
14
|
+
|
|
15
|
+
export const UserIdParamsSchema = z.object({ id: z.string().min(1) })
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import request from 'supertest'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { createApp } from '../src/app'
|
|
5
|
+
|
|
6
|
+
describe('GET /docs.json', () => {
|
|
7
|
+
it('serves the parsed openapi.yaml with all 7 paths', async () => {
|
|
8
|
+
const res = await request(createApp()).get('/docs.json')
|
|
9
|
+
expect(res.status).toBe(200)
|
|
10
|
+
expect(res.body.openapi).toBe('3.1.0')
|
|
11
|
+
expect(Object.keys(res.body.paths).sort()).toEqual(
|
|
12
|
+
[
|
|
13
|
+
'/api/health',
|
|
14
|
+
'/api/users',
|
|
15
|
+
'/api/users/{id}',
|
|
16
|
+
'/api/products',
|
|
17
|
+
'/api/products/{id}',
|
|
18
|
+
'/api/orders',
|
|
19
|
+
'/api/stats',
|
|
20
|
+
].sort(),
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import request from 'supertest'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { createApp } from '../src/app'
|
|
5
|
+
|
|
6
|
+
describe('GET /api/health', () => {
|
|
7
|
+
it('returns ok', async () => {
|
|
8
|
+
const res = await request(createApp()).get('/api/health')
|
|
9
|
+
expect(res.status).toBe(200)
|
|
10
|
+
expect(res.body.status).toBe('ok')
|
|
11
|
+
expect(typeof res.body.uptime).toBe('number')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('unknown route → 404 with stable shape', async () => {
|
|
15
|
+
const res = await request(createApp()).get('/nope')
|
|
16
|
+
expect(res.status).toBe(404)
|
|
17
|
+
expect(res.body).toEqual({ error: 'Route GET /nope not found' })
|
|
18
|
+
})
|
|
19
|
+
})
|