better-ts-stack 2.0.2 → 2.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 +114 -113
- package/dist/args.js +24 -20
- package/dist/builder/buildPlanner.js +1 -1
- package/dist/builder/configGenerator.js +1 -5
- package/dist/builder/index.js +15 -3
- package/dist/builder/moduleSelector.js +4 -2
- package/dist/builder/readmeGenerator.js +101 -0
- package/dist/builder/templateContext.js +30 -0
- package/dist/index.js +7 -1
- package/dist/output/nextSteps.js +19 -22
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/stack.js +21 -2
- package/dist/types/index.js +1 -0
- package/dist/ui/messages.js +2 -1
- package/dist/validators/index.js +5 -2
- package/package.json +1 -1
- package/templates/backend/express/config.json +42 -40
- package/templates/backend/express/src/env.ts.hbs +39 -0
- package/templates/backend/express/src/index.ts.hbs +111 -75
- package/templates/backend/nestjs/config.json +43 -41
- package/templates/backend/nestjs/src/app.module.ts.hbs +13 -0
- package/templates/backend/nestjs/src/env.ts.hbs +39 -0
- package/templates/backend/nestjs/src/main.ts +3 -2
- package/templates/frontend/nextjs/app/page.tsx.hbs +98 -97
- package/templates/frontend/tanstack/config.json +2 -2
- package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -101
- package/templates/frontend/tanstack/vite.config.ts +22 -14
- package/templates/modules/auth/express/config.json +20 -20
- package/templates/modules/auth/express/src/routes/auth.ts.hbs +27 -19
- package/templates/modules/auth/nestjs/config.json +20 -20
- package/templates/modules/auth/nestjs/src/auth/{auth.controller.ts → auth.controller.ts.hbs} +15 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +132 -134
- package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +46 -48
- package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +150 -152
- package/templates/modules/docker/.dockerignore +1 -0
- package/templates/modules/docker/Dockerfile.hbs +147 -136
- package/templates/modules/docker/docker-compose.yml.hbs +96 -1
- package/templates/modules/rate-limit/express/config.json +12 -0
- package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +21 -0
- package/templates/modules/rate-limit/nestjs/config.json +12 -0
|
@@ -1,97 +1,98 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
|
-
|
|
3
|
-
import { ArrowRight } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
import { buttonVariants } from "@/components/ui/button";
|
|
6
|
-
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
7
|
-
import { cn } from "@/lib/utils";
|
|
8
|
-
|
|
9
|
-
const featureList = [
|
|
10
|
-
"Next.js 16 App Router",
|
|
11
|
-
"React 19 and TypeScript",
|
|
12
|
-
"Tailwind CSS v4",
|
|
13
|
-
{{#if useAuth}}"Better Auth-ready session flow",{{/if}}
|
|
14
|
-
{{#if (eq database "prisma")}}"Prisma database tooling",{{/if}}
|
|
15
|
-
{{#if (eq database "drizzle")}}"Drizzle database tooling",{{/if}}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<span
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
|
|
3
|
+
import { ArrowRight } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
6
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
const featureList = [
|
|
10
|
+
"Next.js 16 App Router",
|
|
11
|
+
"React 19 and TypeScript",
|
|
12
|
+
"Tailwind CSS v4",
|
|
13
|
+
{{#if useAuth}}"Better Auth-ready session flow",{{/if}}
|
|
14
|
+
{{#if (eq database "prisma")}}"Prisma database tooling",{{/if}}
|
|
15
|
+
{{#if (eq database "drizzle")}}"Drizzle database tooling",{{/if}}
|
|
16
|
+
{{#if (eq database "mongoose")}}"Mongoose database tooling",{{/if}}
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export default function Home() {
|
|
20
|
+
return (
|
|
21
|
+
<main className="min-h-screen bg-background text-foreground">
|
|
22
|
+
<div className="mx-auto flex min-h-screen max-w-6xl flex-col justify-center gap-12 px-6 py-16 sm:px-10 lg:px-12">
|
|
23
|
+
<section className="grid gap-10 lg:grid-cols-[1.2fr_0.8fr] lg:items-center">
|
|
24
|
+
<div className="space-y-6">
|
|
25
|
+
<span className="inline-flex w-fit items-center rounded-full border border-border bg-card px-3 py-1 text-xs font-medium uppercase tracking-[0.24em] text-muted-foreground shadow-sm">
|
|
26
|
+
Created with better-ts-stack
|
|
27
|
+
</span>
|
|
28
|
+
<div className="space-y-4">
|
|
29
|
+
<h1 className="max-w-3xl text-4xl font-semibold tracking-tight sm:text-5xl">
|
|
30
|
+
Ship your stack faster with a polished TypeScript foundation.
|
|
31
|
+
</h1>
|
|
32
|
+
<p className="max-w-2xl text-base leading-7 text-muted-foreground sm:text-lg">
|
|
33
|
+
Your project already includes the core app shell, database wiring,
|
|
34
|
+
and a shadcn-compatible UI foundation so you can keep building
|
|
35
|
+
instead of setting up boilerplate.
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
<div className="flex flex-col gap-3 sm:flex-row">
|
|
39
|
+
{{#if useAuth}}
|
|
40
|
+
<Link
|
|
41
|
+
href="/sign-up"
|
|
42
|
+
className={cn(buttonVariants({ size: "lg" }), "gap-2")}
|
|
43
|
+
>
|
|
44
|
+
Create an account
|
|
45
|
+
<ArrowRight className="size-4" />
|
|
46
|
+
</Link>
|
|
47
|
+
<Link
|
|
48
|
+
href="/sign-in"
|
|
49
|
+
className={buttonVariants({ variant: "outline", size: "lg" })}
|
|
50
|
+
>
|
|
51
|
+
Login
|
|
52
|
+
</Link>
|
|
53
|
+
{{else}}
|
|
54
|
+
<Link
|
|
55
|
+
href="https://better-ts-stack.abdullahtech.me/docs"
|
|
56
|
+
target="_blank"
|
|
57
|
+
rel="noreferrer"
|
|
58
|
+
className={cn(buttonVariants({ size: "lg" }), "gap-2")}
|
|
59
|
+
>
|
|
60
|
+
Explore the docs
|
|
61
|
+
<ArrowRight className="size-4" />
|
|
62
|
+
</Link>
|
|
63
|
+
<Link
|
|
64
|
+
href="https://nextjs.org/docs"
|
|
65
|
+
target="_blank"
|
|
66
|
+
rel="noreferrer"
|
|
67
|
+
className={buttonVariants({ variant: "outline", size: "lg" })}
|
|
68
|
+
>
|
|
69
|
+
Next.js guide
|
|
70
|
+
</Link>
|
|
71
|
+
{{/if}}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<Card className="border-border bg-card shadow-sm">
|
|
76
|
+
<CardHeader>
|
|
77
|
+
<CardTitle>Included in this starter</CardTitle>
|
|
78
|
+
</CardHeader>
|
|
79
|
+
<CardContent className="space-y-4">
|
|
80
|
+
<ul className="space-y-3 text-sm text-muted-foreground">
|
|
81
|
+
{featureList.map((feature) => (
|
|
82
|
+
<li key={feature} className="flex items-center gap-3">
|
|
83
|
+
<span className="size-2 rounded-full bg-primary" />
|
|
84
|
+
<span>{feature}</span>
|
|
85
|
+
</li>
|
|
86
|
+
))}
|
|
87
|
+
</ul>
|
|
88
|
+
<div className="rounded-2xl border border-border bg-muted px-4 py-3 text-sm text-muted-foreground">
|
|
89
|
+
Start editing <code className="font-mono">app/page.tsx</code> and
|
|
90
|
+
shape the project around your product instead of setup chores.
|
|
91
|
+
</div>
|
|
92
|
+
</CardContent>
|
|
93
|
+
</Card>
|
|
94
|
+
</section>
|
|
95
|
+
</div>
|
|
96
|
+
</main>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite dev",
|
|
8
8
|
"build": "vite build",
|
|
9
|
-
"start": "
|
|
9
|
+
"start": "node --env-file-if-exists=.env .output/server/index.mjs",
|
|
10
10
|
"preview": "vite preview",
|
|
11
11
|
"type:check": "tsc --noEmit",
|
|
12
12
|
"lint": "eslint src"
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"lucide-react": "^1.41.0",
|
|
24
24
|
"react": "^19.2.8",
|
|
25
25
|
"react-dom": "^19.2.8",
|
|
26
|
-
"srvx": "^1.0.5",
|
|
27
26
|
"tailwind-merge": "^3.6.0"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
@@ -34,6 +33,7 @@
|
|
|
34
33
|
"@types/react-dom": "^19.2.7",
|
|
35
34
|
"@vitejs/plugin-react": "^6.1.2",
|
|
36
35
|
"eslint": "^10.10.0",
|
|
36
|
+
"nitro": "^3.0.260903-beta",
|
|
37
37
|
"tailwindcss": "^4.3.3",
|
|
38
38
|
"typescript": "^6.0.3",
|
|
39
39
|
"typescript-eslint": "^8.69.0",
|
|
@@ -1,102 +1,103 @@
|
|
|
1
|
-
import { createFileRoute{{#if useAuth}}, Link{{/if}} } from "@tanstack/react-router";
|
|
2
|
-
import { ArrowRight } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
import { buttonVariants } from "~/components/ui/button";
|
|
5
|
-
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
|
|
6
|
-
import { cn } from "~/lib/utils";
|
|
7
|
-
|
|
8
|
-
export const Route = createFileRoute("/")({
|
|
9
|
-
component: Home,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const featureList = [
|
|
13
|
-
"TanStack Start SSR",
|
|
14
|
-
"TanStack Router and Query",
|
|
15
|
-
"React 19 and TypeScript",
|
|
16
|
-
"Tailwind CSS v4",
|
|
17
|
-
{{#if useAuth}}"Better Auth-ready session flow",{{/if}}
|
|
18
|
-
{{#if (eq database "prisma")}}"Prisma database tooling",{{/if}}
|
|
19
|
-
{{#if (eq database "drizzle")}}"Drizzle database tooling",{{/if}}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<span
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
1
|
+
import { createFileRoute{{#if useAuth}}, Link{{/if}} } from "@tanstack/react-router";
|
|
2
|
+
import { ArrowRight } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
import { buttonVariants } from "~/components/ui/button";
|
|
5
|
+
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
|
|
6
|
+
import { cn } from "~/lib/utils";
|
|
7
|
+
|
|
8
|
+
export const Route = createFileRoute("/")({
|
|
9
|
+
component: Home,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const featureList = [
|
|
13
|
+
"TanStack Start SSR",
|
|
14
|
+
"TanStack Router and Query",
|
|
15
|
+
"React 19 and TypeScript",
|
|
16
|
+
"Tailwind CSS v4",
|
|
17
|
+
{{#if useAuth}}"Better Auth-ready session flow",{{/if}}
|
|
18
|
+
{{#if (eq database "prisma")}}"Prisma database tooling",{{/if}}
|
|
19
|
+
{{#if (eq database "drizzle")}}"Drizzle database tooling",{{/if}}
|
|
20
|
+
{{#if (eq database "mongoose")}}"Mongoose database tooling",{{/if}}
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
function Home() {
|
|
24
|
+
return (
|
|
25
|
+
<main className="min-h-screen bg-background text-foreground">
|
|
26
|
+
<div className="mx-auto flex min-h-screen max-w-6xl flex-col justify-center gap-12 px-6 py-16 sm:px-10 lg:px-12">
|
|
27
|
+
<section className="grid gap-10 lg:grid-cols-[1.2fr_0.8fr] lg:items-center">
|
|
28
|
+
<div className="space-y-6">
|
|
29
|
+
<span className="inline-flex w-fit items-center rounded-full border border-border bg-card px-3 py-1 text-xs font-medium uppercase tracking-[0.24em] text-muted-foreground shadow-sm">
|
|
30
|
+
Created with better-ts-stack
|
|
31
|
+
</span>
|
|
32
|
+
<div className="space-y-4">
|
|
33
|
+
<h1 className="max-w-3xl text-4xl font-semibold tracking-tight sm:text-5xl">
|
|
34
|
+
Ship your stack faster with a polished TypeScript foundation.
|
|
35
|
+
</h1>
|
|
36
|
+
<p className="max-w-2xl text-base leading-7 text-muted-foreground sm:text-lg">
|
|
37
|
+
Your project already includes the core app shell, database wiring,
|
|
38
|
+
and a shadcn-compatible UI foundation so you can keep building
|
|
39
|
+
instead of setting up boilerplate.
|
|
40
|
+
</p>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="flex flex-col gap-3 sm:flex-row">
|
|
43
|
+
{{#if useAuth}}
|
|
44
|
+
<Link
|
|
45
|
+
to="/sign-up"
|
|
46
|
+
className={cn(buttonVariants({ size: "lg" }), "gap-2")}
|
|
47
|
+
>
|
|
48
|
+
Create an account
|
|
49
|
+
<ArrowRight className="size-4" />
|
|
50
|
+
</Link>
|
|
51
|
+
<Link
|
|
52
|
+
to="/sign-in"
|
|
53
|
+
className={buttonVariants({ variant: "outline", size: "lg" })}
|
|
54
|
+
>
|
|
55
|
+
Login
|
|
56
|
+
</Link>
|
|
57
|
+
{{else}}
|
|
58
|
+
<a
|
|
59
|
+
href="https://better-ts-stack.abdullahtech.me/docs"
|
|
60
|
+
target="_blank"
|
|
61
|
+
rel="noreferrer"
|
|
62
|
+
className={cn(buttonVariants({ size: "lg" }), "gap-2")}
|
|
63
|
+
>
|
|
64
|
+
Explore the docs
|
|
65
|
+
<ArrowRight className="size-4" />
|
|
66
|
+
</a>
|
|
67
|
+
<a
|
|
68
|
+
href="https://tanstack.com/start/latest"
|
|
69
|
+
target="_blank"
|
|
70
|
+
rel="noreferrer"
|
|
71
|
+
className={buttonVariants({ variant: "outline", size: "lg" })}
|
|
72
|
+
>
|
|
73
|
+
TanStack guide
|
|
74
|
+
</a>
|
|
75
|
+
{{/if}}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<Card className="border-border bg-card shadow-sm">
|
|
80
|
+
<CardHeader>
|
|
81
|
+
<CardTitle>Included in this starter</CardTitle>
|
|
82
|
+
</CardHeader>
|
|
83
|
+
<CardContent className="space-y-4">
|
|
84
|
+
<ul className="space-y-3 text-sm text-muted-foreground">
|
|
85
|
+
{featureList.map((feature) => (
|
|
86
|
+
<li key={feature} className="flex items-center gap-3">
|
|
87
|
+
<span className="size-2 rounded-full bg-primary" />
|
|
88
|
+
<span>{feature}</span>
|
|
89
|
+
</li>
|
|
90
|
+
))}
|
|
91
|
+
</ul>
|
|
92
|
+
<div className="rounded-2xl border border-border bg-muted px-4 py-3 text-sm text-muted-foreground">
|
|
93
|
+
Start editing{" "}
|
|
94
|
+
<code className="font-mono">src/routes/index.tsx</code> and
|
|
95
|
+
shape the project around your product instead of setup chores.
|
|
96
|
+
</div>
|
|
97
|
+
</CardContent>
|
|
98
|
+
</Card>
|
|
99
|
+
</section>
|
|
100
|
+
</div>
|
|
101
|
+
</main>
|
|
102
|
+
);
|
|
102
103
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
2
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
-
import viteReact from "@vitejs/plugin-react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
2
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
+
import viteReact from "@vitejs/plugin-react";
|
|
4
|
+
import { nitro } from "nitro/vite";
|
|
5
|
+
import { defineConfig } from "vite";
|
|
6
|
+
|
|
7
|
+
export default defineConfig(({ command }) => ({
|
|
8
|
+
server: {
|
|
9
|
+
port: 3000,
|
|
10
|
+
},
|
|
11
|
+
resolve: {
|
|
12
|
+
tsconfigPaths: true,
|
|
13
|
+
},
|
|
14
|
+
plugins: [
|
|
15
|
+
tanstackStart({ srcDirectory: "src" }),
|
|
16
|
+
tailwindcss(),
|
|
17
|
+
viteReact(),
|
|
18
|
+
// Nitro builds the production server in .output/ (run with node). It is
|
|
19
|
+
// left out of `vite dev`, where TanStack Start's own dev server is steadier
|
|
20
|
+
command === "build" && nitro(),
|
|
21
|
+
],
|
|
22
|
+
}));
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "auth",
|
|
3
|
-
"name": "JWT Auth",
|
|
4
|
-
"description": "JWT authentication with bcrypt password hashing",
|
|
5
|
-
"type": "feature",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"bcrypt": "^6.0.0",
|
|
8
|
-
"jsonwebtoken": "^9.0.3",
|
|
9
|
-
"zod": "^4.6.5"
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@types/bcrypt": "^6.0.0",
|
|
13
|
-
"@types/jsonwebtoken": "^9.0.10"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {},
|
|
16
|
-
"envVars": {
|
|
17
|
-
"JWT_SECRET": "please-change-me",
|
|
18
|
-
"JWT_EXPIRES_IN": "1h"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "auth",
|
|
3
|
+
"name": "JWT Auth",
|
|
4
|
+
"description": "JWT authentication with bcrypt password hashing",
|
|
5
|
+
"type": "feature",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"bcrypt": "^6.0.0",
|
|
8
|
+
"jsonwebtoken": "^9.0.3",
|
|
9
|
+
"zod": "^4.6.5"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bcrypt": "^6.0.0",
|
|
13
|
+
"@types/jsonwebtoken": "^9.0.10"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {},
|
|
16
|
+
"envVars": {
|
|
17
|
+
"JWT_SECRET": "please-change-me",
|
|
18
|
+
"JWT_EXPIRES_IN": "1h"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
-
import { login, me, register } from '../controllers/authController';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
+
import { login, me, register } from '../controllers/authController';
|
|
3
|
+
{{#if useRateLimit}}
|
|
4
|
+
import { authLimiter } from '../middleware/rateLimit';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import { requireAuth } from '../middleware/requireAuth';
|
|
7
|
+
|
|
8
|
+
const router: Router = Router();
|
|
9
|
+
|
|
10
|
+
function asyncHandler(
|
|
11
|
+
fn: (req: Request, res: Response, next: NextFunction) => Promise<void>
|
|
12
|
+
): (req: Request, res: Response, next: NextFunction) => void {
|
|
13
|
+
return (req, res, next) => {
|
|
14
|
+
void fn(req, res, next).catch(next);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
{{#if useRateLimit}}
|
|
19
|
+
router.post('/register', authLimiter, asyncHandler(register));
|
|
20
|
+
router.post('/login', authLimiter, asyncHandler(login));
|
|
21
|
+
{{else}}
|
|
22
|
+
router.post('/register', asyncHandler(register));
|
|
23
|
+
router.post('/login', asyncHandler(login));
|
|
24
|
+
{{/if}}
|
|
25
|
+
router.get('/me', requireAuth, me);
|
|
26
|
+
|
|
27
|
+
export default router;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "auth",
|
|
3
|
-
"name": "JWT Auth",
|
|
4
|
-
"description": "JWT authentication for NestJS with bcrypt password hashing",
|
|
5
|
-
"type": "feature",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"bcrypt": "^6.0.0",
|
|
8
|
-
"jsonwebtoken": "^9.0.3",
|
|
9
|
-
"zod": "^4.6.5"
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@types/bcrypt": "^6.0.0",
|
|
13
|
-
"@types/jsonwebtoken": "^9.0.10"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {},
|
|
16
|
-
"envVars": {
|
|
17
|
-
"JWT_SECRET": "please-change-me",
|
|
18
|
-
"JWT_EXPIRES_IN": "1h"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "auth",
|
|
3
|
+
"name": "JWT Auth",
|
|
4
|
+
"description": "JWT authentication for NestJS with bcrypt password hashing",
|
|
5
|
+
"type": "feature",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"bcrypt": "^6.0.0",
|
|
8
|
+
"jsonwebtoken": "^9.0.3",
|
|
9
|
+
"zod": "^4.6.5"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bcrypt": "^6.0.0",
|
|
13
|
+
"@types/jsonwebtoken": "^9.0.10"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {},
|
|
16
|
+
"envVars": {
|
|
17
|
+
"JWT_SECRET": "please-change-me",
|
|
18
|
+
"JWT_EXPIRES_IN": "1h"
|
|
19
|
+
}
|
|
20
|
+
}
|