create-faas-app 8.0.0-beta.35 → 8.0.0-beta.36

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 (25) hide show
  1. package/README.md +5 -1
  2. package/dist/index.mjs +2 -1
  3. package/package.json +1 -1
  4. package/template/admin/package.json +1 -0
  5. package/template/admin/src/.faasjs/types.d.ts +16 -0
  6. package/template/admin/src/{pages/home/api/auth → features/auth/api}/__tests__/me.test.ts +1 -1
  7. package/template/admin/src/{pages/home/api/auth → features/auth/api}/me.api.ts +1 -1
  8. package/template/admin/src/{pages/home/api/users → features/users/api}/__tests__/create.test.ts +1 -1
  9. package/template/admin/src/{pages/home/api/users → features/users/api}/__tests__/detail.test.ts +1 -1
  10. package/template/admin/src/{pages/home/api/users → features/users/api}/__tests__/list.test.ts +1 -1
  11. package/template/admin/src/{pages/home/api/users → features/users/api}/__tests__/update.test.ts +1 -1
  12. package/template/admin/src/{pages/home → features/users}/index.tsx +5 -30
  13. package/template/admin/src/main.tsx +2 -2
  14. package/template/admin/tsconfig.json +1 -1
  15. package/template/minimal/package.json +1 -0
  16. package/template/minimal/src/.faasjs/types.d.ts +12 -0
  17. package/template/minimal/src/{pages → features}/home/api/__tests__/hello.test.ts +1 -1
  18. package/template/minimal/src/{pages → features}/home/index.tsx +2 -11
  19. package/template/minimal/src/main.tsx +1 -1
  20. package/template/minimal/tsconfig.json +1 -1
  21. /package/template/admin/src/{pages/home/api/users → features/users/api}/create.api.ts +0 -0
  22. /package/template/admin/src/{pages/home/api/users → features/users/api}/detail.api.ts +0 -0
  23. /package/template/admin/src/{pages/home/api/users → features/users/api}/list.api.ts +0 -0
  24. /package/template/admin/src/{pages/home/api/users → features/users/api}/update.api.ts +0 -0
  25. /package/template/minimal/src/{pages → features}/home/api/hello.api.ts +0 -0
package/README.md CHANGED
@@ -4,6 +4,8 @@ Create a new FaasJS app from a curated starter template.
4
4
 
5
5
  FaasJS is optimized for database-driven React business applications. `create-faas-app` gives new projects a working starting point for the official path instead of asking every team to assemble React, API, database, testing, and UI conventions from scratch.
6
6
 
7
+ This is the key difference from a generic React starter: the default template is shaped around complete business features. A feature is expected to connect UI, typed APIs, validation, PostgreSQL migrations, table types, and tests in one reviewable application slice.
8
+
7
9
  ## Quick Start
8
10
 
9
11
  ```bash
@@ -51,7 +53,7 @@ It is useful for learning the core FaasJS runtime, building API-only or BFF-styl
51
53
 
52
54
  Start with `admin` unless you have a specific reason not to. It shows how FaasJS expects complete application slices to fit together:
53
55
 
54
- - UI pages call typed APIs
56
+ - feature UI calls typed APIs
55
57
  - APIs validate inputs at system boundaries
56
58
  - APIs use PostgreSQL through the shared database workflow
57
59
  - migrations and table types keep data contracts explicit
@@ -59,6 +61,8 @@ Start with `admin` unless you have a specific reason not to. It shows how FaasJS
59
61
 
60
62
  FaasJS allows teams to replace parts of the stack, but the templates, docs, and examples optimize this curated path first.
61
63
 
64
+ Use `minimal` only when you intentionally want to step away from that path, such as for an API-only service, a BFF that will be paired with a separate frontend, or an app that needs a custom UI/database stack from day one.
65
+
62
66
  ## Auth And Permissions
63
67
 
64
68
  Authentication and permissions are intentionally not built into FaasJS core because production auth requirements vary by product.
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import enquirer from "enquirer";
8
8
  //#region package.json
9
- var version = "8.0.0-beta.34";
9
+ var version = "8.0.0-beta.35";
10
10
  //#endregion
11
11
  //#region src/action/index.ts
12
12
  const prompt = enquirer.prompt;
@@ -82,6 +82,7 @@ async function action(options = {}) {
82
82
  secret: generateSessionSecret()
83
83
  }, templateName);
84
84
  execSync(`cd ${answers.name} && npm install`, { stdio: "inherit" });
85
+ execSync(`cd ${answers.name} && npm run types`, { stdio: "inherit" });
85
86
  execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
86
87
  }
87
88
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-faas-app",
3
- "version": "8.0.0-beta.35",
3
+ "version": "8.0.0-beta.36",
4
4
  "homepage": "https://faasjs.com/doc/create-faas-app",
5
5
  "bugs": {
6
6
  "url": "https://github.com/faasjs/faasjs/issues"
@@ -7,6 +7,7 @@
7
7
  "dev": "vp dev",
8
8
  "build": "vp build",
9
9
  "start": "node --import @faasjs/node-utils/register-hooks server.ts",
10
+ "types": "faas types",
10
11
  "test": "vp test",
11
12
  "db:new": "faasjs-pg new",
12
13
  "db:status": "faasjs-pg status",
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Generated by @faasjs/dev.
3
+ *
4
+ * Do not edit this file manually.
5
+ */
6
+ import type { InferFaasAction } from '@faasjs/types'
7
+
8
+ declare module '@faasjs/types' {
9
+ interface FaasActions {
10
+ "features/auth/api/me": InferFaasAction<typeof import("../features/auth/api/me.api")>
11
+ "features/users/api/create": InferFaasAction<typeof import("../features/users/api/create.api")>
12
+ "features/users/api/detail": InferFaasAction<typeof import("../features/users/api/detail.api")>
13
+ "features/users/api/list": InferFaasAction<typeof import("../features/users/api/list.api")>
14
+ "features/users/api/update": InferFaasAction<typeof import("../features/users/api/update.api")>
15
+ }
16
+ }
@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'
3
3
 
4
4
  import api from '../me.api'
5
5
 
6
- describe('pages/home/api/auth/me', () => {
6
+ describe('features/auth/api/me', () => {
7
7
  it('returns the current user from the auth plugin demo', async () => {
8
8
  const handler = testApi(api)
9
9
 
@@ -1,7 +1,7 @@
1
1
  import { defineApi, HttpError } from '@faasjs/core'
2
2
  import { z } from '@faasjs/utils'
3
3
 
4
- import { AuthPlugin } from '../../../../plugins/auth'
4
+ import { AuthPlugin } from '../../../plugins/auth'
5
5
 
6
6
  const api = defineApi({
7
7
  schema: z.object({}).strict(),
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'
4
4
 
5
5
  import api from '../create.api'
6
6
 
7
- describe('pages/home/api/users/create', () => {
7
+ describe('features/users/api/create', () => {
8
8
  it('creates a user with the shared pg bootstrap', async () => {
9
9
  const handler = testApi(api)
10
10
 
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'
4
4
 
5
5
  import api from '../detail.api'
6
6
 
7
- describe('pages/home/api/users/detail', () => {
7
+ describe('features/users/api/detail', () => {
8
8
  it('returns one user', async () => {
9
9
  const client = await getClient()
10
10
  const [created] = await client.query('users').insert(
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'
4
4
 
5
5
  import api from '../list.api'
6
6
 
7
- describe('pages/home/api/users/list', () => {
7
+ describe('features/users/api/list', () => {
8
8
  it('lists users with total count', async () => {
9
9
  const client = await getClient()
10
10
 
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'
4
4
 
5
5
  import api from '../update.api'
6
6
 
7
- describe('pages/home/api/users/update', () => {
7
+ describe('features/users/api/update', () => {
8
8
  it('updates one user', async () => {
9
9
  const client = await getClient()
10
10
  const [created] = await client.query('users').insert(
@@ -1,35 +1,10 @@
1
- declare module '@faasjs/types' {
2
- interface FaasActions {
3
- '/pages/home/api/users/list': {
4
- Params: { limit: number }
5
- Data: { total?: number; rows?: { id: number; name: string }[] }
6
- }
7
- '/pages/home/api/users/create': {
8
- Params: { name?: string | undefined }
9
- Data: { message?: string; total?: number; user?: { id: number; name: string } }
10
- }
11
- '/pages/home/api/users/update': {
12
- Params: { id: number; name: string }
13
- Data: { message?: string; user?: { id: number; name: string } }
14
- }
15
- '/pages/home/api/users/detail': {
16
- Params: { id: number }
17
- Data: { user?: { id: number; name: string } }
18
- }
19
- '/pages/home/api/auth/me': {
20
- Params: Record<string, never>
21
- Data: { current_user?: { id: number; name: string; role: string } }
22
- }
23
- }
24
- }
25
-
26
1
  import { faas, useApp } from '@faasjs/ant-design'
27
2
  import { useFaas } from '@faasjs/react'
28
3
  import { toErrorMessage } from '@faasjs/utils'
29
4
  import { Button, Card, Input, Space, Table, Typography } from 'antd'
30
5
  import { useState } from 'react'
31
6
 
32
- export default function HomePage() {
7
+ export default function UsersPage() {
33
8
  const app = useApp()
34
9
  const [name, setName] = useState('FaasJS')
35
10
  const [messageText, setMessageText] = useState('Create your first user through the FaasJS API')
@@ -38,7 +13,7 @@ export default function HomePage() {
38
13
  data: listData,
39
14
  loading: listLoading,
40
15
  reload,
41
- } = useFaas('/pages/home/api/users/list', { limit: 10 })
16
+ } = useFaas('features/users/api/list', { limit: 10 })
42
17
 
43
18
  const rows = listData?.rows || []
44
19
 
@@ -46,7 +21,7 @@ export default function HomePage() {
46
21
  const callApi = async () => {
47
22
  setCreating(true)
48
23
  try {
49
- const response = await faas('/pages/home/api/users/create', {
24
+ const response = await faas('features/users/api/create', {
50
25
  name: name.trim() || undefined,
51
26
  })
52
27
  const result = response.data
@@ -75,7 +50,7 @@ export default function HomePage() {
75
50
  setAuthLoading(true)
76
51
  try {
77
52
  const response = await faas(
78
- '/pages/home/api/auth/me',
53
+ 'features/auth/api/me',
79
54
  {},
80
55
  {
81
56
  headers: { authorization: 'Bearer demo-admin' },
@@ -137,7 +112,7 @@ export default function HomePage() {
137
112
  Load users slice
138
113
  </Button>
139
114
  <Button type="primary" loading={creating} onClick={callApi}>
140
- Create /pages/home/api/users/create
115
+ Create features/users/api/create
141
116
  </Button>
142
117
  <Button loading={authLoading} onClick={callAuthDemo}>
143
118
  Call auth plugin demo
@@ -1,7 +1,7 @@
1
1
  import { App } from '@faasjs/ant-design'
2
2
  import { createRoot } from 'react-dom/client'
3
3
 
4
- import HomePage from './pages/home'
4
+ import UsersPage from './features/users'
5
5
 
6
6
  createRoot(document.getElementById('root') as HTMLElement).render(
7
7
  <App
@@ -20,6 +20,6 @@ createRoot(document.getElementById('root') as HTMLElement).render(
20
20
  },
21
21
  }}
22
22
  >
23
- <HomePage />
23
+ <UsersPage />
24
24
  </App>,
25
25
  )
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "@faasjs/types/tsconfig/build.json",
3
- "include": ["src", "vite.config.ts", "server.ts"]
3
+ "include": ["src", "src/.faasjs/types.d.ts", "vite.config.ts", "server.ts"]
4
4
  }
@@ -7,6 +7,7 @@
7
7
  "dev": "vp dev",
8
8
  "build": "vp build",
9
9
  "start": "node --import @faasjs/node-utils/register-hooks server.ts",
10
+ "types": "faas types",
10
11
  "test": "vp test"
11
12
  },
12
13
  "devDependencies": {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generated by @faasjs/dev.
3
+ *
4
+ * Do not edit this file manually.
5
+ */
6
+ import type { InferFaasAction } from '@faasjs/types'
7
+
8
+ declare module '@faasjs/types' {
9
+ interface FaasActions {
10
+ "features/home/api/hello": InferFaasAction<typeof import("../features/home/api/hello.api")>
11
+ }
12
+ }
@@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'
3
3
 
4
4
  import api from '../hello.api'
5
5
 
6
- describe('pages/home/api/hello', () => {
6
+ describe('features/home/api/hello', () => {
7
7
  it('should work', async () => {
8
8
  const handler = testApi(api)
9
9
 
@@ -1,12 +1,3 @@
1
- declare module '@faasjs/types' {
2
- interface FaasActions {
3
- '/pages/home/api/hello': {
4
- Params: { name?: string | undefined }
5
- Data: { message?: string }
6
- }
7
- }
8
- }
9
-
10
1
  import { useState } from 'react'
11
2
 
12
3
  import { useFaas } from '../../react-client'
@@ -15,7 +6,7 @@ export default function HomePage() {
15
6
  const [name, setName] = useState('FaasJS')
16
7
 
17
8
  const { data, loading, reload } = useFaas(
18
- '/pages/home/api/hello',
9
+ 'features/home/api/hello',
19
10
  { name: name.trim() || undefined },
20
11
  { skip: true },
21
12
  )
@@ -39,7 +30,7 @@ export default function HomePage() {
39
30
  onClick={() => reload({ name: name.trim() || undefined })}
40
31
  disabled={loading}
41
32
  >
42
- {loading ? 'Loading...' : 'Call /pages/home/api/hello'}
33
+ {loading ? 'Loading...' : 'Call features/home/api/hello'}
43
34
  </button>
44
35
  </main>
45
36
  )
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from 'react-dom/client'
2
2
 
3
- import HomePage from './pages/home'
3
+ import HomePage from './features/home'
4
4
 
5
5
  createRoot(document.getElementById('root') as HTMLElement).render(<HomePage />)
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "@faasjs/types/tsconfig/build.json",
3
- "include": ["src", "vite.config.ts", "server.ts"]
3
+ "include": ["src", "src/.faasjs/types.d.ts", "vite.config.ts", "server.ts"]
4
4
  }