@strav/spring 0.3.2 → 0.3.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @strav/spring
2
2
 
3
- Flagship framework scaffolding tool for the Strav ecosystem - the Laravel of the Bun ecosystem.
3
+ Flagship framework scaffolding tool for the Strav ecosystem - the rite of the Bun ecosystem.
4
4
 
5
5
  ## Usage
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strav/spring",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "description": "Flagship framework scaffolding tool for the Strav ecosystem.",
6
6
  "license": "MIT",
@@ -10,7 +10,6 @@
10
10
  "framework",
11
11
  "scaffold",
12
12
  "create",
13
- "laravel",
14
13
  "typescript",
15
14
  "vue"
16
15
  ],
@@ -23,7 +22,7 @@
23
22
  "README.md"
24
23
  ],
25
24
  "dependencies": {
26
- "@strav/kernel": "0.3.2"
25
+ "@strav/kernel": "0.3.4"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@types/bun": "latest"
package/src/index.ts CHANGED
@@ -58,7 +58,7 @@ function parseArgs(): ParsedArgs {
58
58
  function printUsage(): void {
59
59
  console.log(`
60
60
  ${bold('@strav/spring')} ${dim(`v${VERSION}`)}
61
- ${dim('The Laravel of the Bun ecosystem')}
61
+ ${dim('The Rite of the Bun ecosystem')}
62
62
 
63
63
  ${bold('Usage:')}
64
64
  bunx @strav/spring ${cyan('<project-name>')} [options]
@@ -98,7 +98,7 @@ async function main(): Promise<void> {
98
98
 
99
99
  console.log()
100
100
  console.log(` ${bold('@strav/spring')} ${dim(`v${VERSION}`)}`)
101
- console.log(` ${dim('The Laravel of the Bun ecosystem')}`)
101
+ console.log(` ${dim('The rite of the Bun ecosystem')}`)
102
102
  console.log()
103
103
 
104
104
  // Project name
@@ -1,7 +1,14 @@
1
1
  import { env } from '@strav/kernel'
2
2
 
3
3
  export default {
4
- port: env.int('APP_PORT', 3000),
4
+ host: env('HOST', '0.0.0.0'),
5
+ port: env.int('PORT', 3000),
6
+ domain: env('DOMAIN', 'localhost'),
7
+ public: './public',
8
+
9
+ // Full application URL (optional - will be constructed from host/port/domain if not set)
10
+ app_url: env('APP_URL'),
11
+
5
12
  cors: {
6
13
  enabled: true,
7
14
  origin: ['http://localhost:3000', 'http://localhost:5173'],
@@ -1,33 +1,11 @@
1
1
  import 'reflect-metadata'
2
2
  import { app } from '@strav/kernel'
3
- import { router } from '@strav/http'
4
- import { ConfigProvider, EncryptionProvider } from '@strav/kernel'
5
- import { DatabaseProvider } from '@strav/database'
6
- import BaseModel from '@strav/database/orm/base_model'
7
- import Database from '@strav/database/database/database'
8
- import Server from '@strav/http/server'
9
- import { ExceptionHandler } from '@strav/kernel'
3
+ import { providers } from './start/providers'
10
4
 
11
5
  // Register service providers
12
- app
13
- .use(new ConfigProvider())
14
- .use(new DatabaseProvider())
15
- .use(new EncryptionProvider())
16
-
17
- // Boot services (loads config, connects database, derives encryption keys)
18
- await app.start()
19
-
20
- // Initialize ORM
21
- new BaseModel(app.resolve(Database))
22
-
23
- // Configure router for API
24
- router.useExceptionHandler(new ExceptionHandler(true))
25
- router.cors()
6
+ app.useProviders(providers)
26
7
 
27
8
  // Load routes
28
- await import('./routes/routes')
9
+ await import('./start/routes')
29
10
 
30
- // Start HTTP server
31
- app.singleton(Server)
32
- const server = app.resolve(Server)
33
- server.start(router)
11
+ await app.start()
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "bun --hot index.ts",
8
+ "start": "bun index.ts",
9
+ "test": "bun test tests/",
10
+ "typecheck": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "@strav/kernel": "__STRAV_VERSION__",
14
+ "@strav/http": "__STRAV_VERSION__",
15
+ "@strav/database": "__STRAV_VERSION__",
16
+ "@strav/cli": "__STRAV_VERSION__",
17
+ "reflect-metadata": "^0.2.2"
18
+ },
19
+ "devDependencies": {
20
+ "@types/bun": "latest",
21
+ "@strav/testing": "__STRAV_VERSION__",
22
+ "typescript": "^5.9.3"
23
+ }
24
+ }
@@ -0,0 +1,10 @@
1
+ import { DatabaseProvider } from "@strav/database"
2
+ import { HttpProvider } from "@strav/http"
3
+ import { ConfigProvider, EncryptionProvider, ServiceProvider } from "@strav/kernel"
4
+
5
+ export const providers: ServiceProvider[] = [
6
+ new ConfigProvider(),
7
+ new HttpProvider(),
8
+ new DatabaseProvider(),
9
+ new EncryptionProvider(),
10
+ ]
@@ -0,0 +1,22 @@
1
+ import { router } from '@strav/http'
2
+ import UserController from '../app/controllers/user_controller'
3
+
4
+ // Health check endpoint
5
+ router.get('/health', async (ctx) => {
6
+ return ctx.json({
7
+ status: 'ok',
8
+ timestamp: new Date().toISOString(),
9
+ app: '__PROJECT_NAME__',
10
+ version: '0.1.0'
11
+ })
12
+ })
13
+
14
+ // API routes
15
+ router.group('/api/v1', () => {
16
+ // User resource routes
17
+ router.get('/users', [UserController, 'index'])
18
+ router.get('/users/:id', [UserController, 'show'])
19
+ router.post('/users', [UserController, 'store'])
20
+ router.put('/users/:id', [UserController, 'update'])
21
+ router.delete('/users/:id', [UserController, 'destroy'])
22
+ })
@@ -1,10 +1,7 @@
1
1
  import { env } from '@strav/kernel'
2
2
 
3
3
  export default {
4
- name: '__PROJECT_NAME__',
5
- env: env('APP_ENV', 'production'),
6
- debug: env.bool('APP_DEBUG', false),
7
- url: env('APP_URL', 'http://localhost:3000'),
8
- port: env.int('APP_PORT', 3000),
4
+ env: env('APP_ENV', 'local'),
5
+ debug: env.bool('APP_DEBUG', true),
9
6
  key: env('APP_KEY'),
10
7
  }
@@ -0,0 +1,11 @@
1
+ import { env } from '@strav/kernel'
2
+
3
+ export default {
4
+ host: env('HOST', '0.0.0.0'),
5
+ port: env.int('PORT', 3000),
6
+ domain: env('DOMAIN', 'localhost'),
7
+ public: './public',
8
+
9
+ // Full application URL (optional - will be constructed from host/port/domain if not set)
10
+ app_url: env('APP_URL'),
11
+ }
@@ -3,5 +3,5 @@ import { env } from '@strav/kernel'
3
3
  export default {
4
4
  directory: 'resources/views',
5
5
  cache: env.bool('VIEW_CACHE', true),
6
- assets: ['/css/app.css', '/islands.js'],
6
+ assets: ['css/app.css', 'builds/islands.js'],
7
7
  }
@@ -1,48 +1,26 @@
1
1
  import 'reflect-metadata'
2
2
  import { app } from '@strav/kernel'
3
- import { router } from '@strav/http'
4
- import { ConfigProvider, EncryptionProvider } from '@strav/kernel'
5
- import { DatabaseProvider } from '@strav/database'
6
- import { SessionProvider } from '@strav/http'
7
- import { ViewProvider } from '@strav/view'
8
- import BaseModel from '@strav/database/orm/base_model'
9
- import Database from '@strav/database/database/database'
10
- import Server from '@strav/http/server'
11
- import { ExceptionHandler } from '@strav/kernel'
12
- import { IslandBuilder } from '@strav/view'
3
+ import { IslandBuilder, ViewEngine } from '@strav/view'
4
+ import { providers } from './start/providers'
5
+
6
+ // Build islands + CSS before the server starts so they're included in the public/ scan
7
+ const builder = new IslandBuilder({
8
+ css: { entry: 'resources/css/app.scss' },
9
+ })
13
10
 
14
11
  // Register service providers
15
12
  app
16
- .use(new ConfigProvider())
17
- .use(new DatabaseProvider())
18
- .use(new EncryptionProvider())
19
- .use(new SessionProvider())
20
- .use(new ViewProvider())
21
-
22
- // Boot services (loads config, connects database, derives encryption keys, starts sessions)
23
- await app.start()
24
-
25
- // Initialize ORM
26
- new BaseModel(app.resolve(Database))
27
-
28
- // Build Vue islands for development
29
- if (process.env.NODE_ENV !== 'production') {
30
- const islands = new IslandBuilder({
31
- islandsDir: './resources/ts/islands',
32
- outDir: './public',
33
- outFile: 'islands.js',
13
+ .useProviders(providers)
14
+ .onBooted(async() => {
15
+ // Watch for island and template changes in dev
16
+ if (Bun.env.NODE_ENV !== 'production') {
17
+ builder.watch()
18
+ ViewEngine.instance.watch()
19
+ }
20
+ await builder.build()
34
21
  })
35
- await islands.build()
36
- islands.watch() // Auto-rebuild on changes
37
- }
38
-
39
- // Configure router
40
- router.useExceptionHandler(new ExceptionHandler(true))
41
22
 
42
23
  // Load routes
43
- await import('./routes/routes')
24
+ await import('./start/routes')
44
25
 
45
- // Start HTTP server
46
- app.singleton(Server)
47
- const server = app.resolve(Server)
48
- server.start(router)
26
+ await app.start()
@@ -0,0 +1,13 @@
1
+ import { DatabaseProvider } from "@strav/database"
2
+ import { HttpProvider, SessionProvider } from "@strav/http"
3
+ import { ConfigProvider, EncryptionProvider, ServiceProvider } from "@strav/kernel"
4
+ import { ViewProvider } from '@strav/view'
5
+
6
+ export const providers: ServiceProvider[] = [
7
+ new ConfigProvider(),
8
+ new HttpProvider(),
9
+ new DatabaseProvider(),
10
+ new EncryptionProvider(),
11
+ new SessionProvider(),
12
+ new ViewProvider(),
13
+ ]
@@ -0,0 +1,16 @@
1
+ import { router } from '@strav/http'
2
+ import HomeController from '../app/controllers/home_controller'
3
+
4
+ // Web routes
5
+ router.get('/', [HomeController, 'index'])
6
+ router.get('/users', [HomeController, 'users'])
7
+
8
+ // Health check endpoint
9
+ router.get('/health', async (ctx) => {
10
+ return ctx.json({
11
+ status: 'ok',
12
+ timestamp: new Date().toISOString(),
13
+ app: '__PROJECT_NAME__',
14
+ version: '0.1.0'
15
+ })
16
+ })
@@ -1,24 +0,0 @@
1
- import type { Router } from '@strav/http'
2
- import UserController from '../app/controllers/user_controller.ts'
3
-
4
- export default function (router: Router) {
5
- // Health check endpoint
6
- router.get('/health', async (ctx) => {
7
- return ctx.json({
8
- status: 'ok',
9
- timestamp: new Date().toISOString(),
10
- app: '__PROJECT_NAME__',
11
- version: '0.1.0'
12
- })
13
- })
14
-
15
- // API routes
16
- router.group('/api/v1', () => {
17
- // User resource routes
18
- router.get('/users', [UserController, 'index'])
19
- router.get('/users/:id', [UserController, 'show'])
20
- router.post('/users', [UserController, 'store'])
21
- router.put('/users/:id', [UserController, 'update'])
22
- router.delete('/users/:id', [UserController, 'destroy'])
23
- })
24
- }
@@ -1,30 +0,0 @@
1
- import { Model, column } from '@strav/database'
2
-
3
- export default class User extends Model {
4
- @column({ isPrimary: true })
5
- declare id: string
6
-
7
- @column()
8
- declare email: string
9
-
10
- @column()
11
- declare name: string
12
-
13
- @column()
14
- declare password_hash: string
15
-
16
- @column()
17
- declare email_verified_at: Date | null
18
-
19
- @column()
20
- declare remember_token: string | null
21
-
22
- @column()
23
- declare created_at: Date
24
-
25
- @column()
26
- declare updated_at: Date
27
-
28
- @column()
29
- declare deleted_at: Date | null
30
- }
@@ -1,22 +0,0 @@
1
- import type { Router } from '@strav/http'
2
- import { staticFiles } from '@strav/http'
3
- import HomeController from '../app/controllers/home_controller.ts'
4
-
5
- export default function (router: Router) {
6
- // Serve static files from public directory
7
- router.use(staticFiles('public'))
8
-
9
- // Web routes
10
- router.get('/', [HomeController, 'index'])
11
- router.get('/users', [HomeController, 'users'])
12
-
13
- // Health check endpoint
14
- router.get('/health', async (ctx) => {
15
- return ctx.json({
16
- status: 'ok',
17
- timestamp: new Date().toISOString(),
18
- app: '__PROJECT_NAME__',
19
- version: '0.1.0'
20
- })
21
- })
22
- }