Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions api-monorepo/apps/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ NODE_ENV=development

# App
LOG_LEVEL=info
APP_KEY=zKXHe-Ahdb7aPK1ylAJlRgTefktEaACi
APP_KEY=
APP_URL=http://${HOST}:${PORT}

# Session
SESSION_DRIVER=cookie

# Database (file name inside ./tmp)
DB_DATABASE=db.sqlite3

#--------------------------------------------------------------------
# CORS (configure allowed origins for API access)
#--------------------------------------------------------------------
# CORS_ORIGIN=http://localhost:5173,http://localhost:3000
# CORS_ORIGIN=http://localhost:5173,http://localhost:3000
4 changes: 4 additions & 0 deletions api-monorepo/apps/backend/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
SESSION_DRIVER=memory

# Dedicated test database. The test runner migrates and truncates it,
# so it must never point at the development database.
DB_DATABASE=test.sqlite3
3 changes: 2 additions & 1 deletion api-monorepo/apps/backend/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import env from '#start/env'
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@adonisjs/lucid'

Expand All @@ -15,7 +16,7 @@ const dbConfig = defineConfig({
client: 'better-sqlite3',

connection: {
filename: app.tmpPath('db.sqlite3'),
filename: app.tmpPath(env.get('DB_DATABASE')),
},

/**
Expand Down
13 changes: 1 addition & 12 deletions api-monorepo/apps/backend/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ import { BaseModel, column } from '@adonisjs/lucid/orm'
import { DateTime } from 'luxon'

export class AuthAccessTokenSchema extends BaseModel {
static $columns = [
'abilities',
'createdAt',
'expiresAt',
'hash',
'id',
'lastUsedAt',
'name',
'tokenableId',
'type',
'updatedAt',
] as const
static $columns = ['abilities', 'createdAt', 'expiresAt', 'hash', 'id', 'lastUsedAt', 'name', 'tokenableId', 'type', 'updatedAt'] as const
$columns = AuthAccessTokenSchema.$columns
@column()
declare abilities: string
Expand Down
7 changes: 6 additions & 1 deletion api-monorepo/apps/backend/providers/api_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class ApiSerializer extends BaseSerializer<{
'Invalid pagination metadata. Expected metadata to contain Lucid pagination keys'
)
}
return metaData

/**
* The type guard of `@adonisjs/http-transformers` does not list
* `pageName`, which Lucid 22.5 added, so the value is cast.
*/
return metaData as SimplePaginatorMetaKeys
}
}

Expand Down
3 changes: 3 additions & 0 deletions api-monorepo/apps/backend/start/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ export default await Env.create(new URL('../', import.meta.url), {

// Session
SESSION_DRIVER: Env.schema.enum(['cookie', 'memory', 'database'] as const),

// Database
DB_DATABASE: Env.schema.string(),
})
2 changes: 1 addition & 1 deletion api-monorepo/apps/backend/tests/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const plugins: Config['plugins'] = [
* The teardown functions are executed after all the tests
*/
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
setup: [],
setup: [() => testUtils.db().migrate()],
teardown: [],
}

Expand Down
7 changes: 5 additions & 2 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ NODE_ENV=development

# App
LOG_LEVEL=info
APP_KEY=zKXHe-Ahdb7aPK1ylAJlRgTefktEaACi
APP_KEY=
APP_URL=http://${HOST}:${PORT}

# Session
SESSION_DRIVER=cookie

# Database (file name inside ./tmp)
DB_DATABASE=db.sqlite3

#--------------------------------------------------------------------
# CORS (configure allowed origins for API access)
#--------------------------------------------------------------------
# CORS_ORIGIN=http://localhost:5173,http://localhost:3000
# CORS_ORIGIN=http://localhost:5173,http://localhost:3000
4 changes: 4 additions & 0 deletions api/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
SESSION_DRIVER=memory

# Dedicated test database. The test runner migrates and truncates it,
# so it must never point at the development database.
DB_DATABASE=test.sqlite3
3 changes: 2 additions & 1 deletion api/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import env from '#start/env'
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@adonisjs/lucid'

Expand All @@ -15,7 +16,7 @@ const dbConfig = defineConfig({
client: 'better-sqlite3',

connection: {
filename: app.tmpPath('db.sqlite3'),
filename: app.tmpPath(env.get('DB_DATABASE')),
},

/**
Expand Down
13 changes: 1 addition & 12 deletions api/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ import { BaseModel, column } from '@adonisjs/lucid/orm'
import { DateTime } from 'luxon'

export class AuthAccessTokenSchema extends BaseModel {
static $columns = [
'abilities',
'createdAt',
'expiresAt',
'hash',
'id',
'lastUsedAt',
'name',
'tokenableId',
'type',
'updatedAt',
] as const
static $columns = ['abilities', 'createdAt', 'expiresAt', 'hash', 'id', 'lastUsedAt', 'name', 'tokenableId', 'type', 'updatedAt'] as const
$columns = AuthAccessTokenSchema.$columns
@column()
declare abilities: string
Expand Down
7 changes: 6 additions & 1 deletion api/providers/api_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class ApiSerializer extends BaseSerializer<{
'Invalid pagination metadata. Expected metadata to contain Lucid pagination keys'
)
}
return metaData

/**
* The type guard of `@adonisjs/http-transformers` does not list
* `pageName`, which Lucid 22.5 added, so the value is cast.
*/
return metaData as SimplePaginatorMetaKeys
}
}

Expand Down
3 changes: 3 additions & 0 deletions api/start/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ export default await Env.create(new URL('../', import.meta.url), {

// Session
SESSION_DRIVER: Env.schema.enum(['cookie', 'memory', 'database'] as const),

// Database
DB_DATABASE: Env.schema.string(),
})
2 changes: 1 addition & 1 deletion api/tests/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const plugins: Config['plugins'] = [
* The teardown functions are executed after all the tests
*/
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
setup: [],
setup: [() => testUtils.db().migrate()],
teardown: [],
}

Expand Down
5 changes: 4 additions & 1 deletion hypermedia/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ NODE_ENV=development

# App
LOG_LEVEL=info
APP_KEY=zKXHe-Ahdb7aPK1ylAJlRgTefktEaACi
APP_KEY=
APP_URL=http://${HOST}:${PORT}

# Session
SESSION_DRIVER=cookie

# Database (file name inside ./tmp)
DB_DATABASE=db.sqlite3
4 changes: 4 additions & 0 deletions hypermedia/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
SESSION_DRIVER=memory

# Dedicated test database. The test runner migrates and truncates it,
# so it must never point at the development database.
DB_DATABASE=test.sqlite3
3 changes: 2 additions & 1 deletion hypermedia/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import env from '#start/env'
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@adonisjs/lucid'

Expand All @@ -19,7 +20,7 @@ const dbConfig = defineConfig({
sqlite: {
client: 'better-sqlite3',
connection: {
filename: app.tmpPath('db.sqlite3'),
filename: app.tmpPath(env.get('DB_DATABASE')),
},
useNullAsDefault: true,
migrations: {
Expand Down
2 changes: 1 addition & 1 deletion hypermedia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@adonisjs/eslint-config": "^3.1.0",
"@adonisjs/prettier-config": "^1.5.0",
"@adonisjs/tsconfig": "^2.0.0",
"@iconify-json/lucide": "^1.2.136",
"@japa/assert": "^4.2.0",
"@japa/browser-client": "^2.3.0",
"@japa/plugin-adonisjs": "^5.2.0",
Expand All @@ -66,6 +65,7 @@
"@adonisjs/shield": "^9.0.0",
"@adonisjs/static": "^2.0.1",
"@adonisjs/vite": "^6.0.2",
"@iconify-json/lucide": "^1.2.136",
"@vinejs/vine": "^4.4.0",
"better-sqlite3": "^13.0.3",
"edge-iconify": "^2.0.2",
Expand Down
6 changes: 3 additions & 3 deletions hypermedia/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hypermedia/resources/views/components/checkbox/group.edge
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: `${fieldKey}[]`,
id: $props.get('id') ?? fieldKey,
groupCounter: 0,
oldValue: old(fieldKey) || '',
oldValue: old(fieldKey),
errors: flashMessages.get('inputErrorsBag', {})[fieldKey],
hasErrors: fieldKey in flashMessages.get('inputErrorsBag', {}),
})
Expand Down
2 changes: 1 addition & 1 deletion hypermedia/resources/views/components/field/root.edge
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@inject({
name: fieldKey,
id: $props.get('id') ?? fieldKey,
oldValue: old(fieldKey) || '',
oldValue: old(fieldKey),
errors: flashMessages.get('inputErrorsBag', {})[fieldKey],
hasErrors: fieldKey in flashMessages.get('inputErrorsBag', {}),
})
Expand Down
2 changes: 1 addition & 1 deletion hypermedia/resources/views/components/input/control.edge
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@let(useOldValue = !['password', 'file', 'checkbox', 'radio'].includes($props.get('type')))
@let(inputValue = useOldValue
? $context.oldValue || $props.get('value') || ''
? $context.oldValue === undefined ? $props.get('value') ?? '' : $context.oldValue ?? ''
: $props.get('value') || '')
@let(classes = ['field__input'])

Expand Down
2 changes: 1 addition & 1 deletion hypermedia/resources/views/components/radio/group.edge
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: fieldKey,
id: $props.get('id') ?? fieldKey,
groupCounter: 0,
oldValue: old(fieldKey) || '',
oldValue: old(fieldKey),
errors: flashMessages.get('inputErrorsBag', {})[fieldKey],
hasErrors: fieldKey in flashMessages.get('inputErrorsBag', {}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
'aria-describedby': $context.hasErrors ? `${$context.id}-error` : '',
})
.toAttrs()
}}>{{{ $context.oldValue || $props.get('value') || '' }}}</textarea>
}}>{{{ $context.oldValue === undefined ? $props.get('value') ?? '' : $context.oldValue ?? '' }}}</textarea>
3 changes: 3 additions & 0 deletions hypermedia/start/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ export default await Env.create(new URL('../', import.meta.url), {

// Session
SESSION_DRIVER: Env.schema.enum(['cookie', 'memory', 'database'] as const),

// Database
DB_DATABASE: Env.schema.string(),
})
2 changes: 1 addition & 1 deletion hypermedia/tests/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const plugins: Config['plugins'] = [
* The teardown functions are executed after all the tests
*/
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
setup: [],
setup: [() => testUtils.db().migrate()],
teardown: [],
}

Expand Down
5 changes: 4 additions & 1 deletion inertia-react/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ NODE_ENV=development

# App
LOG_LEVEL=info
APP_KEY=zKXHe-Ahdb7aPK1ylAJlRgTefktEaACi
APP_KEY=
APP_URL=http://${HOST}:${PORT}

# Session
SESSION_DRIVER=cookie

# Database (file name inside ./tmp)
DB_DATABASE=db.sqlite3
4 changes: 4 additions & 0 deletions inertia-react/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
SESSION_DRIVER=memory

# Dedicated test database. The test runner migrates and truncates it,
# so it must never point at the development database.
DB_DATABASE=test.sqlite3
3 changes: 2 additions & 1 deletion inertia-react/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import env from '#start/env'
import app from '@adonisjs/core/services/app'
import { defineConfig } from '@adonisjs/lucid'

Expand All @@ -18,7 +19,7 @@ const dbConfig = defineConfig({
/**
* Database file location.
*/
filename: app.tmpPath('db.sqlite3'),
filename: app.tmpPath(env.get('DB_DATABASE')),
},

/**
Expand Down
Loading
Loading