create-restack-pattern 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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/index.js +73 -0
- package/package.json +26 -0
- package/template/backend/.env.example +8 -0
- package/template/backend/README.md +8 -0
- package/template/backend/api/index.ts +9 -0
- package/template/backend/drizzle/0000_grey_lethal_legion.sql +19 -0
- package/template/backend/drizzle/meta/0000_snapshot.json +137 -0
- package/template/backend/drizzle/meta/_journal.json +13 -0
- package/template/backend/drizzle.config.ts +11 -0
- package/template/backend/gitignore +31 -0
- package/template/backend/package.json +34 -0
- package/template/backend/public/.gitkeep +0 -0
- package/template/backend/src/config/.gitkeep +0 -0
- package/template/backend/src/config/env.ts +22 -0
- package/template/backend/src/domains/auth/.gitkeep +0 -0
- package/template/backend/src/domains/auth/auth.model.ts +20 -0
- package/template/backend/src/domains/auth/auth.repo.ts +51 -0
- package/template/backend/src/domains/auth/auth.routes.ts +93 -0
- package/template/backend/src/domains/auth/auth.service.test.ts +143 -0
- package/template/backend/src/domains/auth/auth.service.ts +97 -0
- package/template/backend/src/domains/auth/auth.types.ts +7 -0
- package/template/backend/src/domains/user/.gitkeep +0 -0
- package/template/backend/src/domains/user/user.model.ts +14 -0
- package/template/backend/src/domains/user/user.repo.ts +29 -0
- package/template/backend/src/domains/user/user.routes.test.ts +82 -0
- package/template/backend/src/domains/user/user.routes.ts +48 -0
- package/template/backend/src/domains/user/user.service.ts +40 -0
- package/template/backend/src/hono-app.ts +42 -0
- package/template/backend/src/index.ts +13 -0
- package/template/backend/src/shared/db/.gitkeep +0 -0
- package/template/backend/src/shared/db/index.ts +11 -0
- package/template/backend/src/shared/logger/logger.ts +15 -0
- package/template/backend/src/shared/middlewares/.gitkeep +0 -0
- package/template/backend/src/shared/middlewares/rate-limit.ts +43 -0
- package/template/backend/src/shared/middlewares/require-auth.test.ts +51 -0
- package/template/backend/src/shared/middlewares/require-auth.ts +31 -0
- package/template/backend/tsconfig.json +16 -0
- package/template/backend/vercel.json +6 -0
- package/template/frontend/AGENTS.md +5 -0
- package/template/frontend/CLAUDE.md +1 -0
- package/template/frontend/README.md +36 -0
- package/template/frontend/app/(auth)/login/page.tsx +24 -0
- package/template/frontend/app/(auth)/register/page.tsx +24 -0
- package/template/frontend/app/dashboard/page.tsx +29 -0
- package/template/frontend/app/globals.css +131 -0
- package/template/frontend/app/icon.png +0 -0
- package/template/frontend/app/layout.tsx +36 -0
- package/template/frontend/app/page.tsx +33 -0
- package/template/frontend/app/profile/page.tsx +23 -0
- package/template/frontend/components/ui/button.tsx +67 -0
- package/template/frontend/components/ui/card.tsx +103 -0
- package/template/frontend/components/ui/input.tsx +19 -0
- package/template/frontend/components/ui/label.tsx +24 -0
- package/template/frontend/components.json +24 -0
- package/template/frontend/domains/auth/components/.gitkeep +0 -0
- package/template/frontend/domains/auth/components/login-form.tsx +75 -0
- package/template/frontend/domains/auth/components/logout-button.tsx +30 -0
- package/template/frontend/domains/auth/components/register-form.tsx +87 -0
- package/template/frontend/domains/auth/hooks/.gitkeep +0 -0
- package/template/frontend/domains/auth/hooks/use-login.ts +17 -0
- package/template/frontend/domains/auth/hooks/use-register.ts +17 -0
- package/template/frontend/domains/auth/services/.gitkeep +0 -0
- package/template/frontend/domains/auth/services/auth.api.ts +27 -0
- package/template/frontend/domains/user/components/.gitkeep +0 -0
- package/template/frontend/domains/user/components/profile-card.tsx +33 -0
- package/template/frontend/domains/user/hooks/use-profile.ts +39 -0
- package/template/frontend/domains/user/services/user.api.ts +21 -0
- package/template/frontend/eslint.config.mjs +18 -0
- package/template/frontend/gitignore +43 -0
- package/template/frontend/lib/utils.ts +11 -0
- package/template/frontend/next.config.ts +7 -0
- package/template/frontend/package.json +35 -0
- package/template/frontend/postcss.config.mjs +7 -0
- package/template/frontend/public/favicon.ico +0 -0
- package/template/frontend/public/logo.png +0 -0
- package/template/frontend/shared/components/require-auth.tsx +25 -0
- package/template/frontend/shared/components/ui/.gitkeep +0 -0
- package/template/frontend/shared/hooks/.gitkeep +0 -0
- package/template/frontend/shared/hooks/use-auth-mutation.ts +37 -0
- package/template/frontend/shared/lib/.gitkeep +0 -0
- package/template/frontend/shared/lib/api-client.ts +73 -0
- package/template/frontend/tsconfig.json +34 -0
- package/template/gitignore +35 -0
- package/template/package.json +13 -0
- package/template/packages/shared/package.json +24 -0
- package/template/packages/shared/src/index.ts +2 -0
- package/template/packages/shared/src/schemas/auth.schema.ts +20 -0
- package/template/packages/shared/src/schemas/user.schema.ts +16 -0
- package/template/packages/shared/tsconfig.json +51 -0
- package/template/pnpm-workspace.yaml +4 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"next-env.d.ts",
|
|
27
|
+
"**/*.ts",
|
|
28
|
+
"**/*.tsx",
|
|
29
|
+
".next/types/**/*.ts",
|
|
30
|
+
".next/dev/types/**/*.ts",
|
|
31
|
+
"**/*.mts"
|
|
32
|
+
],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Dependencies (Abaikan node_modules di folder mana pun)
|
|
2
|
+
**/node_modules/
|
|
3
|
+
|
|
4
|
+
# Next.js build output (Abaikan .next di folder mana pun)
|
|
5
|
+
**/.next/
|
|
6
|
+
**/out/
|
|
7
|
+
|
|
8
|
+
# Build outputs
|
|
9
|
+
**/dist/
|
|
10
|
+
**/build/
|
|
11
|
+
**/.output/
|
|
12
|
+
|
|
13
|
+
# Env files (Abaikan semua file env di folder mana pun)
|
|
14
|
+
**/.env*
|
|
15
|
+
**/*.env
|
|
16
|
+
!**/.env.example
|
|
17
|
+
|
|
18
|
+
# Logs
|
|
19
|
+
**/logs/
|
|
20
|
+
**/*.log
|
|
21
|
+
**/npm-debug.log*
|
|
22
|
+
**/yarn-debug.log*
|
|
23
|
+
**/yarn-error.log*
|
|
24
|
+
**/pnpm-debug.log*
|
|
25
|
+
|
|
26
|
+
# OS Files
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
29
|
+
|
|
30
|
+
# IDE settings
|
|
31
|
+
.vscode/
|
|
32
|
+
.idea/
|
|
33
|
+
|
|
34
|
+
# Claude Code local overrides (personal, not shared with the team)
|
|
35
|
+
.claude/settings.local.json
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@restack/shared",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^4.4.3"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.8.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
/** Zod validation schema for login form and request payload. */
|
|
4
|
+
export const LoginSchema = z.object({
|
|
5
|
+
email: z.email().max(254),
|
|
6
|
+
password: z.string().min(8).max(128),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
/** Zod validation schema for registering a new account. */
|
|
10
|
+
export const RegisterSchema = z.object({
|
|
11
|
+
name: z.string().min(1).max(100),
|
|
12
|
+
email: z.email().max(254),
|
|
13
|
+
password: z.string().min(8).max(128),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
/** TypeScript input type inferred from LoginSchema. */
|
|
17
|
+
export type LoginInput = z.infer<typeof LoginSchema>
|
|
18
|
+
|
|
19
|
+
/** TypeScript input type inferred from RegisterSchema. */
|
|
20
|
+
export type RegisterInput = z.infer<typeof RegisterSchema>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
/** Public user shape returned by auth endpoints (register/login/refresh) — never includes the password hash. */
|
|
4
|
+
export interface AuthUser {
|
|
5
|
+
id: number
|
|
6
|
+
name: string
|
|
7
|
+
email: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Zod validation schema for updating user profile (partial updates). */
|
|
11
|
+
export const UpdateProfileSchema = z.object({
|
|
12
|
+
name: z.string().min(1).max(100).optional(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
/** TypeScript input type inferred from UpdateProfileSchema. */
|
|
16
|
+
export type UpdateProfileInput = z.infer<typeof UpdateProfileSchema>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Menentukan direktori output hasil compile
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
/**
|
|
6
|
+
* @target ESNext
|
|
7
|
+
* @description Specifies the JavaScript version for the output files.
|
|
8
|
+
* Using 'ESNext' targets the latest ECMAScript features supported by modern runtimes.
|
|
9
|
+
*/
|
|
10
|
+
"target": "ESNext",
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @module NodeNext
|
|
14
|
+
* @description Specifies the module system for the output code.
|
|
15
|
+
* 'NodeNext' is used to support modern Node.js ECMAScript Modules (ESM) with import/export syntax.
|
|
16
|
+
*/
|
|
17
|
+
"module": "NodeNext",
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @moduleResolution NodeNext
|
|
21
|
+
* @description Specifies how TypeScript resolves module imports.
|
|
22
|
+
* 'NodeNext' aligns with modern Node.js ESM module resolution rules, including mandatory file extensions for relative paths.
|
|
23
|
+
*/
|
|
24
|
+
"moduleResolution": "NodeNext",
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @strict true
|
|
28
|
+
* @description Enables all strict type-checking options to prevent common runtime bugs.
|
|
29
|
+
*/
|
|
30
|
+
"strict": true,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @skipLibCheck true
|
|
34
|
+
* @description Skips type checking of declaration files (.d.ts) in node_modules to speed up compile time.
|
|
35
|
+
*/
|
|
36
|
+
"skipLibCheck": true,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @declaration true
|
|
40
|
+
* @description Generates corresponding '.d.ts' declaration files so consuming packages get full type autocomplete.
|
|
41
|
+
*/
|
|
42
|
+
"declaration": true
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @exclude node_modules, dist
|
|
47
|
+
* @description Excludes node_modules and the previous build output — without excluding
|
|
48
|
+
* dist, tsc picks up its own prior .d.ts output as input and fails with TS5055 on rebuild.
|
|
49
|
+
*/
|
|
50
|
+
"exclude": ["node_modules", "dist"]
|
|
51
|
+
}
|