@appweaver/create-weaver-app 1.0.0
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/LICENSE +1 -0
- package/README.md +7 -0
- package/create-weaver-app.d.ts +2 -0
- package/create-weaver-app.js +266 -0
- package/package.json +37 -0
- package/skill/GUIDELINES.md +298 -0
- package/skill/SKILL.md +593 -0
- package/skill/references/cache.md +207 -0
- package/skill/references/cli.md +213 -0
- package/skill/references/client.md +507 -0
- package/skill/references/configuration.md +402 -0
- package/skill/references/database.md +134 -0
- package/skill/references/dependency-injection.md +214 -0
- package/skill/references/events.md +152 -0
- package/skill/references/mailer.md +235 -0
- package/skill/references/queue.md +196 -0
- package/skill/references/resources.md +961 -0
- package/skill/references/scheduler.md +184 -0
- package/skill/references/security.md +694 -0
- package/skill/references/storage.md +251 -0
- package/templates/default/.dockerignore +5 -0
- package/templates/default/.env.tpl +1 -0
- package/templates/default/.prettierignore +3 -0
- package/templates/default/.prettierrc +7 -0
- package/templates/default/Dockerfile +56 -0
- package/templates/default/Dockerfile.bun +56 -0
- package/templates/default/README.md.tpl +7 -0
- package/templates/default/appweaver.dev.json.tpl +9 -0
- package/templates/default/appweaver.json.bun.tpl +17 -0
- package/templates/default/appweaver.json.tpl +16 -0
- package/templates/default/appweaver.test.json.tpl +30 -0
- package/templates/default/bunfig.toml.bun +8 -0
- package/templates/default/database/client.ts.tpl +7 -0
- package/templates/default/database/schema.prisma +13 -0
- package/templates/default/database/seeders/001-create-admin-user.ts.tpl +39 -0
- package/templates/default/eslint.config.mjs +55 -0
- package/templates/default/eslint.config.mjs.bun +53 -0
- package/templates/default/jest.config.json.node +23 -0
- package/templates/default/package.json.bun.tpl +39 -0
- package/templates/default/package.json.tpl +44 -0
- package/templates/default/prisma.config.ts.tpl +14 -0
- package/templates/default/public/favicon.ico +0 -0
- package/templates/default/public/robots.txt +2 -0
- package/templates/default/src/features/index.ts.tpl +0 -0
- package/templates/default/src/main.ts.tpl +7 -0
- package/templates/default/src/resources/user/model.ts.tpl +28 -0
- package/templates/default/src/resources/user/policy.ts.tpl +3 -0
- package/templates/default/src/resources/user/routes.ts.tpl +3 -0
- package/templates/default/src/resources/user/service.ts.tpl +16 -0
- package/templates/default/src/types/generated.ts.tpl +1 -0
- package/templates/default/src/types/index.ts.tpl +1 -0
- package/templates/default/start.sh +26 -0
- package/templates/default/start.sh.bun +26 -0
- package/templates/default/swc.config.json.node +13 -0
- package/templates/default/test/e2e/jest.e2e-config.json.node +22 -0
- package/templates/default/test/e2e/main.test.ts.tpl +24 -0
- package/templates/default/test/e2e/support/each.ts.tpl +13 -0
- package/templates/default/test/e2e/support/preload.ts.bun +13 -0
- package/templates/default/test/e2e/support/setup.ts.tpl +13 -0
- package/templates/default/test/e2e/support/teardown.ts.tpl +13 -0
- package/templates/default/test/unit/sample.test.ts.tpl +5 -0
- package/templates/default/tsconfig.build.json +10 -0
- package/templates/default/tsconfig.json +27 -0
- package/templates/default/tsconfig.json.bun +28 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{LOWER_NAME}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "{{DESCRIPTION}}",
|
|
5
|
+
"private": true,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "weaver build",
|
|
9
|
+
"start": "weaver start",
|
|
10
|
+
"dev": "weaver start --watch",
|
|
11
|
+
"generate": "weaver generate",
|
|
12
|
+
"migrate": "weaver migrate",
|
|
13
|
+
"seed": "weaver seed",
|
|
14
|
+
"test": "bun test ./test/unit --coverage ./src/**/*.ts --reporter=junit --reporter-outfile=./reports/junit.xml",
|
|
15
|
+
"e2e": "bun test ./test/e2e --reporter=junit --reporter-outfile=./reports/e2e.xml --preload ./test/e2e/support/preload.ts",
|
|
16
|
+
"format": "prettier --write \"./**/*.ts\"",
|
|
17
|
+
"lint": "eslint \"./**/*.ts\""
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@appweaver/cli": "{{VERSION}}",
|
|
21
|
+
"@appweaver/common": "{{VERSION}}",
|
|
22
|
+
"@appweaver/core": "{{VERSION}}",
|
|
23
|
+
{{DEPENDENCIES}}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@eslint/js": "9.39.2",
|
|
27
|
+
"@types/bun": "1.3.11",
|
|
28
|
+
"@types/node": "25.0.10",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "8.53.1",
|
|
30
|
+
"@typescript-eslint/parser": "8.53.1",
|
|
31
|
+
"eslint": "9.39.2",
|
|
32
|
+
"eslint-config-prettier": "10.1.8",
|
|
33
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
34
|
+
"globals": "17.4.0",
|
|
35
|
+
"prettier": "3.8.1",
|
|
36
|
+
"typescript": "5.9.3",
|
|
37
|
+
"typescript-eslint": "8.53.1"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{LOWER_NAME}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "{{DESCRIPTION}}",
|
|
5
|
+
"private": true,
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "weaver build",
|
|
9
|
+
"start": "weaver start",
|
|
10
|
+
"dev": "weaver start --watch",
|
|
11
|
+
"generate": "weaver generate",
|
|
12
|
+
"migrate": "weaver migrate",
|
|
13
|
+
"seed": "weaver seed --buildProject",
|
|
14
|
+
"test": "jest --forceExit --detectOpenHandles --coverage",
|
|
15
|
+
"e2e": "jest --forceExit --detectOpenHandles --config ./test/e2e/jest.e2e-config.json",
|
|
16
|
+
"format": "prettier --write \"./**/*.ts\"",
|
|
17
|
+
"lint": "eslint \"./**/*.ts\""
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@appweaver/cli": "{{VERSION}}",
|
|
21
|
+
"@appweaver/common": "{{VERSION}}",
|
|
22
|
+
"@appweaver/core": "{{VERSION}}",
|
|
23
|
+
{{DEPENDENCIES}}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@eslint/js": "9.39.2",
|
|
27
|
+
"@swc/core": "1.15.10",
|
|
28
|
+
"@swc/jest": "0.2.39",
|
|
29
|
+
"@types/jest": "30.0.0",
|
|
30
|
+
"@types/node": "25.0.10",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "8.53.1",
|
|
32
|
+
"@typescript-eslint/parser": "8.53.1",
|
|
33
|
+
"eslint": "9.39.2",
|
|
34
|
+
"eslint-config-prettier": "10.1.8",
|
|
35
|
+
"eslint-plugin-jest": "29.12.1",
|
|
36
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
37
|
+
"globals": "17.4.0",
|
|
38
|
+
"jest": "30.2.0",
|
|
39
|
+
"jest-junit": "16.0.0",
|
|
40
|
+
"prettier": "3.8.1",
|
|
41
|
+
"typescript": "5.9.3",
|
|
42
|
+
"typescript-eslint": "8.53.1"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file was generated by Prisma, and assumes you have installed the following:
|
|
2
|
+
// npm install --save-dev prisma
|
|
3
|
+
import { defineConfig } from 'prisma/config';
|
|
4
|
+
import { config } from '@appweaver/common';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
schema: config.DATABASE_SCHEMA_PATH,
|
|
8
|
+
migrations: {
|
|
9
|
+
path: config.DATABASE_MIGRATIONS_DIR_PATH
|
|
10
|
+
},
|
|
11
|
+
datasource: {
|
|
12
|
+
url: config.DATABASE_URL
|
|
13
|
+
}
|
|
14
|
+
});
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createAuthModel } from '@appweaver/core';
|
|
2
|
+
|
|
3
|
+
export default createAuthModel({
|
|
4
|
+
name: 'User',
|
|
5
|
+
scalars: {
|
|
6
|
+
firstName: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
maxLength: 255
|
|
9
|
+
},
|
|
10
|
+
lastName: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
maxLength: 255
|
|
13
|
+
},
|
|
14
|
+
email: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
unique: true,
|
|
17
|
+
format: 'email',
|
|
18
|
+
maxLength: 255
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
files: {
|
|
22
|
+
avatar: {
|
|
23
|
+
mimeType: 'image/*',
|
|
24
|
+
namePattern: 'avatars/{name}-{hash}.{extension}',
|
|
25
|
+
maxSize: '3 MB'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createAuthService } from '@appweaver/core';
|
|
2
|
+
import { UserCreate } from '@/types';
|
|
3
|
+
|
|
4
|
+
export default createAuthService<UserCreate>({
|
|
5
|
+
modelName: 'User',
|
|
6
|
+
registrationData: (_, email, password, data) => {
|
|
7
|
+
return {
|
|
8
|
+
email,
|
|
9
|
+
password: password ?? '',
|
|
10
|
+
firstName: data?.firstName ?? '',
|
|
11
|
+
lastName: data?.lastName ?? '',
|
|
12
|
+
twoFactorAuth: 'None',
|
|
13
|
+
roles: [{ id: 1 }]
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Generated by Appweaver. Please do not edit this file manually.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generated';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
if [ "$1" ]; then
|
|
6
|
+
role="$1"
|
|
7
|
+
else
|
|
8
|
+
role="app"
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
if [ "$role" = "app" ]; then
|
|
12
|
+
echo "Starting application..."
|
|
13
|
+
npm run start
|
|
14
|
+
|
|
15
|
+
elif [ "$role" = "migrations" ]; then
|
|
16
|
+
echo "Executing migrations..."
|
|
17
|
+
npm run migrate
|
|
18
|
+
|
|
19
|
+
elif [ "$role" = "seed" ]; then
|
|
20
|
+
echo "Seeding database..."
|
|
21
|
+
npm run seed
|
|
22
|
+
|
|
23
|
+
else
|
|
24
|
+
echo "Could not match the container role \"$role\""
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
if [ "$1" ]; then
|
|
6
|
+
role="$1"
|
|
7
|
+
else
|
|
8
|
+
role="app"
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
if [ "$role" = "app" ]; then
|
|
12
|
+
echo "Starting application..."
|
|
13
|
+
bun run start
|
|
14
|
+
|
|
15
|
+
elif [ "$role" = "migrations" ]; then
|
|
16
|
+
echo "Executing migrations..."
|
|
17
|
+
bun run migrate
|
|
18
|
+
|
|
19
|
+
elif [ "$role" = "seed" ]; then
|
|
20
|
+
echo "Seeding database..."
|
|
21
|
+
bun run seed
|
|
22
|
+
|
|
23
|
+
else
|
|
24
|
+
echo "Could not match the container role \"$role\""
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
3
|
+
"rootDir": "../../",
|
|
4
|
+
"testEnvironment": "node",
|
|
5
|
+
"testMatch": ["**/test/e2e/?(*.)+(spec|test).ts"],
|
|
6
|
+
"transform": {
|
|
7
|
+
"^.+\\.(t|j)s$": ["@swc/jest"]
|
|
8
|
+
},
|
|
9
|
+
"reporters": [
|
|
10
|
+
"default",
|
|
11
|
+
[
|
|
12
|
+
"jest-junit",
|
|
13
|
+
{
|
|
14
|
+
"outputDirectory": "./reports",
|
|
15
|
+
"outputName": "e2e.xml"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
],
|
|
19
|
+
"setupFilesAfterEnv": ["<rootDir>/test/e2e/support/each.ts"],
|
|
20
|
+
"globalSetup": "<rootDir>/test/e2e/support/setup.ts",
|
|
21
|
+
"globalTeardown": "<rootDir>/test/e2e/support/teardown.ts"
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Application, createApp } from '@appweaver/core';
|
|
2
|
+
|
|
3
|
+
describe('Sample e2e test', () => {
|
|
4
|
+
let app: Application;
|
|
5
|
+
|
|
6
|
+
beforeAll(async () => {
|
|
7
|
+
app = await createApp({ autoStartServer: false });
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
afterAll(async () => {
|
|
11
|
+
await app.stop();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Info endpoint /api', async () => {
|
|
15
|
+
const resp = await app.server.inject({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
url: '/api'
|
|
18
|
+
});
|
|
19
|
+
expect(resp.json()).toEqual({
|
|
20
|
+
name: '{{NAME}}',
|
|
21
|
+
version: '1.0.0'
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import setup from './setup';
|
|
2
|
+
import teardown from './teardown';
|
|
3
|
+
import './each';
|
|
4
|
+
|
|
5
|
+
beforeAll(async () => {
|
|
6
|
+
await setup();
|
|
7
|
+
}, 10_000);
|
|
8
|
+
|
|
9
|
+
afterAll(async () => {
|
|
10
|
+
// Wait for database connection to close before calling teardown
|
|
11
|
+
await Bun.sleep(100);
|
|
12
|
+
await teardown();
|
|
13
|
+
}, 10_000);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
export default async function setup() {
|
|
4
|
+
const { error } = spawnSync('weaver test setup', {
|
|
5
|
+
stdio: 'inherit',
|
|
6
|
+
shell: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
if (error) {
|
|
10
|
+
console.error(error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
export default async function teardown() {
|
|
4
|
+
const { error } = spawnSync('weaver test teardown', {
|
|
5
|
+
stdio: 'inherit',
|
|
6
|
+
shell: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
if (error) {
|
|
10
|
+
console.error(error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"target": "ES2024",
|
|
5
|
+
"baseUrl": "./",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"removeComments": true,
|
|
14
|
+
"emitDecoratorMetadata": true,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"allowSyntheticDefaultImports": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strictNullChecks": true,
|
|
19
|
+
"noImplicitAny": false,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./src/*"],
|
|
23
|
+
"@db/*": ["./database/*"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["node_modules", "dist", "temp"]
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"target": "ES2024",
|
|
5
|
+
"baseUrl": "./",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"removeComments": true,
|
|
14
|
+
"emitDecoratorMetadata": true,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"allowSyntheticDefaultImports": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strictNullChecks": true,
|
|
19
|
+
"noImplicitAny": false,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"types": ["bun"],
|
|
22
|
+
"paths": {
|
|
23
|
+
"@/*": ["./src/*"],
|
|
24
|
+
"@db/*": ["./database/*"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"exclude": ["node_modules", "dist", "temp"]
|
|
28
|
+
}
|