@strav/spring 0.3.1 → 0.3.3
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/package.json +2 -2
- package/src/templates/api/config/http.ts +8 -1
- package/src/templates/api/index.ts +4 -26
- package/src/templates/api/package.json +24 -0
- package/src/templates/api/start/providers.ts +10 -0
- package/src/templates/api/start/routes.ts +22 -0
- package/src/templates/shared/config/app.ts +2 -5
- package/src/templates/web/config/http.ts +11 -0
- package/src/templates/web/config/view.ts +1 -1
- package/src/templates/web/index.ts +17 -39
- package/src/templates/web/start/providers.ts +13 -0
- package/src/templates/web/start/routes.ts +16 -0
- package/src/templates/api/routes/routes.ts +0 -24
- package/src/templates/web/routes/routes.ts +0 -22
- /package/src/templates/web/resources/css/{app.css → app.scss} +0 -0
- /package/src/templates/web/resources/{ts/islands → islands}/counter.vue +0 -0
- /package/src/templates/web/resources/{ts/islands → islands}/user_manager.vue +0 -0
- /package/src/templates/web/resources/{ts/islands → islands}/user_search.vue +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strav/spring",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Flagship framework scaffolding tool for the Strav ecosystem.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@strav/kernel": "0.3.
|
|
26
|
+
"@strav/kernel": "0.3.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bun": "latest"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { env } from '@strav/kernel'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
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 {
|
|
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('./
|
|
9
|
+
await import('./start/routes')
|
|
29
10
|
|
|
30
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
+
}
|
|
@@ -1,48 +1,26 @@
|
|
|
1
1
|
import 'reflect-metadata'
|
|
2
2
|
import { app } from '@strav/kernel'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
.
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
await
|
|
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('./
|
|
24
|
+
await import('./start/routes')
|
|
44
25
|
|
|
45
|
-
|
|
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,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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|