@stone-js/starters 0.8.8 → 0.8.9

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 (74) hide show
  1. package/README.md +2 -2
  2. package/basic-react-declarative/app/Application.tsx +0 -2
  3. package/basic-react-declarative/package.json +7 -7
  4. package/basic-react-declarative/public/favicon.svg +16 -0
  5. package/basic-react-declarative/tests/Application.spec.ts +25 -100
  6. package/basic-react-imperative/app/Application.tsx +2 -17
  7. package/basic-react-imperative/package.json +7 -7
  8. package/basic-react-imperative/public/favicon.svg +16 -0
  9. package/basic-react-imperative/tests/Application.spec.ts +25 -86
  10. package/basic-service-declarative/app/Application.ts +0 -2
  11. package/basic-service-declarative/package.json +6 -6
  12. package/basic-service-declarative/tests/Application.spec.ts +20 -53
  13. package/basic-service-imperative/app/Application.ts +2 -14
  14. package/basic-service-imperative/package.json +6 -6
  15. package/basic-service-imperative/tests/Application.spec.ts +19 -44
  16. package/continuum-showcase/package.json +11 -10
  17. package/continuum-showcase/public/favicon.svg +16 -0
  18. package/continuum-showcase/stone.config.mjs +2 -2
  19. package/continuum-showcase/tests/application.spec.ts +30 -0
  20. package/full-react-declarative/app/Application.ts +0 -4
  21. package/full-react-declarative/package.json +12 -12
  22. package/full-react-declarative/public/favicon.svg +16 -0
  23. package/full-react-declarative/stone.config.mjs +2 -2
  24. package/full-react-declarative/tests/application.spec.ts +30 -0
  25. package/full-react-imperative/app/Application.ts +1 -3
  26. package/full-react-imperative/package.json +12 -12
  27. package/full-react-imperative/public/favicon.svg +16 -0
  28. package/full-react-imperative/stone.config.mjs +2 -2
  29. package/full-react-imperative/tests/application.spec.ts +30 -0
  30. package/full-service-declarative/app/Application.ts +5 -2
  31. package/full-service-declarative/app/configurations/AppConfiguration.ts +1 -3
  32. package/full-service-declarative/package.json +13 -12
  33. package/full-service-declarative/stone.config.mjs +2 -2
  34. package/full-service-declarative/tests/application.spec.ts +30 -0
  35. package/full-service-imperative/app/Application.ts +8 -2
  36. package/full-service-imperative/app/configurations/AppConfiguration.ts +1 -3
  37. package/full-service-imperative/package.json +13 -12
  38. package/full-service-imperative/stone.config.mjs +2 -2
  39. package/full-service-imperative/tests/application.spec.ts +30 -0
  40. package/package.json +1 -1
  41. package/standard-react-declarative/package.json +11 -10
  42. package/standard-react-declarative/public/favicon.svg +16 -0
  43. package/standard-react-declarative/tests/application.spec.ts +30 -0
  44. package/standard-react-imperative/package.json +11 -10
  45. package/standard-react-imperative/public/favicon.svg +16 -0
  46. package/standard-react-imperative/tests/application.spec.ts +30 -0
  47. package/standard-service-declarative/package.json +9 -8
  48. package/standard-service-declarative/tests/Application.spec.ts +22 -94
  49. package/standard-service-imperative/package.json +9 -8
  50. package/standard-service-imperative/tests/Application.spec.ts +22 -78
  51. package/basic-react-declarative/vitest.config.ts +0 -24
  52. package/basic-react-imperative/vitest.config.ts +0 -24
  53. package/basic-service-declarative/vitest.config.ts +0 -24
  54. package/basic-service-imperative/vitest.config.ts +0 -24
  55. package/continuum-showcase/tests/HomePage.spec.tsx +0 -41
  56. package/continuum-showcase/vitest.config.ts +0 -31
  57. package/full-react-declarative/tests/AppLayout.spec.ts +0 -51
  58. package/full-react-declarative/tests/HomePage.spec.ts +0 -38
  59. package/full-react-declarative/vitest.config.ts +0 -24
  60. package/full-react-imperative/tests/HomePage.spec.ts +0 -45
  61. package/full-react-imperative/tests/LayoutHeader.spec.ts +0 -39
  62. package/full-react-imperative/vitest.config.ts +0 -24
  63. package/full-service-declarative/tests/PostService.spec.ts +0 -56
  64. package/full-service-declarative/tests/WelcomeEventHandler.spec.ts +0 -54
  65. package/full-service-declarative/vitest.config.ts +0 -24
  66. package/full-service-imperative/tests/PostService.spec.ts +0 -47
  67. package/full-service-imperative/tests/WelcomeEventHandler.spec.ts +0 -31
  68. package/full-service-imperative/vitest.config.ts +0 -24
  69. package/standard-react-declarative/tests/WelcomePage.spec.ts +0 -71
  70. package/standard-react-declarative/vitest.config.ts +0 -24
  71. package/standard-react-imperative/tests/WelcomePage.spec.ts +0 -53
  72. package/standard-react-imperative/vitest.config.ts +0 -24
  73. package/standard-service-declarative/vitest.config.ts +0 -24
  74. package/standard-service-imperative/vitest.config.ts +0 -24
@@ -1,53 +1,28 @@
1
- import { IncomingHttpEvent } from '@stone-js/http-core'
2
- import { FunctionalEventHandler, ILogger } from '@stone-js/core'
3
- import { AppConfig, FactoryHandler, ResponseData } from '../app/Application'
4
-
5
- vi.mock('@stone-js/core', async (mod) => {
6
- const actual: any = await mod()
7
- return {
8
- ...actual,
9
- isNotEmpty: vi.fn(() => true),
10
- defineConfig: (config: any) => config
11
- }
12
- })
13
-
1
+ import { createTestApp, makeIncomingHttpEvent } from '@stone-js/testing'
2
+
3
+ /**
4
+ * The whole application, booted in memory and asked a real question.
5
+ *
6
+ * Nothing is mocked and nothing is listed: `createTestApp()` discovers `app/**`, and the event goes
7
+ * through the same kernel production runs. If this passes the application works; if it fails the
8
+ * application is broken. That is the only kind of test worth shipping in a starter — the previous one
9
+ * stubbed out the framework's own decorators, which meant it could pass while nothing worked.
10
+ */
14
11
  describe('Application', () => {
15
- let mockedLogger: ILogger
16
- let app: FunctionalEventHandler<IncomingHttpEvent, ResponseData>
17
-
18
- beforeEach(() => {
19
- mockedLogger = {
20
- info: vi.fn(),
21
- } as unknown as ILogger
12
+ it('answers the caller', async () => {
13
+ const app = await createTestApp()
22
14
 
23
- app = FactoryHandler({ logger: mockedLogger })
24
- })
25
-
26
- it('should create an event handler instance', () => {
27
- // Assert
28
- expect(app).toBeTypeOf('function')
29
- })
15
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/?name=Ada' }))
30
16
 
31
- it('should handle incoming http events', async () => {
32
- // Arrange
33
- const event = { get: () => 'World' } as unknown as IncomingHttpEvent
34
- // Act
35
- const response = await app(event)
36
- // Assert
37
- expect(response.message).toBe('Hello World! Welcome to Stone.js.')
38
- expect(response.framework.name).toBe('Stone.js')
39
- expect(mockedLogger.info).toHaveBeenCalledWith('Hello World! Welcome to Stone.js.')
17
+ expect(response.statusCode).toBe(200)
18
+ expect(response.json()).toMatchObject({ message: expect.stringContaining('Ada') })
40
19
  })
41
20
 
42
- it('should get config', () => {
43
- // Arrange
44
- const config: any = AppConfig
45
- const blueprint: any = { is: () => true, set: vi.fn() }
21
+ it('answers when nobody says who they are', async () => {
22
+ const app = await createTestApp()
46
23
 
47
- // Act
48
- config.afterConfigure(blueprint)
24
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/' }))
49
25
 
50
- // Assert
51
- expect(blueprint.set).toHaveBeenCalled()
26
+ expect(response.statusCode).toBe(200)
52
27
  })
53
28
  })
@@ -9,25 +9,26 @@
9
9
  "build": "stone build",
10
10
  "build:ssr": "stone build --ssr",
11
11
  "preview": "stone preview",
12
- "test": "vitest run",
13
- "test:cvg": "npm run test -- --coverage"
12
+ "test": "stone test",
13
+ "test:cvg": "stone test --coverage"
14
14
  },
15
15
  "dependencies": {
16
16
  "react": "^19.0.0",
17
17
  "react-dom": "^19.0.0",
18
- "@stone-js/core": "^0.8.8",
19
- "@stone-js/router": "^0.8.8",
20
- "@stone-js/use-react": "^0.8.8",
21
- "@stone-js/http-core": "^0.8.8",
22
- "@stone-js/pipeline": "^0.8.8",
23
- "@stone-js/browser-adapter": "^0.8.8",
24
- "@stone-js/node-http-adapter": "^0.8.8"
18
+ "@stone-js/core": "^0.8.9",
19
+ "@stone-js/router": "^0.8.9",
20
+ "@stone-js/use-react": "^0.8.9",
21
+ "@stone-js/http-core": "^0.8.9",
22
+ "@stone-js/pipeline": "^0.8.9",
23
+ "@stone-js/browser-adapter": "^0.8.9",
24
+ "@stone-js/node-http-adapter": "^0.8.9"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@babel/plugin-proposal-decorators": "^7.25.9",
28
28
  "@babel/preset-env": "^7.26.9",
29
29
  "@babel/preset-typescript": "^7.27.0",
30
- "@stone-js/cli": "^0.8.8",
30
+ "@stone-js/cli": "^0.8.9",
31
+ "@stone-js/testing": "^0.8.9",
31
32
  "@types/node": "^24.0.7",
32
33
  "@types/react": "^19.0.7",
33
34
  "@types/react-dom": "^19.0.3",
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-label="Stone.js">
2
+ <title>Stone.js</title>
3
+ <style>
4
+ .ink { stroke: #1B1613; }
5
+ @media (prefers-color-scheme: dark) { .ink { stroke: #EFE8DC; } }
6
+ </style>
7
+ <defs>
8
+ <linearGradient id="braise" gradientUnits="userSpaceOnUse" x1="22" y1="14" x2="74" y2="26.1">
9
+ <stop offset="0" stop-color="#FFC46B" />
10
+ <stop offset="1" stop-color="#FF5A1F" />
11
+ </linearGradient>
12
+ </defs>
13
+ <path class="ink" d="M 79.96 36.4 A 34 34 0 0 1 53.9 81.5" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
14
+ <path class="ink" d="M 42.1 81.5 A 34 34 0 0 1 16.05 36.4" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
15
+ <path d="M 22 26.1 A 34 34 0 0 1 74 26.1" fill="none" stroke="url(#braise)" stroke-width="11" stroke-linecap="round" />
16
+ </svg>
@@ -1,4 +1,4 @@
1
- import { defineConfig } from '@stone-js/cli'
1
+ import { defineBuilderConfig } from '@stone-js/cli'
2
2
 
3
3
  /**
4
4
  * Build configuration for the showcase.
@@ -6,7 +6,7 @@ import { defineConfig } from '@stone-js/cli'
6
6
  * - `target: 'react'` + `rendering: 'ssr'` exercises the server-rendered head pipeline.
7
7
  * - `assets` enables the `@img` / `@css` / `@assets` import aliases used in components.
8
8
  */
9
- export default defineConfig({
9
+ export default defineBuilderConfig({
10
10
  target: 'react',
11
11
  rendering: 'ssr',
12
12
  assets: {
@@ -0,0 +1,30 @@
1
+ import { createTestApp, makeIncomingHttpEvent } from '@stone-js/testing'
2
+
3
+ /**
4
+ * The whole application, booted in memory and asked a real question.
5
+ *
6
+ * Nothing is mocked and nothing is listed: `createTestApp()` discovers `app/**`, and the event goes
7
+ * through the same kernel production runs. If this passes the application works; if it fails the
8
+ * application is broken. That is the only kind of test worth shipping in a starter — the previous one
9
+ * stubbed out the framework's own decorators, which meant it could pass while nothing worked.
10
+ */
11
+ describe('Pages', () => {
12
+ it('renders the home page, data included', async () => {
13
+ const app = await createTestApp()
14
+
15
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/?name=Ada' }))
16
+
17
+ expect(response.statusCode).toBe(200)
18
+ // A page is a handler, so a rendered page is a response whose body is HTML. Query that HTML with
19
+ // whatever you already use (happy-dom, jsdom, Testing Library): none is bundled here.
20
+ expect(response.html()).toContain('Ada')
21
+ })
22
+
23
+ it('renders without a name', async () => {
24
+ const app = await createTestApp()
25
+
26
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/' }))
27
+
28
+ expect(response.statusCode).toBe(200)
29
+ })
30
+ })
@@ -2,7 +2,6 @@ import { Routing } from '@stone-js/router'
2
2
  import { Browser } from '@stone-js/browser-adapter'
3
3
  import { Hook, UseReact } from '@stone-js/use-react'
4
4
  import { NodeHttp } from '@stone-js/node-http-adapter'
5
- import { NodeConsole } from '@stone-js/node-cli-adapter'
6
5
  import { IBlueprint, IContainer, ILogger, LogLevel, Promiseable, StoneApp } from '@stone-js/core'
7
6
 
8
7
  /**
@@ -13,8 +12,6 @@ import { IBlueprint, IContainer, ILogger, LogLevel, Promiseable, StoneApp } from
13
12
  * @StoneApp() is used to enable the Stone application, it is mandatory.
14
13
  * @Routing() is used to enable the routing feature.
15
14
  * @NodeHttp() is used to enable the Node HTTP adapter.
16
- * @NodeConsole() is used to enable the Node Console adapter.
17
- * @NodeConsole() requires the incoming event type.
18
15
  * BodyEventMiddleware is used to parse the incoming event body.
19
16
  * BodyEventMiddleware is imported because it is not installed by default.
20
17
  *
@@ -25,7 +22,6 @@ import { IBlueprint, IContainer, ILogger, LogLevel, Promiseable, StoneApp } from
25
22
  @Routing()
26
23
  @Browser()
27
24
  @UseReact()
28
- @NodeConsole()
29
25
  @NodeHttp({ default: true, url: 'http://localhost:3100' })
30
26
  @StoneApp({ name: 'My Stone', logger: { level: LogLevel.DEBUG } })
31
27
  export class Application {
@@ -14,19 +14,18 @@
14
14
  "build": "stone build",
15
15
  "preview": "stone preview",
16
16
  "build:ssr": "stone build --ssr",
17
- "test": "vitest run",
18
- "test:cvg": "npm run test -- --coverage"
17
+ "test": "stone test",
18
+ "test:cvg": "stone test --coverage"
19
19
  },
20
20
  "dependencies": {
21
- "@stone-js/env": "^0.8.8",
22
- "@stone-js/http-core": "^0.8.8",
23
- "@stone-js/node-http-adapter": "^0.8.8",
24
- "@stone-js/router": "^0.8.8",
25
- "@stone-js/filesystem": "^0.8.8",
26
- "@stone-js/core": "^0.8.8",
27
- "@stone-js/use-react": "^0.8.8",
28
- "@stone-js/browser-adapter": "^0.8.8",
29
- "@stone-js/node-cli-adapter": "^0.8.8",
21
+ "@stone-js/env": "^0.8.9",
22
+ "@stone-js/http-core": "^0.8.9",
23
+ "@stone-js/node-http-adapter": "^0.8.9",
24
+ "@stone-js/router": "^0.8.9",
25
+ "@stone-js/filesystem": "^0.8.9",
26
+ "@stone-js/core": "^0.8.9",
27
+ "@stone-js/use-react": "^0.8.9",
28
+ "@stone-js/browser-adapter": "^0.8.9",
30
29
  "axios": "^1.7.9",
31
30
  "react": "^19.0.0",
32
31
  "react-dom": "^19.0.0"
@@ -35,7 +34,8 @@
35
34
  "@babel/plugin-proposal-decorators": "^7.25.9",
36
35
  "@babel/preset-env": "^7.26.9",
37
36
  "@babel/preset-typescript": "^7.27.0",
38
- "@stone-js/cli": "^0.8.8",
37
+ "@stone-js/cli": "^0.8.9",
38
+ "@stone-js/testing": "^0.8.9",
39
39
  "@types/axios": "^0.14.4",
40
40
  "@types/node": "^24.0.7",
41
41
  "@types/react": "^19.0.7",
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-label="Stone.js">
2
+ <title>Stone.js</title>
3
+ <style>
4
+ .ink { stroke: #1B1613; }
5
+ @media (prefers-color-scheme: dark) { .ink { stroke: #EFE8DC; } }
6
+ </style>
7
+ <defs>
8
+ <linearGradient id="braise" gradientUnits="userSpaceOnUse" x1="22" y1="14" x2="74" y2="26.1">
9
+ <stop offset="0" stop-color="#FFC46B" />
10
+ <stop offset="1" stop-color="#FF5A1F" />
11
+ </linearGradient>
12
+ </defs>
13
+ <path class="ink" d="M 79.96 36.4 A 34 34 0 0 1 53.9 81.5" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
14
+ <path class="ink" d="M 42.1 81.5 A 34 34 0 0 1 16.05 36.4" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
15
+ <path d="M 22 26.1 A 34 34 0 0 1 74 26.1" fill="none" stroke="url(#braise)" stroke-width="11" stroke-linecap="round" />
16
+ </svg>
@@ -1,9 +1,9 @@
1
- import { defineConfig } from '@stone-js/cli'
1
+ import { defineBuilderConfig } from '@stone-js/cli'
2
2
 
3
3
  /**
4
4
  * Stone build configuration.
5
5
  */
6
- export default defineConfig({
6
+ export default defineBuilderConfig({
7
7
  dotenv: {
8
8
  private: {
9
9
  path: ['.env', '.env.public'],
@@ -0,0 +1,30 @@
1
+ import { createTestApp, makeIncomingHttpEvent } from '@stone-js/testing'
2
+
3
+ /**
4
+ * The whole application, booted in memory and asked a real question.
5
+ *
6
+ * Nothing is mocked and nothing is listed: `createTestApp()` discovers `app/**`, and the event goes
7
+ * through the same kernel production runs. If this passes the application works; if it fails the
8
+ * application is broken. That is the only kind of test worth shipping in a starter — the previous one
9
+ * stubbed out the framework's own decorators, which meant it could pass while nothing worked.
10
+ */
11
+ describe('Pages', () => {
12
+ it('renders the home page, data included', async () => {
13
+ const app = await createTestApp()
14
+
15
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/?name=Ada' }))
16
+
17
+ expect(response.statusCode).toBe(200)
18
+ // A page is a handler, so a rendered page is a response whose body is HTML. Query that HTML with
19
+ // whatever you already use (happy-dom, jsdom, Testing Library): none is bundled here.
20
+ expect(response.html()).toContain('Ada')
21
+ })
22
+
23
+ it('renders without a name', async () => {
24
+ const app = await createTestApp()
25
+
26
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/' }))
27
+
28
+ expect(response.statusCode).toBe(200)
29
+ })
30
+ })
@@ -1,7 +1,6 @@
1
1
  import { routerBlueprint } from '@stone-js/router'
2
2
  import { browserAdapterBlueprint } from '@stone-js/browser-adapter'
3
3
  import { nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
4
- import { nodeConsoleAdapterBlueprint } from '@stone-js/node-cli-adapter'
5
4
  import { defineStoneReactApp, ReactLifecycleHookType } from '@stone-js/use-react'
6
5
  import { defineHookListeners, IBlueprint, IContainer, ILogger, LogLevel, Promiseable } from '@stone-js/core'
7
6
 
@@ -61,8 +60,7 @@ export const MyStoneReactApp = defineStoneReactApp(
61
60
  [
62
61
  routerBlueprint,
63
62
  browserAdapterBlueprint,
64
- nodeHttpAdapterBlueprint,
65
- nodeConsoleAdapterBlueprint
63
+ nodeHttpAdapterBlueprint
66
64
  ]
67
65
  )
68
66
 
@@ -14,19 +14,18 @@
14
14
  "build": "stone build",
15
15
  "preview": "stone preview",
16
16
  "build:ssr": "stone build --ssr",
17
- "test": "vitest run",
18
- "test:cvg": "npm run test -- --coverage"
17
+ "test": "stone test",
18
+ "test:cvg": "stone test --coverage"
19
19
  },
20
20
  "dependencies": {
21
- "@stone-js/env": "^0.8.8",
22
- "@stone-js/http-core": "^0.8.8",
23
- "@stone-js/node-http-adapter": "^0.8.8",
24
- "@stone-js/router": "^0.8.8",
25
- "@stone-js/filesystem": "^0.8.8",
26
- "@stone-js/core": "^0.8.8",
27
- "@stone-js/use-react": "^0.8.8",
28
- "@stone-js/browser-adapter": "^0.8.8",
29
- "@stone-js/node-cli-adapter": "^0.8.8",
21
+ "@stone-js/env": "^0.8.9",
22
+ "@stone-js/http-core": "^0.8.9",
23
+ "@stone-js/node-http-adapter": "^0.8.9",
24
+ "@stone-js/router": "^0.8.9",
25
+ "@stone-js/filesystem": "^0.8.9",
26
+ "@stone-js/core": "^0.8.9",
27
+ "@stone-js/use-react": "^0.8.9",
28
+ "@stone-js/browser-adapter": "^0.8.9",
30
29
  "axios": "^1.7.9",
31
30
  "dayjs": "^1.11.13",
32
31
  "react": "^19.0.0",
@@ -36,7 +35,8 @@
36
35
  "@babel/plugin-proposal-decorators": "^7.25.9",
37
36
  "@babel/preset-env": "^7.26.9",
38
37
  "@babel/preset-typescript": "^7.27.0",
39
- "@stone-js/cli": "^0.8.8",
38
+ "@stone-js/cli": "^0.8.9",
39
+ "@stone-js/testing": "^0.8.9",
40
40
  "@types/axios": "^0.14.4",
41
41
  "@types/node": "^24.0.7",
42
42
  "@types/react": "^19.0.7",
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-label="Stone.js">
2
+ <title>Stone.js</title>
3
+ <style>
4
+ .ink { stroke: #1B1613; }
5
+ @media (prefers-color-scheme: dark) { .ink { stroke: #EFE8DC; } }
6
+ </style>
7
+ <defs>
8
+ <linearGradient id="braise" gradientUnits="userSpaceOnUse" x1="22" y1="14" x2="74" y2="26.1">
9
+ <stop offset="0" stop-color="#FFC46B" />
10
+ <stop offset="1" stop-color="#FF5A1F" />
11
+ </linearGradient>
12
+ </defs>
13
+ <path class="ink" d="M 79.96 36.4 A 34 34 0 0 1 53.9 81.5" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
14
+ <path class="ink" d="M 42.1 81.5 A 34 34 0 0 1 16.05 36.4" fill="none" stroke-width="11" stroke-linecap="round" opacity=".85" />
15
+ <path d="M 22 26.1 A 34 34 0 0 1 74 26.1" fill="none" stroke="url(#braise)" stroke-width="11" stroke-linecap="round" />
16
+ </svg>
@@ -1,9 +1,9 @@
1
- import { defineConfig } from '@stone-js/cli'
1
+ import { defineBuilderConfig } from '@stone-js/cli'
2
2
 
3
3
  /**
4
4
  * Stone build configuration.
5
5
  */
6
- export default defineConfig({
6
+ export default defineBuilderConfig({
7
7
  dotenv: {
8
8
  private: {
9
9
  path: ['.env', '.env.public'],
@@ -0,0 +1,30 @@
1
+ import { createTestApp, makeIncomingHttpEvent } from '@stone-js/testing'
2
+
3
+ /**
4
+ * The whole application, booted in memory and asked a real question.
5
+ *
6
+ * Nothing is mocked and nothing is listed: `createTestApp()` discovers `app/**`, and the event goes
7
+ * through the same kernel production runs. If this passes the application works; if it fails the
8
+ * application is broken. That is the only kind of test worth shipping in a starter — the previous one
9
+ * stubbed out the framework's own decorators, which meant it could pass while nothing worked.
10
+ */
11
+ describe('Pages', () => {
12
+ it('renders the home page, data included', async () => {
13
+ const app = await createTestApp()
14
+
15
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/?name=Ada' }))
16
+
17
+ expect(response.statusCode).toBe(200)
18
+ // A page is a handler, so a rendered page is a response whose body is HTML. Query that HTML with
19
+ // whatever you already use (happy-dom, jsdom, Testing Library): none is bundled here.
20
+ expect(response.html()).toContain('Ada')
21
+ })
22
+
23
+ it('renders without a name', async () => {
24
+ const app = await createTestApp()
25
+
26
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/' }))
27
+
28
+ expect(response.statusCode).toBe(200)
29
+ })
30
+ })
@@ -1,11 +1,11 @@
1
1
  import {
2
+ Cors,
2
3
  IncomingHttpEvent,
3
4
  OutgoingHttpResponse,
4
5
  IncomingHttpEventOptions
5
6
  } from '@stone-js/http-core'
6
7
  import {
7
8
  NodeHttp,
8
- MetaBodyEventMiddleware,
9
9
  MetaFilesEventMiddleware
10
10
  } from '@stone-js/node-http-adapter'
11
11
  import {
@@ -35,15 +35,18 @@ import { PipelineHookContext } from '@stone-js/pipeline'
35
35
  * @NodeHttp() is used to enable the Node HTTP adapter.
36
36
  * @NodeConsole() is used to enable the Node Console adapter.
37
37
  * @NodeConsole() requires the incoming event type.
38
+ * @Cors() answers cross-origin requests, on the kernel and the adapter alike.
39
+ * Nothing is allowed until you name the origins you trust: add `origin: ['https://your-front']`.
38
40
  * BodyEventMiddleware is used to parse the incoming event body.
39
41
  * BodyEventMiddleware is imported because it is not installed by default.
40
42
  *
41
43
  * Note: In this example we implement the IBlueprintHook, IAdapterHook and IKernelHook interfaces for demonstration purposes.
42
44
  */
45
+ @Cors({ preflightStop: true, allowedHeaders: ['*'] })
43
46
  @Routing()
44
47
  @NodeConsole()
45
48
  @StoneApp({ name: 'MyApps', logger: { level: LogLevel.INFO } })
46
- @NodeHttp({ default: true, middleware: [MetaBodyEventMiddleware, MetaFilesEventMiddleware], url: getString('BASE_URL', 'http://localhost:8080') })
49
+ @NodeHttp({ default: true, middleware: [MetaFilesEventMiddleware], url: getString('BASE_URL', 'http://localhost:8080') })
47
50
  export class Application {
48
51
  /**
49
52
  * Run before the blueprint is prepared
@@ -1,7 +1,6 @@
1
1
  import { Config } from '@libsql/client'
2
2
  import { getString } from '@stone-js/env'
3
- import { CORSHeadersMiddleware } from '@stone-js/http-core'
4
- import { Configuration, defineBlueprintMiddleware, IBlueprint, IConfiguration, LogLevel, Promiseable } from '@stone-js/core'
3
+ import { Configuration, IBlueprint, IConfiguration, LogLevel, Promiseable } from '@stone-js/core'
5
4
 
6
5
  /**
7
6
  * User Implicit Configuration
@@ -23,7 +22,6 @@ export class AppConfiguration implements IConfiguration {
23
22
  .set('stone.logger.level', LogLevel.INFO)
24
23
  .set('stone.http.cors.preflightStop', true)
25
24
  .set('stone.http.cors.allowedHeaders', ['*'])
26
- .set(defineBlueprintMiddleware(CORSHeadersMiddleware))
27
25
  }
28
26
 
29
27
  /**
@@ -17,28 +17,29 @@
17
17
  "db:setup": "drizzle-kit push",
18
18
  "db:generate": "drizzle-kit generate",
19
19
  "db:migrate": "drizzle-kit migrate",
20
- "test": "vitest run",
21
- "test:cvg": "npm run test -- --coverage"
20
+ "test": "stone test",
21
+ "test:cvg": "stone test --coverage"
22
22
  },
23
23
  "dependencies": {
24
24
  "@libsql/client": "^0.14.0",
25
- "@stone-js/core": "^0.8.8",
26
- "@stone-js/env": "^0.8.8",
27
- "@stone-js/filesystem": "^0.8.8",
28
- "@stone-js/http-core": "^0.8.8",
29
- "@stone-js/node-cli-adapter": "^0.8.8",
30
- "@stone-js/node-http-adapter": "^0.8.8",
31
- "@stone-js/pipeline": "^0.8.8",
32
- "@stone-js/router": "^0.8.8",
25
+ "@stone-js/core": "^0.8.9",
26
+ "@stone-js/env": "^0.8.9",
27
+ "@stone-js/filesystem": "^0.8.9",
28
+ "@stone-js/http-core": "^0.8.9",
29
+ "@stone-js/node-cli-adapter": "^0.8.9",
30
+ "@stone-js/node-http-adapter": "^0.8.9",
31
+ "@stone-js/pipeline": "^0.8.9",
32
+ "@stone-js/router": "^0.8.9",
33
33
  "bcryptjs": "^3.0.2",
34
- "drizzle-orm": "^0.44.7",
34
+ "drizzle-orm": "^0.45.2",
35
35
  "jsonwebtoken": "^9.0.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@babel/plugin-proposal-decorators": "^7.25.9",
39
39
  "@babel/preset-env": "^7.26.9",
40
40
  "@babel/preset-typescript": "^7.27.0",
41
- "@stone-js/cli": "^0.8.8",
41
+ "@stone-js/cli": "^0.8.9",
42
+ "@stone-js/testing": "^0.8.9",
42
43
  "@types/jsonwebtoken": "^9.0.8",
43
44
  "@types/node": "^24.0.3",
44
45
  "@vitest/coverage-v8": "^3.0.9",
@@ -1,9 +1,9 @@
1
- import { defineConfig } from '@stone-js/cli'
1
+ import { defineBuilderConfig } from '@stone-js/cli'
2
2
 
3
3
  /**
4
4
  * Stone build configuration.
5
5
  */
6
- export default defineConfig({
6
+ export default defineBuilderConfig({
7
7
  rollup: {
8
8
  bundle: {
9
9
  external: ['@libsql/client'],
@@ -0,0 +1,30 @@
1
+ import { createTestApp, makeIncomingHttpEvent } from '@stone-js/testing'
2
+
3
+ /**
4
+ * The whole application, booted in memory and asked a real question.
5
+ *
6
+ * Nothing is mocked and nothing is listed: `createTestApp()` discovers `app/**`, and the event goes
7
+ * through the same kernel production runs. If this passes the application works; if it fails the
8
+ * application is broken. That is the only kind of test worth shipping in a starter — the previous one
9
+ * stubbed out the framework's own decorators, which meant it could pass while nothing worked.
10
+ */
11
+ describe('Application', () => {
12
+ it('answers on the public welcome route', async () => {
13
+ const app = await createTestApp()
14
+
15
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/' }))
16
+
17
+ expect(response.statusCode).toBe(200)
18
+ expect(response.json()).toMatchObject({ message: expect.stringContaining('Stone.js') })
19
+ })
20
+
21
+ it('refuses an unauthenticated request to a protected route', async () => {
22
+ // Substitute a repository with `bindings` when a route needs data:
23
+ // createTestApp({ bindings: { userRepository: fakeRepository } })
24
+ const app = await createTestApp()
25
+
26
+ const response = await app.send(makeIncomingHttpEvent({ method: 'GET', url: '/users' }))
27
+
28
+ expect(response.statusCode).toBeGreaterThanOrEqual(400)
29
+ })
30
+ })
@@ -1,4 +1,5 @@
1
1
  import {
2
+ corsBlueprint,
2
3
  IncomingHttpEvent,
3
4
  OutgoingHttpResponse,
4
5
  IncomingHttpEventOptions
@@ -21,7 +22,7 @@ import { getString } from '@stone-js/env'
21
22
  import { routerBlueprint } from '@stone-js/router'
22
23
  import { PipelineHookContext } from '@stone-js/pipeline'
23
24
  import { nodeConsoleAdapterBlueprint } from '@stone-js/node-cli-adapter'
24
- import { MetaBodyEventMiddleware, MetaFilesEventMiddleware, NODE_HTTP_PLATFORM, nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
25
+ import { MetaFilesEventMiddleware, NODE_HTTP_PLATFORM, nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
25
26
 
26
27
  /**
27
28
  * Run before the blueprint is prepared
@@ -288,6 +289,7 @@ export const onTerminate = defineHookListener((container: IContainer): void => {
288
289
  export const Application = defineStoneApp(
289
290
  { name: 'MyApp', logger: { level: LogLevel.INFO } },
290
291
  [
292
+ corsBlueprint,
291
293
  routerBlueprint,
292
294
  nodeHttpAdapterBlueprint,
293
295
  nodeConsoleAdapterBlueprint
@@ -308,10 +310,14 @@ export const AppConfig = defineConfig({
308
310
  })
309
311
  },
310
312
  afterConfigure (blueprint: IBlueprint) {
313
+ // Nothing is allowed cross-origin until you name the origins you trust:
314
+ // add `origin: ['https://your-front']` here.
315
+ blueprint.set('stone.http.cors', { preflightStop: true, allowedHeaders: ['*'] })
316
+
311
317
  if (blueprint.is('stone.adapter.platform', NODE_HTTP_PLATFORM)) {
312
318
  blueprint
313
319
  .set('stone.adapter.url', getString('BASE_URL', 'http://localhost:8080'))
314
- .add('stone.adapter.middleware', [MetaBodyEventMiddleware, MetaFilesEventMiddleware])
320
+ .add('stone.adapter.middleware', [MetaFilesEventMiddleware])
315
321
  }
316
322
  }
317
323
  })
@@ -1,7 +1,6 @@
1
1
  import { Config } from '@libsql/client'
2
2
  import { getString } from '@stone-js/env'
3
- import { CORSHeadersMiddleware } from '@stone-js/http-core'
4
- import { defineBlueprintMiddleware, defineConfig, IBlueprint, LogLevel, Promiseable } from '@stone-js/core'
3
+ import { defineConfig, IBlueprint, LogLevel, Promiseable } from '@stone-js/core'
5
4
 
6
5
  /**
7
6
  * User Implicit Configuration
@@ -16,7 +15,6 @@ export const AppConfiguration = defineConfig((blueprint: IBlueprint): Promiseabl
16
15
  .set('stone.logger.level', LogLevel.INFO)
17
16
  .set('stone.http.cors.preflightStop', true)
18
17
  .set('stone.http.cors.allowedHeaders', ['*'])
19
- .set(defineBlueprintMiddleware(CORSHeadersMiddleware))
20
18
  })
21
19
 
22
20
  /**