create-cslug 0.0.0 → 0.4.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.
Files changed (80) hide show
  1. package/README.md +11 -1
  2. package/docs/README.md +32 -0
  3. package/package.json +30 -4
  4. package/src/bin.ts +58 -0
  5. package/src/index.ts +10 -0
  6. package/src/scaffold.ts +133 -0
  7. package/templates/api/AGENTS.md +8 -0
  8. package/templates/api/README.md +12 -0
  9. package/templates/api/_env.example +5 -0
  10. package/templates/api/_env.test +7 -0
  11. package/templates/api/_gitignore +6 -0
  12. package/templates/api/app/providers/app-service-provider.ts +8 -0
  13. package/templates/api/bootstrap/app.ts +8 -0
  14. package/templates/api/bootstrap/providers.ts +12 -0
  15. package/templates/api/config/app.ts +10 -0
  16. package/templates/api/config/cache.ts +10 -0
  17. package/templates/api/config/database.ts +8 -0
  18. package/templates/api/config/env.ts +9 -0
  19. package/templates/api/config/http.ts +9 -0
  20. package/templates/api/config/i18n.ts +7 -0
  21. package/templates/api/config/index.ts +14 -0
  22. package/templates/api/config/redis.ts +6 -0
  23. package/templates/api/cslug.config.ts +8 -0
  24. package/templates/api/database/migrations/.gitkeep +0 -0
  25. package/templates/api/database/seeders/database-seeder.ts +4 -0
  26. package/templates/api/docker-compose.yml +9 -0
  27. package/templates/api/resources/lang/en.json +7 -0
  28. package/templates/api/routes/api.ts +9 -0
  29. package/templates/api/storage/.gitkeep +0 -0
  30. package/templates/api/tests/feature/api.test.ts.tpl +12 -0
  31. package/templates/api/tsconfig.json +18 -0
  32. package/templates/full/_env.example +8 -0
  33. package/templates/full/_env.test +8 -0
  34. package/templates/full/app/controllers/auth/register-controller.ts +30 -0
  35. package/templates/full/app/jobs/.gitkeep +0 -0
  36. package/templates/full/app/mail/welcome-mail.ts +20 -0
  37. package/templates/full/bootstrap/providers.ts +23 -0
  38. package/templates/full/config/env.ts +14 -0
  39. package/templates/full/config/index.ts +22 -0
  40. package/templates/full/config/mail.ts +12 -0
  41. package/templates/full/config/queue.ts +11 -0
  42. package/templates/full/config/storage.ts +9 -0
  43. package/templates/full/cslug.config.ts +15 -0
  44. package/templates/full/docker-compose.yml +12 -0
  45. package/templates/full/resources/lang/en.json +32 -0
  46. package/templates/full/resources/mail/layout.vue +20 -0
  47. package/templates/full/resources/mail/welcome.vue +14 -0
  48. package/templates/full/routes/schedule.ts +6 -0
  49. package/templates/full/tests/feature/welcome-mail.test.ts.tpl +21 -0
  50. package/templates/tailwind/resources/styles/tailwind.css +1 -0
  51. package/templates/web/app/controllers/auth/register-controller.ts +26 -0
  52. package/templates/web/app/controllers/auth/session-controller.ts +24 -0
  53. package/templates/web/app/controllers/home-controller.ts +16 -0
  54. package/templates/web/app/repositories/user-repository.ts +6 -0
  55. package/templates/web/app/tables/user-table.ts +12 -0
  56. package/templates/web/app/validators/login-validator.ts +6 -0
  57. package/templates/web/app/validators/register-validator.ts +26 -0
  58. package/templates/web/bootstrap/providers.ts +16 -0
  59. package/templates/web/bunfig.toml +3 -0
  60. package/templates/web/config/auth.ts +7 -0
  61. package/templates/web/config/index.ts +19 -0
  62. package/templates/web/config/session.ts +8 -0
  63. package/templates/web/cslug.config.ts +13 -0
  64. package/templates/web/database/factories/user-factory.ts +9 -0
  65. package/templates/web/database/migrations/00000000_000001_create_users.sql +13 -0
  66. package/templates/web/database/seeders/database-seeder.ts +7 -0
  67. package/templates/web/public/.gitkeep +0 -0
  68. package/templates/web/resources/client.ts +4 -0
  69. package/templates/web/resources/lang/en.json +25 -0
  70. package/templates/web/resources/styles/app.scss +80 -0
  71. package/templates/web/resources/views/auth/login.vue +26 -0
  72. package/templates/web/resources/views/auth/register.vue +34 -0
  73. package/templates/web/resources/views/dashboard.vue +13 -0
  74. package/templates/web/resources/views/errors/404.vue +13 -0
  75. package/templates/web/resources/views/home.vue +13 -0
  76. package/templates/web/resources/views/layouts/default.vue +39 -0
  77. package/templates/web/routes/web.ts +22 -0
  78. package/templates/web/tests/feature/auth.test.ts.tpl +57 -0
  79. package/templates/web/tsconfig.json +19 -0
  80. package/index.js +0 -3
@@ -0,0 +1,14 @@
1
+ import { defineEnv, v } from '@cslug/core'
2
+
3
+ export const env = defineEnv({
4
+ APP_ENV: v.enum(['development', 'test', 'staging', 'production']).default('development'),
5
+ APP_URL: v.url(),
6
+ APP_KEY: v.secret().min(32),
7
+ DATABASE_URL: v.url(),
8
+ REDIS_URL: v.url().default('redis://localhost:6379'),
9
+ MAIL_TRANSPORT: v.enum(['smtp', 'log']).default('log'),
10
+ SMTP_HOST: v.string().default('localhost'),
11
+ SMTP_PORT: v.coerce.int().default(1025),
12
+ SMTP_USER: v.string().optional(),
13
+ SMTP_PASSWORD: v.secret().optional(),
14
+ })
@@ -0,0 +1,22 @@
1
+ import type { Typed } from '@cslug/core'
2
+ import type { User } from '#app/tables/user-table'
3
+ import app from './app'
4
+ import auth from './auth'
5
+ import cache from './cache'
6
+ import database from './database'
7
+ import http from './http'
8
+ import i18n from './i18n'
9
+ import mail from './mail'
10
+ import queue from './queue'
11
+ import redis from './redis'
12
+ import session from './session'
13
+ import storage from './storage'
14
+
15
+ export const configs = { app, http, database, redis, cache, queue, mail, storage, session, auth, i18n }
16
+
17
+ declare module '@cslug/core' {
18
+ /** Types `config('...')`. */
19
+ interface Config extends Typed<typeof configs> {}
20
+ /** Types `auth.user()` and policy arguments. */
21
+ interface AuthUser extends User {}
22
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from '@cslug/core'
2
+ import { env } from './env'
3
+
4
+ export default defineConfig({
5
+ from: { address: 'hello@example.com', name: '{{title}}' },
6
+ transport: env.MAIL_TRANSPORT,
7
+ transports: {
8
+ smtp: { host: env.SMTP_HOST, port: env.SMTP_PORT, user: env.SMTP_USER, password: env.SMTP_PASSWORD },
9
+ log: {},
10
+ },
11
+ queue: 'mail',
12
+ })
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from '@cslug/core'
2
+
3
+ export default defineConfig({
4
+ connection: 'default',
5
+ queues: {
6
+ default: { concurrency: 5 },
7
+ mail: { concurrency: 5 },
8
+ },
9
+ failed: { keep: '14d' },
10
+ shutdownTimeout: '30s',
11
+ })
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from '@cslug/core'
2
+
3
+ export default defineConfig({
4
+ default: 'local',
5
+ disks: {
6
+ local: { driver: 'local', root: 'storage/app' },
7
+ // s3: { driver: 's3', bucket: env.S3_BUCKET, endpoint: env.S3_ENDPOINT, region: 'eu-west-3' },
8
+ },
9
+ })
@@ -0,0 +1,15 @@
1
+ import { defineCslugConfig } from '@cslug/cli'
2
+
3
+ /** Framework-level settings: assets and the processes `cslug start` runs. App settings live in config/. */
4
+ export default defineCslugConfig({
5
+ assets: {
6
+ entries: { client: 'resources/client.ts' },
7
+ scss: true,
8
+ tailwind: {{tailwind}},
9
+ },
10
+ processes: {
11
+ web: { instances: 1 },
12
+ worker: [{ queues: ['default', 'mail'], concurrency: 5 }],
13
+ scheduler: true,
14
+ },
15
+ })
@@ -0,0 +1,12 @@
1
+ # Development services: `docker compose up -d`
2
+ services:
3
+ postgres:
4
+ image: postgres:17
5
+ environment: { POSTGRES_USER: cslug, POSTGRES_PASSWORD: cslug, POSTGRES_DB: {{db}} }
6
+ ports: ["5432:5432"]
7
+ redis:
8
+ image: redis:7
9
+ ports: ["6379:6379"]
10
+ mailpit:
11
+ image: axllent/mailpit
12
+ ports: ["1025:1025", "8025:8025"]
@@ -0,0 +1,32 @@
1
+ {
2
+ "app": { "name": "{{title}}" },
3
+ "home": { "title": "Home", "intro": "Your cslug app is running. Edit resources/views/home.vue to start." },
4
+ "dashboard": { "title": "Dashboard", "hello": "Hello, {name}!" },
5
+ "auth": {
6
+ "login": "Log in",
7
+ "logout": "Log out",
8
+ "register": "Create an account",
9
+ "name": "Name",
10
+ "email": "Email",
11
+ "password": "Password",
12
+ "password_confirmation": "Confirm password",
13
+ "no_account": "No account yet?",
14
+ "failed": "These credentials do not match our records.",
15
+ "password_mismatch": "The passwords do not match.",
16
+ "welcome": "Welcome, {name}!"
17
+ },
18
+ "mail": {
19
+ "welcome": {
20
+ "subject": "Welcome aboard",
21
+ "greeting": "Hi {name},",
22
+ "body": "Your account is ready."
23
+ }
24
+ },
25
+ "errors": { "not_found": "Page not found", "back_home": "Back to the home page" },
26
+ "validation": {
27
+ "required": "This field is required.",
28
+ "unique": "This value is already taken.",
29
+ "string.min": "Must be at least {min} characters.",
30
+ "string.max": "Must be at most {max} characters."
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ <script setup lang="ts">
2
+ defineProps<{ preview?: string }>()
3
+ </script>
4
+
5
+ <template>
6
+ <html>
7
+ <head>
8
+ <meta charset="utf-8" />
9
+ <style>
10
+ body { font-family: system-ui, sans-serif; background: #fafafa; margin: 0; padding: 24px; color: #18181b; }
11
+ .card { max-width: 560px; margin: 0 auto; background: #fff; border-radius: 8px; padding: 24px; }
12
+ .button { display: inline-block; background: #0f766e; color: #fff; padding: 10px 16px; border-radius: 6px; text-decoration: none; }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <span v-if="preview" style="display: none">{{ preview }}</span>
17
+ <div class="card"><slot /></div>
18
+ </body>
19
+ </html>
20
+ </template>
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ import { useT } from '@cslug/vue'
3
+ import Layout from './layout.vue'
4
+
5
+ defineProps<{ name: string }>()
6
+ const { t } = useT()
7
+ </script>
8
+
9
+ <template>
10
+ <Layout :preview="t('mail.welcome.subject')">
11
+ <p>{{ t('mail.welcome.greeting', { name }) }}</p>
12
+ <p>{{ t('mail.welcome.body') }}</p>
13
+ </Layout>
14
+ </template>
@@ -0,0 +1,6 @@
1
+ import { defineSchedule } from '@cslug/queue'
2
+
3
+ /** Recurring work, run by `cslug schedule:work` (part of `cslug dev` and `cslug start`). */
4
+ export default defineSchedule((_s) => {
5
+ // s.job(SendDailyDigestJob).dailyAt('07:00')
6
+ })
@@ -0,0 +1,21 @@
1
+ import { test } from 'bun:test'
2
+ import { testApp } from '@cslug/testing'
3
+ import { WelcomeMail } from '#app/mail/welcome-mail'
4
+
5
+ const app = testApp({ fakes: ['mail'] })
6
+
7
+ test('registering queues the welcome mail', async () => {
8
+ await app
9
+ .post('/register')
10
+ .form({
11
+ name: 'Ada',
12
+ email: 'ada@example.test',
13
+ password: 'correct horse battery',
14
+ passwordConfirmation: 'correct horse battery',
15
+ })
16
+ .assertRedirect('/dashboard')
17
+ app.mail.assertQueued(
18
+ WelcomeMail,
19
+ (m) => m.to === 'ada@example.test' && m.subject === 'Welcome aboard' && !!m.text?.includes('Your account is ready.'),
20
+ )
21
+ })
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,26 @@
1
+ import { Hash } from '@cslug/auth'
2
+ import { inject, t } from '@cslug/core'
3
+ import { type HttpContext, redirect, route } from '@cslug/http'
4
+ import { view } from '@cslug/vue'
5
+ import { UserRepository } from '#app/repositories/user-repository'
6
+ import { RegisterValidator } from '#app/validators/register-validator'
7
+ import Register from '#views/auth/register.vue'
8
+
9
+ @inject(UserRepository, Hash)
10
+ export class RegisterController {
11
+ constructor(
12
+ private users: UserRepository,
13
+ private hash: Hash,
14
+ ) {}
15
+
16
+ async create() {
17
+ return view(Register, {})
18
+ }
19
+
20
+ async store({ request, auth }: HttpContext) {
21
+ const { name, email, password } = await request.validate(RegisterValidator)
22
+ const user = await this.users.create({ name, email, passwordHash: await this.hash.make(password) })
23
+ await auth.login(user)
24
+ return redirect().to(route('dashboard')).with('success', t('auth.welcome', { name }))
25
+ }
26
+ }
@@ -0,0 +1,24 @@
1
+ import { inject, ValidationError } from '@cslug/core'
2
+ import { type HttpContext, redirect, route } from '@cslug/http'
3
+ import { view } from '@cslug/vue'
4
+ import { LoginValidator } from '#app/validators/login-validator'
5
+ import Login from '#views/auth/login.vue'
6
+
7
+ @inject()
8
+ export class SessionController {
9
+ async create() {
10
+ return view(Login, {})
11
+ }
12
+
13
+ async store({ request, auth }: HttpContext) {
14
+ const { email, password } = await request.validate(LoginValidator)
15
+ const user = await auth.attempt(email, password) // throttled; failures logged without the password
16
+ if (!user) throw new ValidationError({ email: ['auth.failed'] })
17
+ return redirect().intended(route('dashboard'))
18
+ }
19
+
20
+ async destroy({ auth }: HttpContext) {
21
+ await auth.logout()
22
+ return redirect().to(route('home'))
23
+ }
24
+ }
@@ -0,0 +1,16 @@
1
+ import { inject } from '@cslug/core'
2
+ import type { HttpContext } from '@cslug/http'
3
+ import { view } from '@cslug/vue'
4
+ import Dashboard from '#views/dashboard.vue'
5
+ import Home from '#views/home.vue'
6
+
7
+ @inject()
8
+ export class HomeController {
9
+ async index() {
10
+ return view(Home, {})
11
+ }
12
+
13
+ async dashboard({ auth }: HttpContext) {
14
+ return view(Dashboard, { name: auth.user().name })
15
+ }
16
+ }
@@ -0,0 +1,6 @@
1
+ import { inject } from '@cslug/core'
2
+ import { Repository } from '@cslug/database'
3
+ import { users } from '#app/tables/user-table'
4
+
5
+ @inject()
6
+ export class UserRepository extends Repository(users) {}
@@ -0,0 +1,12 @@
1
+ import { id, type Row, table, text, timestamp, timestamps } from '@cslug/database'
2
+
3
+ export const users = table('users', {
4
+ id: id(),
5
+ name: text(),
6
+ email: text().unique(),
7
+ passwordHash: text(),
8
+ emailVerifiedAt: timestamp().nullable(),
9
+ ...timestamps(),
10
+ })
11
+
12
+ export type User = Row<typeof users>
@@ -0,0 +1,6 @@
1
+ import { v } from '@cslug/validation'
2
+
3
+ export const LoginValidator = v.object({
4
+ email: v.email().toLowerCase(),
5
+ password: v.string().min(1),
6
+ })
@@ -0,0 +1,26 @@
1
+ import { inject } from '@cslug/core'
2
+ import { type Fail, Validator, v } from '@cslug/validation'
3
+ import { UserRepository } from '#app/repositories/user-repository'
4
+
5
+ @inject(UserRepository)
6
+ export class RegisterValidator extends Validator {
7
+ constructor(private users: UserRepository) {
8
+ super()
9
+ }
10
+
11
+ schema = v
12
+ .object({
13
+ name: v.string().trim().min(2).max(80),
14
+ email: v.email().toLowerCase(),
15
+ password: v.string().min(12).max(200),
16
+ passwordConfirmation: v.string(),
17
+ })
18
+ .refine((d) => d.password === d.passwordConfirmation, {
19
+ path: ['passwordConfirmation'],
20
+ message: 'auth.password_mismatch',
21
+ })
22
+
23
+ async after(data: v.infer<this['schema']>, fail: Fail) {
24
+ if (await this.users.existsBy({ email: data.email })) fail('email', 'validation.unique')
25
+ }
26
+ }
@@ -0,0 +1,16 @@
1
+ import { AuthProvider } from '@cslug/auth'
2
+ import { DatabaseProvider } from '@cslug/database'
3
+ import { HttpProvider } from '@cslug/http'
4
+ import { RedisProvider } from '@cslug/redis'
5
+ import { VueProvider } from '@cslug/vue'
6
+ import { AppServiceProvider } from '#app/providers/app-service-provider'
7
+
8
+ /** One provider per installed @cslug/* package. Core (config, events, logger, i18n) needs none. */
9
+ export const providers = [
10
+ DatabaseProvider,
11
+ RedisProvider, // binds Redis drivers for Cache, Lock, RateLimiter, SessionStore
12
+ AuthProvider,
13
+ HttpProvider,
14
+ VueProvider,
15
+ AppServiceProvider,
16
+ ]
@@ -0,0 +1,3 @@
1
+ # `bun test` compiles .vue files from the first import (a test may import a mailable or a view directly)
2
+ [test]
3
+ preload = ["@cslug/vue/register"]
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from '@cslug/core'
2
+ import { UserRepository } from '#app/repositories/user-repository'
3
+
4
+ export default defineConfig({
5
+ users: UserRepository,
6
+ passwords: { algorithm: 'argon2id', rehashOnLogin: true },
7
+ })
@@ -0,0 +1,19 @@
1
+ import type { Typed } from '@cslug/core'
2
+ import type { User } from '#app/tables/user-table'
3
+ import app from './app'
4
+ import auth from './auth'
5
+ import cache from './cache'
6
+ import database from './database'
7
+ import http from './http'
8
+ import i18n from './i18n'
9
+ import redis from './redis'
10
+ import session from './session'
11
+
12
+ export const configs = { app, http, database, redis, cache, session, auth, i18n }
13
+
14
+ declare module '@cslug/core' {
15
+ /** Types `config('...')`. */
16
+ interface Config extends Typed<typeof configs> {}
17
+ /** Types `auth.user()` and policy arguments. */
18
+ interface AuthUser extends User {}
19
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from '@cslug/core'
2
+
3
+ export default defineConfig({
4
+ store: 'redis',
5
+ cookie: '{{db}}_session',
6
+ lifetime: '14d',
7
+ sameSite: 'lax',
8
+ })
@@ -0,0 +1,13 @@
1
+ import { defineCslugConfig } from '@cslug/cli'
2
+
3
+ /** Framework-level settings: assets and the processes `cslug start` runs. App settings live in config/. */
4
+ export default defineCslugConfig({
5
+ assets: {
6
+ entries: { client: 'resources/client.ts' },
7
+ scss: true,
8
+ tailwind: {{tailwind}},
9
+ },
10
+ processes: {
11
+ web: { instances: 1 },
12
+ },
13
+ })
@@ -0,0 +1,9 @@
1
+ import { factory } from '@cslug/database'
2
+ import { users } from '#app/tables/user-table'
3
+
4
+ /** Every factory user has the password "password-password". */
5
+ export const UserFactory = factory(users, ({ seq, fake }) => ({
6
+ name: fake.name(),
7
+ email: `user${seq}@example.test`,
8
+ passwordHash: fake.passwordHash('password-password'),
9
+ }))
@@ -0,0 +1,13 @@
1
+ -- up
2
+ create table users (
3
+ id uuid primary key,
4
+ name text not null,
5
+ email text not null unique,
6
+ password_hash text not null,
7
+ email_verified_at timestamptz,
8
+ created_at timestamptz not null default now(),
9
+ updated_at timestamptz not null default now()
10
+ );
11
+
12
+ -- down
13
+ drop table users;
@@ -0,0 +1,7 @@
1
+ import { seeder } from '@cslug/database'
2
+ import { UserFactory } from '#database/factories/user-factory'
3
+
4
+ /** `cslug db:seed`: development data. Log in as demo@example.test / password-password. */
5
+ export default seeder(async () => {
6
+ await UserFactory.create({ name: 'Demo', email: 'demo@example.test' })
7
+ })
File without changes
@@ -0,0 +1,4 @@
1
+ import { mountIslands } from '@cslug/vue'
2
+ {{styles}}
3
+
4
+ mountIslands()
@@ -0,0 +1,25 @@
1
+ {
2
+ "app": { "name": "{{title}}" },
3
+ "home": { "title": "Home", "intro": "Your cslug app is running. Edit resources/views/home.vue to start." },
4
+ "dashboard": { "title": "Dashboard", "hello": "Hello, {name}!" },
5
+ "auth": {
6
+ "login": "Log in",
7
+ "logout": "Log out",
8
+ "register": "Create an account",
9
+ "name": "Name",
10
+ "email": "Email",
11
+ "password": "Password",
12
+ "password_confirmation": "Confirm password",
13
+ "no_account": "No account yet?",
14
+ "failed": "These credentials do not match our records.",
15
+ "password_mismatch": "The passwords do not match.",
16
+ "welcome": "Welcome, {name}!"
17
+ },
18
+ "errors": { "not_found": "Page not found", "back_home": "Back to the home page" },
19
+ "validation": {
20
+ "required": "This field is required.",
21
+ "unique": "This value is already taken.",
22
+ "string.min": "Must be at least {min} characters.",
23
+ "string.max": "Must be at most {max} characters."
24
+ }
25
+ }
@@ -0,0 +1,80 @@
1
+ $brand: #0f766e;
2
+ $danger: #b91c1c;
3
+ $border: #e4e4e7;
4
+
5
+ *,
6
+ *::before,
7
+ *::after {
8
+ box-sizing: border-box;
9
+ }
10
+ body {
11
+ margin: 0;
12
+ font-family: system-ui, sans-serif;
13
+ background: #fafafa;
14
+ color: #18181b;
15
+ }
16
+ .container {
17
+ max-width: 40rem;
18
+ margin: 0 auto;
19
+ padding: 1rem;
20
+ }
21
+ .site-header {
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ padding: 0.75rem 1rem;
26
+ border-bottom: 1px solid $border;
27
+ background: #fff;
28
+ nav {
29
+ display: flex;
30
+ gap: 0.75rem;
31
+ align-items: center;
32
+ }
33
+ form {
34
+ margin: 0;
35
+ }
36
+ }
37
+ .brand {
38
+ font-weight: 700;
39
+ color: $brand;
40
+ text-decoration: none;
41
+ }
42
+ .stack {
43
+ display: grid;
44
+ gap: 0.5rem;
45
+ max-width: 24rem;
46
+ }
47
+ input,
48
+ button {
49
+ font: inherit;
50
+ padding: 0.5rem;
51
+ border: 1px solid $border;
52
+ border-radius: 0.5rem;
53
+ }
54
+ button {
55
+ background: $brand;
56
+ color: #fff;
57
+ border-color: $brand;
58
+ cursor: pointer;
59
+ }
60
+ button.link {
61
+ background: none;
62
+ border: none;
63
+ color: $brand;
64
+ padding: 0;
65
+ }
66
+ [aria-invalid="true"] {
67
+ border-color: $danger;
68
+ }
69
+ .error {
70
+ color: $danger;
71
+ margin: 0;
72
+ font-size: 0.875rem;
73
+ }
74
+ .flash {
75
+ max-width: 40rem;
76
+ margin: 0.75rem auto 0;
77
+ padding: 0.75rem;
78
+ border-radius: 0.5rem;
79
+ background: #ecfdf5;
80
+ }
@@ -0,0 +1,26 @@
1
+ <script setup lang="ts">
2
+ import { route, useRequest, useT } from '@cslug/vue'
3
+ import Layout from '../layouts/default.vue'
4
+
5
+ const { t } = useT()
6
+ const { csrfToken, errors, old } = useRequest()
7
+ </script>
8
+
9
+ <template>
10
+ <Layout :title="t('auth.login')">
11
+ <h1>{{ t('auth.login') }}</h1>
12
+ <form class="stack" :action="route('login.store')" method="post">
13
+ <input type="hidden" name="_token" :value="csrfToken" />
14
+
15
+ <label for="email">{{ t('auth.email') }}</label>
16
+ <input id="email" name="email" type="email" :value="old.email" :aria-invalid="!!errors.email" required autofocus />
17
+ <p v-if="errors.email" class="error">{{ errors.email }}</p>
18
+
19
+ <label for="password">{{ t('auth.password') }}</label>
20
+ <input id="password" name="password" type="password" required />
21
+
22
+ <button>{{ t('auth.login') }}</button>
23
+ </form>
24
+ <p>{{ t('auth.no_account') }} <a :href="route('register')">{{ t('auth.register') }}</a></p>
25
+ </Layout>
26
+ </template>
@@ -0,0 +1,34 @@
1
+ <script setup lang="ts">
2
+ import { route, useRequest, useT } from '@cslug/vue'
3
+ import Layout from '../layouts/default.vue'
4
+
5
+ const { t } = useT()
6
+ const { csrfToken, errors, old } = useRequest()
7
+ </script>
8
+
9
+ <template>
10
+ <Layout :title="t('auth.register')">
11
+ <h1>{{ t('auth.register') }}</h1>
12
+ <form class="stack" :action="route('register.store')" method="post">
13
+ <input type="hidden" name="_token" :value="csrfToken" />
14
+
15
+ <label for="name">{{ t('auth.name') }}</label>
16
+ <input id="name" name="name" :value="old.name" :aria-invalid="!!errors.name" required />
17
+ <p v-if="errors.name" class="error">{{ errors.name }}</p>
18
+
19
+ <label for="email">{{ t('auth.email') }}</label>
20
+ <input id="email" name="email" type="email" :value="old.email" :aria-invalid="!!errors.email" required />
21
+ <p v-if="errors.email" class="error">{{ errors.email }}</p>
22
+
23
+ <label for="password">{{ t('auth.password') }}</label>
24
+ <input id="password" name="password" type="password" minlength="12" required />
25
+ <p v-if="errors.password" class="error">{{ errors.password }}</p>
26
+
27
+ <label for="passwordConfirmation">{{ t('auth.password_confirmation') }}</label>
28
+ <input id="passwordConfirmation" name="passwordConfirmation" type="password" required />
29
+ <p v-if="errors.passwordConfirmation" class="error">{{ errors.passwordConfirmation }}</p>
30
+
31
+ <button>{{ t('auth.register') }}</button>
32
+ </form>
33
+ </Layout>
34
+ </template>
@@ -0,0 +1,13 @@
1
+ <script setup lang="ts">
2
+ import { useT } from '@cslug/vue'
3
+ import Layout from './layouts/default.vue'
4
+
5
+ defineProps<{ name: string }>()
6
+ const { t } = useT()
7
+ </script>
8
+
9
+ <template>
10
+ <Layout :title="t('dashboard.title')">
11
+ <h1>{{ t('dashboard.hello', { name }) }}</h1>
12
+ </Layout>
13
+ </template>
@@ -0,0 +1,13 @@
1
+ <script setup lang="ts">
2
+ import { route, useT } from '@cslug/vue'
3
+ import Layout from '../layouts/default.vue'
4
+
5
+ const { t } = useT()
6
+ </script>
7
+
8
+ <template>
9
+ <Layout :title="t('errors.not_found')">
10
+ <h1>{{ t('errors.not_found') }}</h1>
11
+ <p><a :href="route('home')">{{ t('errors.back_home') }}</a></p>
12
+ </Layout>
13
+ </template>