create-faas-app 8.0.0-beta.3 → 8.0.0-beta.31
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 +66 -9
- package/dist/index.d.ts +11 -16
- package/dist/index.mjs +147 -153
- package/index.mjs +1 -1
- package/package.json +20 -23
- package/template/admin/.env.example +1 -0
- package/template/admin/gitignore +4 -0
- package/template/admin/index.html +12 -0
- package/template/admin/migrations/20250101000000_create_users.ts +12 -0
- package/template/admin/package.json +34 -0
- package/template/admin/server.ts +33 -0
- package/template/admin/src/faas.yaml +11 -0
- package/template/admin/src/main.tsx +25 -0
- package/template/admin/src/pages/home/api/auth/__tests__/me.test.ts +39 -0
- package/template/admin/src/pages/home/api/auth/me.api.ts +23 -0
- package/template/admin/src/pages/home/api/users/__tests__/create.test.ts +47 -0
- package/template/admin/src/pages/home/api/users/__tests__/detail.test.ts +39 -0
- package/template/admin/src/pages/home/api/users/__tests__/list.test.ts +31 -0
- package/template/admin/src/pages/home/api/users/__tests__/update.test.ts +51 -0
- package/template/admin/src/pages/home/api/users/create.api.ts +26 -0
- package/template/admin/src/pages/home/api/users/detail.api.ts +23 -0
- package/template/admin/src/pages/home/api/users/list.api.ts +22 -0
- package/template/admin/src/pages/home/api/users/update.api.ts +35 -0
- package/template/admin/src/pages/home/index.tsx +163 -0
- package/template/admin/src/plugins/auth.ts +25 -0
- package/template/admin/src/types/faasjs-auth.d.ts +8 -0
- package/template/admin/src/types/faasjs-pg.d.ts +10 -0
- package/template/admin/tsconfig.json +4 -0
- package/template/admin/vite.config.ts +12 -0
- package/template/minimal/gitignore +4 -0
- package/template/minimal/index.html +12 -0
- package/template/minimal/package.json +26 -0
- package/template/minimal/server.ts +33 -0
- package/template/minimal/src/faas.yaml +11 -0
- package/template/minimal/src/main.tsx +5 -0
- package/template/minimal/src/pages/home/api/__tests__/hello.test.ts +17 -0
- package/template/minimal/src/pages/home/api/hello.api.ts +13 -0
- package/template/minimal/src/pages/home/index.tsx +46 -0
- package/template/minimal/src/react-client.ts +8 -0
- package/template/minimal/tsconfig.json +4 -0
- package/template/minimal/vite.config.ts +6 -0
- package/dist/index.cjs +0 -164
package/README.md
CHANGED
|
@@ -1,20 +1,77 @@
|
|
|
1
1
|
# create-faas-app
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/create-faas-app)
|
|
3
|
+
Create a new FaasJS app from a curated starter template.
|
|
5
4
|
|
|
6
|
-
|
|
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.
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Quick Start
|
|
9
8
|
|
|
10
9
|
```bash
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
npx create-faas-app --name my-faas-app
|
|
11
|
+
cd my-faas-app
|
|
12
|
+
npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The default template is `admin`, which demonstrates the curated React + Ant Design + PostgreSQL path.
|
|
16
|
+
|
|
17
|
+
## Templates
|
|
18
|
+
|
|
19
|
+
### `admin`
|
|
20
|
+
|
|
21
|
+
Use `admin` for the golden-path FaasJS starter.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx create-faas-app --name my-admin --template admin
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
It includes:
|
|
28
|
+
|
|
29
|
+
- React app structure powered by Vite Plus
|
|
30
|
+
- `@faasjs/ant-design` and Ant Design for business UI
|
|
31
|
+
- `defineApi` endpoints for typed backend APIs
|
|
32
|
+
- a copyable users slice with create, list, detail, update, migration, table types, and API tests
|
|
33
|
+
- `@faasjs/pg` for PostgreSQL access and migrations
|
|
34
|
+
- `@faasjs/pg-dev` for pg-dev-powered tests
|
|
35
|
+
- `.env.example` for local database configuration
|
|
36
|
+
- type declarations for PostgreSQL table inference
|
|
37
|
+
|
|
38
|
+
This is the best starting point for admin panels, internal tools, SaaS dashboards, and other database-driven business applications.
|
|
39
|
+
|
|
40
|
+
### `minimal`
|
|
13
41
|
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
Use `minimal` when you want a smaller React starter without the database and Ant Design stack.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx create-faas-app --name my-minimal-app --template minimal
|
|
16
46
|
```
|
|
17
47
|
|
|
18
|
-
|
|
48
|
+
It is useful for learning the core FaasJS runtime, building API-only or BFF-style projects, or adding a custom UI/database path intentionally.
|
|
49
|
+
|
|
50
|
+
## Recommended Path
|
|
51
|
+
|
|
52
|
+
Start with `admin` unless you have a specific reason not to. It shows how FaasJS expects complete application slices to fit together:
|
|
53
|
+
|
|
54
|
+
- UI pages call typed APIs
|
|
55
|
+
- APIs validate inputs at system boundaries
|
|
56
|
+
- APIs use PostgreSQL through the shared database workflow
|
|
57
|
+
- migrations and table types keep data contracts explicit
|
|
58
|
+
- tests cover the API and database behavior
|
|
59
|
+
|
|
60
|
+
FaasJS allows teams to replace parts of the stack, but the templates, docs, and examples optimize this curated path first.
|
|
61
|
+
|
|
62
|
+
## Auth And Permissions
|
|
63
|
+
|
|
64
|
+
Authentication and permissions are intentionally not built into FaasJS core because production auth requirements vary by product.
|
|
65
|
+
|
|
66
|
+
The admin starter includes a small auth plugin demo. Treat it as a plugin pattern that shows how to inject current-user context, protect APIs, and model project-specific permissions. It is not a mandatory framework auth system.
|
|
67
|
+
|
|
68
|
+
## Next Steps
|
|
69
|
+
|
|
70
|
+
- Read the FaasJS guide at <https://faasjs.com/guide/>.
|
|
71
|
+
- Review the root README for the project direction and package overview.
|
|
72
|
+
- Explore runnable templates in <https://github.com/faasjs/faasjs/tree/main/templates>.
|
|
73
|
+
- Use the admin starter users slice as the reference for complete UI/API/database/test examples.
|
|
74
|
+
|
|
75
|
+
## API Docs
|
|
19
76
|
|
|
20
77
|
- [main](functions/main.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
|
|
3
|
+
//#region src/index.d.ts
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
* [](https://www.npmjs.com/package/create-faas-app)
|
|
5
|
+
* Run the `create-faas-app` CLI with a provided argv array.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* @param {string[]} argv - CLI arguments forwarded to Commander.
|
|
8
|
+
* @returns {Promise<Command>} Commander program instance after parsing.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { main } from 'create-faas-app'
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
* # use npm
|
|
13
|
-
* npx create-faas-app --name faasjs
|
|
14
|
-
*
|
|
15
|
-
* # use bun
|
|
16
|
-
* bunx create-faas-app --name faasjs
|
|
14
|
+
* await main(['node', 'create-faas-app', '--help'])
|
|
17
15
|
* ```
|
|
18
|
-
*
|
|
19
|
-
* @packageDocumentation
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
17
|
declare function main(argv: string[]): Promise<Command>;
|
|
23
|
-
|
|
24
|
-
export { main };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { main };
|
package/dist/index.mjs
CHANGED
|
@@ -1,162 +1,156 @@
|
|
|
1
|
-
import { Command } from
|
|
2
|
-
import { execSync } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
answers.name = await prompt({
|
|
25
|
-
type: "input",
|
|
26
|
-
name: "value",
|
|
27
|
-
message: "Project name",
|
|
28
|
-
initial: "faasjs",
|
|
29
|
-
validate: Validator.name
|
|
30
|
-
}).then((res) => res.value);
|
|
31
|
-
if (!answers.name) return;
|
|
32
|
-
mkdirSync(answers.name);
|
|
33
|
-
const runtime = process.versions.bun ? "bun" : "npm";
|
|
34
|
-
writeFileSync(
|
|
35
|
-
join(answers.name, "faas.yaml"),
|
|
36
|
-
`defaults:
|
|
37
|
-
plugins:
|
|
38
|
-
development:
|
|
39
|
-
testing:
|
|
40
|
-
staging:
|
|
41
|
-
production:
|
|
42
|
-
`
|
|
43
|
-
);
|
|
44
|
-
writeFileSync(
|
|
45
|
-
join(answers.name, "package.json"),
|
|
46
|
-
`{
|
|
47
|
-
"name": "${answers.name}",
|
|
48
|
-
"version": "1.0.0",
|
|
49
|
-
"private": true,
|
|
50
|
-
"scripts": {
|
|
51
|
-
"serve": "faas server",
|
|
52
|
-
"test": "vitest run"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"faasjs": "*"
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"vitest": "*"
|
|
59
|
-
}
|
|
60
|
-
}`
|
|
61
|
-
);
|
|
62
|
-
writeFileSync(
|
|
63
|
-
join(answers.name, "tsconfig.json"),
|
|
64
|
-
`{
|
|
65
|
-
"compilerOptions": {
|
|
66
|
-
"downlevelIteration": true,
|
|
67
|
-
"esModuleInterop": true,
|
|
68
|
-
"target": "ES2019",
|
|
69
|
-
"module": "ESNext",
|
|
70
|
-
"moduleResolution": "node",
|
|
71
|
-
"baseUrl": "."
|
|
72
|
-
}
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import enquirer from "enquirer";
|
|
8
|
+
//#region package.json
|
|
9
|
+
var version = "8.0.0-beta.30";
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/action/index.ts
|
|
12
|
+
const prompt = enquirer.prompt;
|
|
13
|
+
const validateName = (input) => Validator.name(input);
|
|
14
|
+
const templateRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "template");
|
|
15
|
+
const ignoredTemplateEntries = new Set(["node_modules"]);
|
|
16
|
+
const Validator = { name(input) {
|
|
17
|
+
const match = /^[a-z0-9-_]+$/i.test(input) ? true : "Must be a-z, 0-9 or -_";
|
|
18
|
+
if (match !== true) return match;
|
|
19
|
+
if (existsSync(input)) return `${input} folder exists, please try another name`;
|
|
20
|
+
return true;
|
|
21
|
+
} };
|
|
22
|
+
function getTemplateNames() {
|
|
23
|
+
return readdirSync(templateRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
73
24
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`node_modules/
|
|
79
|
-
tmp/
|
|
80
|
-
coverage/
|
|
81
|
-
*.tmp.js
|
|
82
|
-
`
|
|
83
|
-
);
|
|
84
|
-
mkdirSync(join(answers.name, ".vscode"));
|
|
85
|
-
writeFileSync(
|
|
86
|
-
join(answers.name, ".vscode", "settings.json"),
|
|
87
|
-
`{
|
|
88
|
-
"editor.detectIndentation": true,
|
|
89
|
-
"editor.insertSpaces": true,
|
|
90
|
-
"editor.tabSize": 2,
|
|
91
|
-
"editor.codeActionsOnSave": {
|
|
92
|
-
"source.fixAll": true
|
|
93
|
-
},
|
|
94
|
-
"editor.wordWrap": "on",
|
|
95
|
-
"files.insertFinalNewline": true,
|
|
96
|
-
"files.trimFinalNewlines": true,
|
|
97
|
-
"files.trimTrailingWhitespace": true
|
|
25
|
+
function resolveTemplateName(template = "admin") {
|
|
26
|
+
const templates = getTemplateNames();
|
|
27
|
+
if (templates.includes(template)) return template;
|
|
28
|
+
throw new Error(`Unknown template "${template}". Available templates: ${templates.join(", ")}`);
|
|
98
29
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
writeFileSync(
|
|
102
|
-
join(answers.name, ".vscode", "extensions.json"),
|
|
103
|
-
`{
|
|
104
|
-
"recommendations": [
|
|
105
|
-
"faasjs.faasjs-snippets"
|
|
106
|
-
]
|
|
30
|
+
function renderTemplate(content, replacements) {
|
|
31
|
+
return Object.entries(replacements).reduce((result, [key, value]) => result.replaceAll(`{{${key}}}`, value), content);
|
|
107
32
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
mkdirSync(join(answers.name, "__tests__"));
|
|
124
|
-
writeFileSync(
|
|
125
|
-
join(answers.name, "__tests__", "index.test.ts"),
|
|
126
|
-
`import { test } from '@faasjs/test'
|
|
127
|
-
import { func } from '../index.func'
|
|
128
|
-
|
|
129
|
-
describe('hello', () => {
|
|
130
|
-
it('should work', async () => {
|
|
131
|
-
const testFunc = test(func)
|
|
132
|
-
|
|
133
|
-
const { statusCode, data } = await testFunc.JSONhandler<string>({ name: 'world' })
|
|
134
|
-
|
|
135
|
-
expect(statusCode).toEqual(200)
|
|
136
|
-
expect(data).toEqual('Hello, world')
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
`
|
|
140
|
-
);
|
|
141
|
-
if (runtime === "bun") {
|
|
142
|
-
execSync(`cd ${answers.name} && bun test`, { stdio: "inherit" });
|
|
143
|
-
} else execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
|
|
33
|
+
function generateSessionSecret() {
|
|
34
|
+
return randomBytes(32).toString("hex");
|
|
35
|
+
}
|
|
36
|
+
function copyTemplateDirectory(sourcePath, targetPath, replacements) {
|
|
37
|
+
mkdirSync(targetPath, { recursive: true });
|
|
38
|
+
for (const entry of readdirSync(sourcePath, { withFileTypes: true })) {
|
|
39
|
+
if (ignoredTemplateEntries.has(entry.name)) continue;
|
|
40
|
+
const nextSourcePath = join(sourcePath, entry.name);
|
|
41
|
+
const nextTargetPath = join(targetPath, entry.name === "gitignore" ? ".gitignore" : entry.name);
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
copyTemplateDirectory(nextSourcePath, nextTargetPath, replacements);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
writeFileSync(nextTargetPath, renderTemplate(readFileSync(nextSourcePath, "utf8"), replacements));
|
|
47
|
+
}
|
|
144
48
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
49
|
+
function scaffold(rootPath, replacements, templateName) {
|
|
50
|
+
mkdirSync(rootPath);
|
|
51
|
+
copyTemplateDirectory(join(templateRoot, templateName), rootPath, replacements);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Scaffold a new FaasJS app from a bundled template and install its dependencies.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} [options] - Optional CLI arguments used to choose the project name and template.
|
|
57
|
+
* @param {string} [options.name] - Target folder name for the generated app.
|
|
58
|
+
* @param {string} [options.template] - Template name such as `admin` or `minimal`.
|
|
59
|
+
* @returns {Promise<void>} Resolves after the project is generated and its test command finishes.
|
|
60
|
+
* @throws {Error} When the selected template is unknown.
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* await action({
|
|
64
|
+
* name: 'faasjs-demo',
|
|
65
|
+
* template: 'admin',
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
async function action(options = {}) {
|
|
70
|
+
const templateName = resolveTemplateName(options.template);
|
|
71
|
+
const answers = Object.assign(options, {});
|
|
72
|
+
if (!options.name || Validator.name(options.name) !== true) answers.name = await prompt({
|
|
73
|
+
type: "input",
|
|
74
|
+
name: "value",
|
|
75
|
+
message: "Project name",
|
|
76
|
+
initial: "faasjs",
|
|
77
|
+
validate: validateName
|
|
78
|
+
}).then((res) => res.value);
|
|
79
|
+
if (!answers.name) return;
|
|
80
|
+
scaffold(answers.name, {
|
|
81
|
+
name: answers.name,
|
|
82
|
+
secret: generateSessionSecret()
|
|
83
|
+
}, templateName);
|
|
84
|
+
execSync(`cd ${answers.name} && npm install`, { stdio: "inherit" });
|
|
85
|
+
execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
|
|
147
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Register the `create-faas-app` command on a Commander program.
|
|
89
|
+
*
|
|
90
|
+
* @param {Command} program - Commander program instance extended with the generator command.
|
|
91
|
+
* @returns {void} No return value.
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const program = new Command()
|
|
95
|
+
*
|
|
96
|
+
* registerCreateFaasApp(program)
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
function registerCreateFaasApp(program) {
|
|
100
|
+
program.description("Create a new FaasJS app").on("--help", () => console.log(`Examples:
|
|
101
|
+
npx create-faas-app --name faasjs
|
|
102
|
+
npx create-faas-app --name faasjs-admin --template admin
|
|
103
|
+
npx create-faas-app --name faasjs-minimal --template minimal
|
|
148
104
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
105
|
+
Templates:
|
|
106
|
+
admin: recommended React + Ant Design + PostgreSQL starter
|
|
107
|
+
minimal: lighter React starter
|
|
108
|
+
|
|
109
|
+
Available:
|
|
110
|
+
${getTemplateNames().join(", ")}`)).option("--name <name>", "Project name").option("--template <template>", "Template name", "admin").action(action);
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/index.ts
|
|
114
|
+
/**
|
|
115
|
+
* # create-faas-app
|
|
116
|
+
*
|
|
117
|
+
* [](https://github.com/faasjs/faasjs/blob/main/packages/create-faas-app/LICENSE)
|
|
118
|
+
* [](https://www.npmjs.com/package/create-faas-app)
|
|
119
|
+
*
|
|
120
|
+
* Quick way to create a FaasJS project.
|
|
121
|
+
*
|
|
122
|
+
* ## Usage
|
|
123
|
+
*
|
|
124
|
+
* ```bash
|
|
125
|
+
* npx create-faas-app --name faasjs
|
|
126
|
+
* npx create-faas-app --name faasjs-admin --template admin
|
|
127
|
+
* npx create-faas-app --name faasjs-minimal --template minimal
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
const commander = new Command();
|
|
131
|
+
commander.storeOptionsAsProperties(false).allowUnknownOption(true).version(version).name("create-faas-app").exitOverride();
|
|
132
|
+
registerCreateFaasApp(commander);
|
|
133
|
+
/**
|
|
134
|
+
* Run the `create-faas-app` CLI with a provided argv array.
|
|
135
|
+
*
|
|
136
|
+
* @param {string[]} argv - CLI arguments forwarded to Commander.
|
|
137
|
+
* @returns {Promise<Command>} Commander program instance after parsing.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { main } from 'create-faas-app'
|
|
142
|
+
*
|
|
143
|
+
* await main(['node', 'create-faas-app', '--help'])
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
153
146
|
async function main(argv) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
147
|
+
try {
|
|
148
|
+
await commander.parseAsync(argv);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "commander.helpDisplayed") return commander;
|
|
151
|
+
console.error(error);
|
|
152
|
+
}
|
|
153
|
+
return commander;
|
|
160
154
|
}
|
|
161
|
-
|
|
155
|
+
//#endregion
|
|
162
156
|
export { main };
|
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-faas-app",
|
|
3
|
-
"version": "
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.cjs",
|
|
7
|
-
"module": "dist/index.mjs",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"bin": {
|
|
10
|
-
"create-faas-app": "index.mjs"
|
|
11
|
-
},
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.mjs",
|
|
16
|
-
"require": "./dist/index.cjs"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
3
|
+
"version": "8.0.0-beta.31",
|
|
19
4
|
"homepage": "https://faasjs.com/doc/create-faas-app",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/faasjs/faasjs/issues"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
20
9
|
"repository": {
|
|
21
10
|
"type": "git",
|
|
22
11
|
"url": "git+https://github.com/faasjs/faasjs.git",
|
|
23
12
|
"directory": "packages/create-faas-app"
|
|
24
13
|
},
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/faasjs/faasjs/issues"
|
|
27
|
-
},
|
|
28
14
|
"funding": "https://github.com/sponsors/faasjs",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
15
|
+
"bin": {
|
|
16
|
+
"create-faas-app": "index.mjs"
|
|
31
17
|
},
|
|
32
18
|
"files": [
|
|
33
19
|
"dist",
|
|
34
|
-
"index.
|
|
20
|
+
"index.mjs",
|
|
21
|
+
"template"
|
|
35
22
|
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/index.mjs",
|
|
25
|
+
"module": "dist/index.mjs",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
36
33
|
"dependencies": {
|
|
37
34
|
"commander": ">=14.0.0",
|
|
38
35
|
"enquirer": "*"
|
|
39
36
|
},
|
|
40
37
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
38
|
+
"node": ">=26.0.0",
|
|
42
39
|
"npm": ">=11.0.0"
|
|
43
40
|
}
|
|
44
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/{{name}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>FaasJS Ant Design App</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SchemaBuilder } from '@faasjs/pg'
|
|
2
|
+
|
|
3
|
+
export function up(builder: SchemaBuilder) {
|
|
4
|
+
builder.createTable('users', (table) => {
|
|
5
|
+
table.specificType('id', 'serial').primary()
|
|
6
|
+
table.string('name')
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function down(builder: SchemaBuilder) {
|
|
11
|
+
builder.dropTable('users')
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vp dev",
|
|
8
|
+
"build": "vp build",
|
|
9
|
+
"start": "node --import @faasjs/node-utils/register-hooks server.ts",
|
|
10
|
+
"test": "vp test",
|
|
11
|
+
"db:new": "faasjs-pg new",
|
|
12
|
+
"db:status": "faasjs-pg status",
|
|
13
|
+
"db:migrate": "faasjs-pg migrate",
|
|
14
|
+
"db:up": "faasjs-pg up",
|
|
15
|
+
"db:down": "faasjs-pg down"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@faasjs/dev": "*",
|
|
19
|
+
"@faasjs/pg-dev": "*"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@faasjs/ant-design": "*",
|
|
23
|
+
"@faasjs/core": "*",
|
|
24
|
+
"@faasjs/pg": "*"
|
|
25
|
+
},
|
|
26
|
+
"overrides": {
|
|
27
|
+
"vite": "npm:@voidzero-dev/vite-plus-core",
|
|
28
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=26.0.0",
|
|
32
|
+
"npm": ">=11.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path'
|
|
2
|
+
import { loadEnvFile } from 'node:process'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
import { Server, staticHandler } from '@faasjs/core'
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
8
|
+
const __dirname = dirname(__filename)
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
loadEnvFile()
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn('[faasjs] Failed to load env file', error)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const publicHandler = staticHandler({
|
|
17
|
+
root: join(__dirname, 'public'),
|
|
18
|
+
notFound: false,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const distHandler = staticHandler({
|
|
22
|
+
root: join(__dirname, 'dist'),
|
|
23
|
+
notFound: 'index.html',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
new Server(join(__dirname, 'src'), {
|
|
27
|
+
beforeHandle: async (req, res, ctx) => {
|
|
28
|
+
if (!req.url || req.method !== 'GET') return
|
|
29
|
+
|
|
30
|
+
await publicHandler(req, res, ctx)
|
|
31
|
+
await distHandler(req, res, ctx)
|
|
32
|
+
},
|
|
33
|
+
}).listen()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { App } from '@faasjs/ant-design'
|
|
2
|
+
import { createRoot } from 'react-dom/client'
|
|
3
|
+
|
|
4
|
+
import HomePage from './pages/home'
|
|
5
|
+
|
|
6
|
+
createRoot(document.getElementById('root') as HTMLElement).render(
|
|
7
|
+
<App
|
|
8
|
+
browserRouterProps={false}
|
|
9
|
+
configProviderProps={{
|
|
10
|
+
theme: {
|
|
11
|
+
token: {
|
|
12
|
+
borderRadius: 16,
|
|
13
|
+
colorPrimary: '#1677ff',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}}
|
|
17
|
+
faasConfigProviderProps={{
|
|
18
|
+
faasClientOptions: {
|
|
19
|
+
baseUrl: '/',
|
|
20
|
+
},
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<HomePage />
|
|
24
|
+
</App>,
|
|
25
|
+
)
|