Skip to content

Commit 9bea470

Browse files
committed
chore: wip
1 parent 492092e commit 9bea470

32 files changed

+3105
-115
lines changed

config/storage.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,55 @@ import type { StorageConfig } from '@stacksjs/types'
66
* This configuration defines all of your storage options. Because Stacks is fully-typed,
77
* you may hover any of the options below and the definitions will be provided. In case
88
* you have any questions, feel free to reach out via Discord or GitHub Discussions.
9+
*
10+
* @see https://stacksjs.org/docs/storage
911
*/
1012
export default {
11-
driver: 's3',
13+
/**
14+
* Storage driver to use
15+
*
16+
* Options: 'local', 'bun', 's3', 'memory'
17+
* - 'local': Node.js fs-based storage (compatible, slower)
18+
* - 'bun': Bun-native storage (fastest, recommended when using Bun)
19+
* - 's3': AWS S3 or S3-compatible storage
20+
* - 'memory': In-memory storage (for testing)
21+
*/
22+
driver: process.env.STORAGE_DRIVER || 'bun',
23+
24+
/**
25+
* Root directory for local/bun drivers
26+
*
27+
* @default process.cwd()
28+
*/
29+
root: process.env.STORAGE_ROOT || process.cwd(),
30+
31+
/**
32+
* S3 Configuration (when driver is 's3')
33+
*/
34+
s3: {
35+
bucket: process.env.AWS_S3_BUCKET || '',
36+
region: process.env.AWS_REGION || 'us-east-1',
37+
prefix: process.env.AWS_S3_PREFIX || '',
38+
credentials: process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY
39+
? {
40+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
41+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
42+
}
43+
: undefined,
44+
// endpoint: 'https://s3-compatible-service.com', // For S3-compatible services
45+
},
46+
47+
/**
48+
* Public URL configuration
49+
*/
50+
publicUrl: {
51+
domain: process.env.STORAGE_PUBLIC_URL || process.env.APP_URL || 'http://localhost',
52+
},
53+
54+
/**
55+
* Default file visibility
56+
*
57+
* @default 'private'
58+
*/
59+
defaultVisibility: 'private',
1260
} satisfies StorageConfig

storage/framework/config/ace-config.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

storage/framework/core/database/src/seeder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { path } from '@stacksjs/path'
77
import { makeHash } from '@stacksjs/security'
88
import { fs } from '@stacksjs/storage'
99
import { snakeCase } from '@stacksjs/strings'
10-
import { globSync } from 'tinyglobby'
1110

1211
async function seedModel(name: string, modelPath: string, model: Model) {
1312
if (model?.traits?.useSeeder === false || model?.traits?.seedable === false) {

storage/framework/core/db/src/orm/generate.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { path } from '@stacksjs/path'
22
import { fs } from '@stacksjs/storage'
33
import { plural, snakeCase } from '@stacksjs/strings'
44
import type { Model } from '@stacksjs/types'
5-
import { globSync } from 'tinyglobby'
65

76
export function getModelName(model: Model, modelPath: string): string {
87
if (model.name)
@@ -22,26 +21,26 @@ export function getTableName(model: Model, modelPath: string): string {
2221

2322
function extractHiddenFields(model: Model): string[] {
2423
if (!model.attributes) return []
25-
26-
return Object.keys(model.attributes).filter(key =>
24+
25+
return Object.keys(model.attributes).filter(key =>
2726
model.attributes?.[key]?.hidden === true
2827
).map(field => snakeCase(field))
2928
}
3029

3130
function extractFillableFields(model: Model): string[] {
3231
if (!model.attributes) return []
33-
34-
const fillable = Object.keys(model.attributes).filter(key =>
32+
33+
const fillable = Object.keys(model.attributes).filter(key =>
3534
model.attributes?.[key]?.fillable === true
3635
).map(field => snakeCase(field))
3736

3837
// Add trait-specific fillable fields
3938
const additionalFields: string[] = []
40-
39+
4140
if (model.traits?.useUuid) {
4241
additionalFields.push('uuid')
4342
}
44-
43+
4544
if (model.traits?.useAuth) {
4645
const useAuth = model.traits.useAuth
4746
if (typeof useAuth === 'object' && useAuth.usePasskey) {
@@ -54,8 +53,8 @@ function extractFillableFields(model: Model): string[] {
5453

5554
function extractGuardedFields(model: Model): string[] {
5655
if (!model.attributes) return []
57-
58-
return Object.keys(model.attributes).filter(key =>
56+
57+
return Object.keys(model.attributes).filter(key =>
5958
model.attributes?.[key]?.guarded === true
6059
).map(field => snakeCase(field))
6160
}
@@ -145,7 +144,7 @@ class ${modelName}Model {
145144
// Create a new record
146145
static async create(data: Record<string, any>) {
147146
const instance = new ${modelName}Model()
148-
147+
149148
// Filter based on fillable and guarded
150149
const filteredData = Object.fromEntries(
151150
Object.entries(data).filter(([key]) =>
@@ -211,11 +210,11 @@ class ${modelName}Model {
211210
// Convert to JSON (excluding hidden fields)
212211
toJSON() {
213212
const json = { ...this.attributes }
214-
213+
215214
for (const field of this.hidden) {
216215
delete json[field]
217216
}
218-
217+
219218
return json
220219
}
221220
}
@@ -236,15 +235,15 @@ export async function generateOrmModels(): Promise<void> {
236235
const tableName = getTableName(model, userModelFile)
237236

238237
const modelString = generateOrmModelString(modelName, tableName, model)
239-
238+
240239
// Ensure the directory exists
241240
const ormModelsDir = path.storagePath('framework/core/db/src/orm/Models')
242241
await fs.promises.mkdir(ormModelsDir, { recursive: true })
243242

244243
// Write the generated model file
245244
const outputPath = path.join(ormModelsDir, `${modelName}.ts`)
246245
await fs.promises.writeFile(outputPath, modelString, 'utf8')
247-
246+
248247
console.log(`Generated ORM model: ${modelName} -> ${outputPath}`)
249248
}
250249
}
@@ -255,15 +254,15 @@ export async function generateOrmModel(modelPath: string): Promise<void> {
255254
const tableName = getTableName(model, modelPath)
256255

257256
const modelString = generateOrmModelString(modelName, tableName, model)
258-
257+
259258
// Ensure the directory exists
260259
const ormModelsDir = path.storagePath('framework/core/db/src/orm/Models')
261260
await fs.promises.mkdir(ormModelsDir, { recursive: true })
262261

263262
// Write the generated model file
264263
const outputPath = path.join(ormModelsDir, `${modelName}.ts`)
265264
await fs.promises.writeFile(outputPath, modelString, 'utf8')
266-
265+
267266
console.log(`Generated ORM model: ${modelName} -> ${outputPath}`)
268267
}
269268

storage/framework/core/orm/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
"prepublishOnly": "bun run build"
3636
},
3737
"dependencies": {
38-
"@stacksjs/ts-validation": "^0.4.7",
39-
"tinyglobby": "^0.2.15"
38+
"@stacksjs/ts-validation": "^0.4.7"
4039
},
4140
"devDependencies": {
4241
"@stacksjs/build": "workspace:*",

storage/framework/core/orm/src/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { path } from '@stacksjs/path'
2121
import { fs } from '@stacksjs/storage'
2222
import { camelCase, kebabCase, pascalCase, plural, singular, slugify, snakeCase } from '@stacksjs/strings'
2323
import { isString } from '@stacksjs/validation'
24-
import { globSync } from 'tinyglobby'
2524
import { generateModelString } from './generate'
2625
import { generateTraitRequestTypes, generateTraitTableInterfaces, traitInterfaces } from './generated/table-traits'
2726

@@ -612,7 +611,7 @@ export async function writeModelEvents(): Promise<void> {
612611
eventString += `
613612
${observerImports} \n\n
614613
615-
export interface ModelEvents {\n
614+
export interface ModelEvents {\n
616615
${observerString}
617616
}`
618617

@@ -1757,7 +1756,7 @@ export interface ${formattedTableName}Table {
17571756

17581757
if (relationType === 'belongsType' && !relationCount) {
17591758
const relationName = camelCase(relation.relationName || formattedModelRelation)
1760-
modelTypeInterface += ` get ${snakeCase(relationName)}(): ${modelRelation}ModelType | undefined
1759+
modelTypeInterface += ` get ${snakeCase(relationName)}(): ${modelRelation}ModelType | undefined
17611760
`
17621761
}
17631762

storage/framework/core/realtime/src/broadcast.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { BroadcastInstance, ChannelType, RealtimeDriver } from '@stacksjs/types'
22
import { config } from '@stacksjs/config'
33
import { appPath } from '@stacksjs/path'
4-
import { globSync } from 'tinyglobby'
54
import { RealtimeFactory } from './factory'
65

76
export class Broadcast {

storage/framework/core/storage/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"@stacksjs/strings": "workspace:*",
6060
"@stacksjs/types": "workspace:*",
6161
"@types/archiver": "^6.0.3",
62-
"archiver": "^7.0.1",
63-
"tinyglobby": "^0.2.15"
62+
"archiver": "^7.0.1"
6463
}
6564
}

storage/framework/core/storage/src/glob.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { globSync as gs } from 'tinyglobby'
2-
3-
export { glob } from 'tinyglobby'
4-
51
export interface GlobOptions {
62
absolute?: boolean
73
cwd?: string

0 commit comments

Comments
 (0)