@kevinmarrec/create-app 0.1.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/index.js +144 -0
  4. package/package.json +67 -0
  5. package/template/.github/workflows/ci.yml +39 -0
  6. package/template/.vscode/extensions.json +19 -0
  7. package/template/.vscode/settings.json +68 -0
  8. package/template/.vscode/vue.code-snippets +18 -0
  9. package/template/backend/.env.development +2 -0
  10. package/template/backend/env.d.ts +9 -0
  11. package/template/backend/package.json +23 -0
  12. package/template/backend/src/config/database.ts +11 -0
  13. package/template/backend/src/config/drizzle.ts +10 -0
  14. package/template/backend/src/config/logger.ts +19 -0
  15. package/template/backend/src/config/server.ts +40 -0
  16. package/template/backend/src/database/index.ts +23 -0
  17. package/template/backend/src/database/migrations/0000_white_bishop.sql +6 -0
  18. package/template/backend/src/database/migrations/meta/0000_snapshot.json +56 -0
  19. package/template/backend/src/database/migrations/meta/_journal.json +13 -0
  20. package/template/backend/src/database/schema/index.ts +1 -0
  21. package/template/backend/src/database/schema/users.ts +8 -0
  22. package/template/backend/src/lib/orpc.ts +10 -0
  23. package/template/backend/src/logger.ts +10 -0
  24. package/template/backend/src/router/index.ts +9 -0
  25. package/template/backend/src/router/welcome.ts +11 -0
  26. package/template/backend/src/server.ts +53 -0
  27. package/template/backend/tsconfig.json +6 -0
  28. package/template/compose.yaml +22 -0
  29. package/template/eslint.config.ts +1 -0
  30. package/template/frontend/.env.development +1 -0
  31. package/template/frontend/env.d.ts +9 -0
  32. package/template/frontend/index.html +15 -0
  33. package/template/frontend/package.json +24 -0
  34. package/template/frontend/public/favicon.svg +5 -0
  35. package/template/frontend/public/robots.txt +2 -0
  36. package/template/frontend/src/App.vue +25 -0
  37. package/template/frontend/src/components/.gitkeep +0 -0
  38. package/template/frontend/src/composables/index.ts +2 -0
  39. package/template/frontend/src/lib/orpc.ts +12 -0
  40. package/template/frontend/src/locales/en.yml +3 -0
  41. package/template/frontend/src/locales/fr.yml +3 -0
  42. package/template/frontend/src/main.ts +10 -0
  43. package/template/frontend/src/queries/index.ts +1 -0
  44. package/template/frontend/src/queries/welcome.ts +10 -0
  45. package/template/frontend/src/utils.ts +1 -0
  46. package/template/frontend/tsconfig.json +6 -0
  47. package/template/frontend/uno.config.ts +1 -0
  48. package/template/frontend/vite.config.ts +1 -0
  49. package/template/gitignore +17 -0
  50. package/template/knip.config.ts +23 -0
  51. package/template/package.json +35 -0
  52. package/template/scripts/dev.ts +8 -0
  53. package/template/stylelint.config.ts +1 -0
  54. package/template/taze.config.ts +8 -0
  55. package/template/tsconfig.json +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-present Kevin Marrec <https://github.com/kevinmarrec>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @kevinmarrec/create-app
2
+
3
+ ## Description
4
+
5
+ CLI that scaffolds an opinionated [Bun](https://bun.sh) & [Vue](https://vuejs.org) fullstack application.
6
+
7
+ ## Opinions
8
+
9
+ - [Bun](https://bun.sh) as package manager & runtime
10
+
11
+ - [Vue](https://vuejs.org) as frontend framework
12
+
13
+ ## Usage
14
+
15
+ > Requires [Bun](https://bun.sh) v1.2 _or later_.
16
+
17
+ ```sh
18
+ bun create @kevinmarrec/app
19
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process";
3
+ import { parseArgs } from "node:util";
4
+ import { cancel, confirm, intro, isCancel, log, note, outro, tasks, text } from "@clack/prompts";
5
+ import c from "ansis";
6
+ import { join, resolve } from "pathe";
7
+ import { x } from "tinyexec";
8
+ import fs from "node:fs/promises";
9
+
10
+ //#region package.json
11
+ var version = "0.1.0";
12
+
13
+ //#endregion
14
+ //#region src/utils/fs.ts
15
+ const ignorePredicate = (filename) => [".git"].includes(filename);
16
+ async function empty(dir) {
17
+ const entries = await fs.readdir(dir);
18
+ await Promise.all(entries.filter((entry) => !ignorePredicate(entry)).map((entry) => fs.rm(resolve(dir, entry), { recursive: true })));
19
+ }
20
+ async function emptyCheck(path) {
21
+ return fs.readdir(path).then((files) => files.every(ignorePredicate)).catch(() => true);
22
+ }
23
+ async function exists(path) {
24
+ return fs.access(path).then(() => true).catch(() => false);
25
+ }
26
+ var fs_default = {
27
+ ...fs,
28
+ empty,
29
+ emptyCheck,
30
+ exists
31
+ };
32
+
33
+ //#endregion
34
+ //#region src/scaffold.ts
35
+ async function scaffold(root) {
36
+ await fs_default.exists(root) ? await fs_default.empty(root) : await fs_default.mkdir(root);
37
+ await fs_default.cp(join(import.meta.dirname, "../template"), root, { recursive: true });
38
+ await fs_default.rename(join(root, "gitignore"), join(root, ".gitignore"));
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/run.ts
43
+ function maybeCancel(value, options) {
44
+ if (isCancel(value) || options?.strict && !value) {
45
+ cancel("Operation cancelled");
46
+ process.exit(1);
47
+ }
48
+ }
49
+ async function run() {
50
+ const { values: options, positionals } = parseArgs({
51
+ args: process.argv.slice(2),
52
+ allowPositionals: true,
53
+ options: {
54
+ force: {
55
+ type: "boolean",
56
+ short: "f"
57
+ },
58
+ help: {
59
+ type: "boolean",
60
+ short: "h"
61
+ },
62
+ version: {
63
+ type: "boolean",
64
+ short: "v"
65
+ }
66
+ }
67
+ });
68
+ if (options.help) {
69
+ process.stdout.write(`\
70
+ Usage: create-app [OPTIONS...] [DIRECTORY]
71
+
72
+ Options:
73
+ -f, --force Create the project even if the directory is not empty.
74
+ -h, --help Display this help message.
75
+ --version Display the version number of this CLI.
76
+ `);
77
+ process.exit(0);
78
+ }
79
+ if (options.version) {
80
+ process.stdout.write(`${version}\n`);
81
+ process.exit(0);
82
+ }
83
+ process.stdout.write("\n");
84
+ intro(`create-app ${c.dim(`v${version}`)}`);
85
+ let projectName = positionals[0] || await text({
86
+ message: "Project name",
87
+ placeholder: "my-app",
88
+ validate: (value) => {
89
+ if (!value.trim()) return "Project name cannot be empty";
90
+ }
91
+ });
92
+ maybeCancel(projectName);
93
+ projectName = projectName.trim();
94
+ const cwd = process.cwd();
95
+ const targetDir = resolve(cwd, projectName);
96
+ if (!(await fs_default.emptyCheck(targetDir) || options.force)) {
97
+ await log.warn(`${targetDir === cwd ? "Current directory" : `Target directory ${c.blue(targetDir)}`} is not empty`);
98
+ const shouldOverwrite = await confirm({
99
+ message: "Remove existing files and continue?",
100
+ initialValue: true,
101
+ active: "Yes",
102
+ inactive: "No"
103
+ });
104
+ maybeCancel(shouldOverwrite, { strict: true });
105
+ }
106
+ await tasks([{
107
+ title: `Scaffolding project in ${c.blue(targetDir)}`,
108
+ task: async () => {
109
+ await scaffold(targetDir);
110
+ return `Scaffolded project in ${c.blue(targetDir)}`;
111
+ }
112
+ }]);
113
+ const shouldInstall = await confirm({
114
+ message: "Install dependencies?",
115
+ initialValue: true,
116
+ active: "Yes",
117
+ inactive: "No"
118
+ });
119
+ maybeCancel(shouldInstall);
120
+ await tasks([{
121
+ title: "Installing with bun",
122
+ enabled: shouldInstall,
123
+ task: async () => {
124
+ await x("bun", [
125
+ "install",
126
+ "--cwd",
127
+ targetDir,
128
+ "--force"
129
+ ]);
130
+ return "Installed with bun";
131
+ }
132
+ }]);
133
+ await note([targetDir !== cwd && `cd ${c.reset.blue(projectName)}`, `bun run dev`].filter(Boolean).join("\n"), "Next steps");
134
+ await outro(`Problems? ${c.cyan("https://github.com/kevinmarrec/create-app/issues")}`);
135
+ }
136
+
137
+ //#endregion
138
+ //#region src/index.ts
139
+ run().catch((error) => {
140
+ console.error(error);
141
+ });
142
+
143
+ //#endregion
144
+ export { };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@kevinmarrec/create-app",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "CLI that scaffolds an opinionated Bun & Vue fullstack application.",
6
+ "author": "Kevin Marrec <kevin@marrec.io>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/kevinmarrec/create-app#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/kevinmarrec/create-app.git"
12
+ },
13
+ "keywords": [
14
+ "cli",
15
+ "create-app",
16
+ "template"
17
+ ],
18
+ "workspaces": [
19
+ "template",
20
+ "template/backend",
21
+ "template/frontend"
22
+ ],
23
+ "bin": {
24
+ "create-app": "dist/index.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "template"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsdown",
32
+ "check": "bun run check:unused && bun run check:eslint && bun run check:stylelint && bun run check:types",
33
+ "check:eslint": "eslint . --cache",
34
+ "check:stylelint": "stylelint '**/*.{css,scss,vue}' --ignorePath .gitignore --cache",
35
+ "check:types": "vue-tsc --noEmit",
36
+ "check:unused": "knip -n",
37
+ "lint": "bun run check:eslint && bun run check:stylelint",
38
+ "lint:inspect": "bunx @eslint/config-inspector",
39
+ "playground": "bun --cwd template dev",
40
+ "release": "bumpp",
41
+ "test": "vitest",
42
+ "test:coverage": "vitest run --coverage"
43
+ },
44
+ "dependencies": {
45
+ "@clack/prompts": "^0.11.0",
46
+ "ansis": "^4.1.0",
47
+ "pathe": "^2.0.3",
48
+ "tinyexec": "^1.0.1"
49
+ },
50
+ "devDependencies": {
51
+ "@faker-js/faker": "^10.0.0",
52
+ "@kevinmarrec/eslint-config": "^1.0.0",
53
+ "@kevinmarrec/stylelint-config": "^1.0.0",
54
+ "@kevinmarrec/tsconfig": "^1.0.0",
55
+ "@types/bun": "^1.2.21",
56
+ "@vitest/coverage-v8": "^3.2.4",
57
+ "bumpp": "^10.2.3",
58
+ "eslint": "^9.34.0",
59
+ "knip": "^5.63.0",
60
+ "stylelint": "^16.23.1",
61
+ "taze": "^19.3.0",
62
+ "tsdown": "^0.14.2",
63
+ "typescript": "^5.9.2",
64
+ "vitest": "^3.2.4",
65
+ "vue-tsc": "^3.0.6"
66
+ }
67
+ }
@@ -0,0 +1,39 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ check:
13
+ name: Check
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Bun
20
+ uses: oven-sh/setup-bun@v2
21
+ with:
22
+ bun-version-file: package.json
23
+
24
+ - name: Set up Node.js
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version-file: package.json
28
+
29
+ - name: Install dependencies
30
+ run: bun install --frozen-lockfile
31
+
32
+ - name: Check unused files, dependencies, and exports
33
+ run: bun run check:unused
34
+
35
+ - name: Lint
36
+ run: bun run check:eslint && bun run check:stylelint
37
+
38
+ - name: Type check
39
+ run: bun run check:types
@@ -0,0 +1,19 @@
1
+ {
2
+ "recommendations": [
3
+ "aaron-bond.better-comments",
4
+ "antfu.goto-alias",
5
+ "antfu.iconify",
6
+ "antfu.unocss",
7
+ "dbaeumer.vscode-eslint",
8
+ "eamodio.gitlens",
9
+ "github.copilot",
10
+ "lokalise.i18n-ally",
11
+ "mikestead.dotenv",
12
+ "ms-azuretools.vscode-docker",
13
+ "pkief.material-icon-theme",
14
+ "redhat.vscode-yaml",
15
+ "stylelint.vscode-stylelint",
16
+ "vue.volar",
17
+ "yoavbls.pretty-ts-errors"
18
+ ]
19
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "typescript.tsdk": "node_modules/typescript/lib",
3
+
4
+ // Disable the default formatter
5
+ "prettier.enable": false,
6
+ "editor.formatOnSave": false,
7
+
8
+ // Auto fix
9
+ "editor.codeActionsOnSave": {
10
+ "source.fixAll.eslint": "explicit",
11
+ "source.fixAll.stylelint": "explicit",
12
+ "source.organizeImports": "never"
13
+ },
14
+
15
+ "editor.gotoLocation.multipleDefinitions": "goto",
16
+
17
+ "eslint.runtime": "node",
18
+
19
+ // Silent the stylistic rules in your IDE, but still auto fix them
20
+ "eslint.rules.customizations": [
21
+ { "rule": "style/*", "severity": "off" },
22
+ { "rule": "*-indent", "severity": "off" },
23
+ { "rule": "*-spacing", "severity": "off" },
24
+ { "rule": "*-spaces", "severity": "off" },
25
+ { "rule": "*-order", "severity": "off" },
26
+ { "rule": "*-dangle", "severity": "off" },
27
+ { "rule": "*-newline", "severity": "off" },
28
+ { "rule": "*quotes", "severity": "off" },
29
+ { "rule": "*semi", "severity": "off" }
30
+ ],
31
+
32
+ "eslint.validate": [
33
+ "javascript",
34
+ "typescript",
35
+ "vue",
36
+ "html",
37
+ "css",
38
+ "scss",
39
+ "markdown",
40
+ "json",
41
+ "jsonc",
42
+ "yaml"
43
+ ],
44
+
45
+ "css.validate": false,
46
+ "scss.validate": false,
47
+
48
+ "stylelint.validate": [
49
+ "css",
50
+ "scss",
51
+ "vue"
52
+ ],
53
+
54
+ "javascript.format.semicolons": "remove",
55
+ "javascript.preferences.quoteStyle": "single",
56
+ "typescript.format.semicolons": "remove",
57
+ "typescript.preferences.quoteStyle": "single",
58
+
59
+ "vue.inlayHints.inlineHandlerLeading": true,
60
+ "vue.inlayHints.missingProps": true,
61
+
62
+ // i18n Ally
63
+ "i18n-ally.enabledFrameworks": ["vue"],
64
+ "i18n-ally.keystyle": "nested",
65
+ "i18n-ally.localesPaths": [
66
+ "frontend/src/locales"
67
+ ]
68
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "vue-sfc-init": {
3
+ "scope": "vue",
4
+ "prefix": "init",
5
+ "body": [
6
+ "<script setup lang=\"ts\">",
7
+ "",
8
+ "</script>",
9
+ "",
10
+ "<template>",
11
+ " <div>",
12
+ " ${0:Content}",
13
+ " </div>",
14
+ "</template>",
15
+ ""
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ NODE_ENV=development
2
+ DATABASE_URL=dev.db
@@ -0,0 +1,9 @@
1
+ interface ImportMetaEnv {
2
+ readonly DATABASE_URL: string
3
+ readonly LOG_LEVEL: string
4
+ readonly NODE_ENV: string
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv
9
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "backend",
3
+ "type": "module",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "bun --watch --no-clear-screen src/server.ts",
7
+ "build": "bun build src/server.ts --compile --minify --sourcemap --outfile dist/server",
8
+ "db:generate": "bun --bun run drizzle-kit generate --config src/config/drizzle.ts",
9
+ "db:migrate": "bun --bun run drizzle-kit migrate --config src/config/drizzle.ts"
10
+ },
11
+ "dependencies": {
12
+ "@orpc/server": "^1.8.5",
13
+ "drizzle-orm": "^0.44.5",
14
+ "pino": "^9.9.0",
15
+ "valibot": "^1.1.0"
16
+ },
17
+ "devDependencies": {
18
+ "@libsql/client": "^0.15.14",
19
+ "@types/bun": "^1.2.21",
20
+ "drizzle-kit": "^0.31.4",
21
+ "pino-pretty": "^13.1.1"
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ import * as v from 'valibot'
2
+
3
+ const schema = v.object({
4
+ url: v.string(),
5
+ })
6
+
7
+ const config = v.parse(schema, {
8
+ url: import.meta.env.DATABASE_URL,
9
+ })
10
+
11
+ export const url = config.url
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'drizzle-kit'
2
+
3
+ import { url } from './database'
4
+
5
+ export default defineConfig({
6
+ dialect: 'sqlite',
7
+ dbCredentials: { url },
8
+ schema: './src/database/schema',
9
+ out: './src/database/migrations',
10
+ })
@@ -0,0 +1,19 @@
1
+ import * as v from 'valibot'
2
+
3
+ const schema = v.object({
4
+ level: v.optional(v.union([
5
+ v.literal('trace'),
6
+ v.literal('debug'),
7
+ v.literal('info'),
8
+ v.literal('warn'),
9
+ v.literal('error'),
10
+ v.literal('fatal'),
11
+ v.literal('silent'),
12
+ ]), 'info'),
13
+ })
14
+
15
+ const config = v.parse(schema, {
16
+ level: import.meta.env.LOG_LEVEL,
17
+ })
18
+
19
+ export const level = config.level
@@ -0,0 +1,40 @@
1
+ import * as v from 'valibot'
2
+
3
+ const schema = v.object({
4
+ cors: v.object({
5
+ origin: v.optional(
6
+ v.pipe(
7
+ v.string(),
8
+ v.minLength(1),
9
+ v.transform(value => value.split(',')),
10
+ ),
11
+ '*',
12
+ ),
13
+ }),
14
+ hostname: v.optional(
15
+ v.pipe(
16
+ v.string(),
17
+ v.minLength(1),
18
+ ),
19
+ 'localhost',
20
+ ),
21
+ port: v.optional(v.pipe(
22
+ v.string(),
23
+ v.transform(value => +value),
24
+ v.number(),
25
+ v.minValue(3000),
26
+ v.maxValue(65535),
27
+ ), '4000'),
28
+ })
29
+
30
+ const config = v.parse(schema, {
31
+ cors: {
32
+ origin: import.meta.env.ALLOWED_ORIGINS,
33
+ },
34
+ hostname: import.meta.env.HOST,
35
+ port: import.meta.env.PORT,
36
+ })
37
+
38
+ export const cors = config.cors
39
+ export const hostname = config.hostname
40
+ export const port = config.port
@@ -0,0 +1,23 @@
1
+ import { url } from '@backend/config/database'
2
+ import { logger } from '@backend/logger'
3
+ import { drizzle } from 'drizzle-orm/bun-sqlite'
4
+
5
+ import * as schema from './schema'
6
+
7
+ export const db = drizzle(url, {
8
+ schema,
9
+ logger: {
10
+ logQuery: (query, params) => {
11
+ let msg = `[SQL] ${query}`
12
+ msg += params.length ? ` [${params}]` : ''
13
+ logger.info(msg)
14
+ },
15
+ },
16
+ })
17
+
18
+ db.run('PRAGMA journal_mode = WAL')
19
+ db.run('PRAGMA journal_size_limit = 6144000')
20
+ db.run('PRAGMA synchronous = NORMAL')
21
+ db.run('PRAGMA foreign_keys = ON')
22
+
23
+ export type Database = typeof db
@@ -0,0 +1,6 @@
1
+ CREATE TABLE `users` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `name` text NOT NULL,
4
+ `createdAt` integer NOT NULL,
5
+ `updatedAt` integer NOT NULL
6
+ );
@@ -0,0 +1,56 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "2570ada9-1704-45ba-b294-429e89874a79",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "users": {
8
+ "name": "users",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "integer",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": true
16
+ },
17
+ "name": {
18
+ "name": "name",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "createdAt": {
25
+ "name": "createdAt",
26
+ "type": "integer",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "updatedAt": {
32
+ "name": "updatedAt",
33
+ "type": "integer",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ }
38
+ },
39
+ "indexes": {},
40
+ "foreignKeys": {},
41
+ "compositePrimaryKeys": {},
42
+ "uniqueConstraints": {},
43
+ "checkConstraints": {}
44
+ }
45
+ },
46
+ "views": {},
47
+ "enums": {},
48
+ "_meta": {
49
+ "schemas": {},
50
+ "tables": {},
51
+ "columns": {}
52
+ },
53
+ "internal": {
54
+ "indexes": {}
55
+ }
56
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1751572351628,
9
+ "tag": "0000_white_bishop",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1 @@
1
+ export * from './users'
@@ -0,0 +1,8 @@
1
+ import { sqliteTable } from 'drizzle-orm/sqlite-core'
2
+
3
+ export const users = sqliteTable('users', t => ({
4
+ id: t.integer().primaryKey({ autoIncrement: true }),
5
+ name: t.text().notNull(),
6
+ createdAt: t.integer({ mode: 'timestamp_ms' }).notNull().$defaultFn(() => new Date()),
7
+ updatedAt: t.integer({ mode: 'timestamp_ms' }).notNull().$defaultFn(() => new Date()).$onUpdate(() => new Date()),
8
+ }))
@@ -0,0 +1,10 @@
1
+ import type { Database } from '@backend/database'
2
+ import type { Logger } from '@backend/logger'
3
+ import { os } from '@orpc/server'
4
+
5
+ interface Context {
6
+ db: Database
7
+ logger: Logger
8
+ }
9
+
10
+ export const pub = os.$context<Context>()
@@ -0,0 +1,10 @@
1
+ import pino from 'pino'
2
+
3
+ import { level } from './config/logger'
4
+
5
+ export const logger = pino({
6
+ level,
7
+ base: {},
8
+ })
9
+
10
+ export type Logger = typeof logger
@@ -0,0 +1,9 @@
1
+ import { welcome } from './welcome'
2
+
3
+ export type { RouterClient } from '@orpc/server'
4
+
5
+ export const router = {
6
+ welcome,
7
+ }
8
+
9
+ export type Router = typeof router
@@ -0,0 +1,11 @@
1
+ import { users } from '@backend/database/schema'
2
+ import { pub } from '@backend/lib/orpc'
3
+ import * as v from 'valibot'
4
+
5
+ export const welcome = pub
6
+ .input(v.string())
7
+ .output(v.string())
8
+ .handler(async ({ input, context: { db } }) => {
9
+ const count = await db.$count(users)
10
+ return `Hello ${input} (${count})`
11
+ })
@@ -0,0 +1,53 @@
1
+ import process from 'node:process'
2
+
3
+ import { onError } from '@orpc/server'
4
+ import { RPCHandler } from '@orpc/server/fetch'
5
+ import { CORSPlugin } from '@orpc/server/plugins'
6
+
7
+ import { cors, hostname, port } from './config/server'
8
+ import { db } from './database'
9
+ import { logger } from './logger'
10
+ import { router } from './router'
11
+
12
+ const rpcHandler = new RPCHandler(router, {
13
+ plugins: [new CORSPlugin(cors)],
14
+ interceptors: [
15
+ onError((error) => {
16
+ logger.error(error)
17
+ }),
18
+ ],
19
+ })
20
+
21
+ const server = Bun.serve({
22
+ hostname,
23
+ port,
24
+ async fetch(request) {
25
+ const { matched, response } = await rpcHandler.handle(request, {
26
+ prefix: '/rpc',
27
+ context: {
28
+ db,
29
+ logger,
30
+ },
31
+ })
32
+
33
+ if (matched)
34
+ return response
35
+
36
+ return new Response('Not found', { status: 404 })
37
+ },
38
+ error(error) {
39
+ logger.error(error)
40
+ return new Response('Internal Server Error', { status: 500 })
41
+ },
42
+ })
43
+
44
+ logger.info(`Listening on ${server.url}`)
45
+
46
+ async function gracefulShutdown() {
47
+ logger.info('Gracefully shutting down...')
48
+ await server.stop()
49
+ process.exit(0)
50
+ }
51
+
52
+ process.on('SIGINT', gracefulShutdown)
53
+ process.on('SIGTERM', gracefulShutdown)
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ESNext"]
5
+ }
6
+ }
@@ -0,0 +1,22 @@
1
+ x-common: &common
2
+ working_dir: /app
3
+ volumes:
4
+ - ./:/app
5
+ user: 1000:1000
6
+
7
+ services:
8
+ backend:
9
+ <<: *common
10
+ image: oven/bun:1-alpine
11
+ command: [bun, --cwd, backend, dev]
12
+ ports:
13
+ - 4000:4000
14
+
15
+ frontend:
16
+ <<: *common
17
+ depends_on:
18
+ - backend
19
+ image: imbios/bun-node:22-alpine
20
+ command: [bun, --cwd, frontend, dev, --host, 0.0.0.0]
21
+ ports:
22
+ - 5173:5173
@@ -0,0 +1 @@
1
+ export { default } from '@kevinmarrec/eslint-config'
@@ -0,0 +1 @@
1
+ VITE_API_URL=http://localhost:4000/rpc
@@ -0,0 +1,9 @@
1
+ /// <reference types="@kevinmarrec/cloudstack-vite-config/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_API_URL: string
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv
9
+ }
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="description" content="Description" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
8
+ <title>Title</title>
9
+ </head>
10
+ <body class="font-sans">
11
+ <div id="app"></div>
12
+ <script type="module" src="/src/main.ts"></script>
13
+ <noscript>Please enable JavaScript to use this application.</noscript>
14
+ </body>
15
+ </html>
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "frontend",
3
+ "type": "module",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build --mode static",
8
+ "build:analyze": "vite build --mode analyze",
9
+ "preview": "vite preview --open"
10
+ },
11
+ "dependencies": {
12
+ "@orpc/client": "^1.8.5",
13
+ "@orpc/tanstack-query": "1.6.4",
14
+ "@tanstack/vue-query": "^5.85.5",
15
+ "unocss": "^66.4.2",
16
+ "vue": "^3.5.20"
17
+ },
18
+ "devDependencies": {
19
+ "@kevinmarrec/cloudstack-vite-config": "^1.0.0-rc.15",
20
+ "@kevinmarrec/cloudstack-vue": "^1.0.0-rc.15",
21
+ "@kevinmarrec/unocss-config": "^1.0.0",
22
+ "vite": "^7.1.3"
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ <svg width="800" height="800" viewBox="0 -17.5 256 256" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
2
+ <path d="M204.8 0H256L128 220.8 0 0h97.92L128 51.2 157.44 0z" fill="#41B883"/>
3
+ <path d="m0 0 128 220.8L256 0h-51.2L128 132.48 50.56 0z" fill="#41B883"/>
4
+ <path d="M50.56 0 128 133.12 204.8 0h-47.36L128 51.2 97.92 0z" fill="#35495E"/>
5
+ </svg>
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Disallow:
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ import { useHead, useI18n } from '@frontend/composables'
3
+ import { useWelcome } from '@frontend/queries'
4
+
5
+ const { t } = useI18n()
6
+
7
+ useHead({
8
+ title: () => t('title'),
9
+ })
10
+
11
+ const { data: message } = useWelcome('world')
12
+ </script>
13
+
14
+ <template>
15
+ <div class="grid h-full place-items-center">
16
+ <div class="flex flex-col gap-4 items-center">
17
+ <h1 class="text-4xl font-bold">
18
+ {{ t('body.message') }}
19
+ </h1>
20
+ <h2 class="text-2xl text-gray-500">
21
+ {{ message }}
22
+ </h2>
23
+ </div>
24
+ </div>
25
+ </template>
File without changes
@@ -0,0 +1,2 @@
1
+ export { useHead } from '@kevinmarrec/cloudstack-vue/head'
2
+ export { useI18n } from '@kevinmarrec/cloudstack-vue/i18n'
@@ -0,0 +1,12 @@
1
+ import type { Router, RouterClient } from '@backend/router'
2
+ import { createORPCClient } from '@orpc/client'
3
+ import { RPCLink } from '@orpc/client/fetch'
4
+ import { createTanstackQueryUtils } from '@orpc/tanstack-query'
5
+
6
+ const link = new RPCLink({
7
+ url: import.meta.env.VITE_API_URL,
8
+ })
9
+
10
+ const client: RouterClient<Router> = createORPCClient(link)
11
+
12
+ export const orpc = createTanstackQueryUtils(client)
@@ -0,0 +1,3 @@
1
+ title: Welcome !
2
+ body:
3
+ message: Template
@@ -0,0 +1,3 @@
1
+ title: Bienvenue !
2
+ body:
3
+ message: Template (French)
@@ -0,0 +1,10 @@
1
+ import { VueQueryPlugin } from '@tanstack/vue-query'
2
+ import { Cloudstack } from 'virtual:cloudstack'
3
+
4
+ import App from './App.vue'
5
+
6
+ export const createApp = Cloudstack(App, ({ app }) => {
7
+ app.use(VueQueryPlugin, {
8
+ enableDevtoolsV6Plugin: true,
9
+ })
10
+ })
@@ -0,0 +1 @@
1
+ export * from './welcome'
@@ -0,0 +1,10 @@
1
+ import { orpc } from '@frontend/lib/orpc'
2
+ import { get } from '@frontend/utils'
3
+ import { useQuery } from '@tanstack/vue-query'
4
+ import { computed, type MaybeRef } from 'vue'
5
+
6
+ export function useWelcome(text: MaybeRef<string>) {
7
+ return useQuery(computed(() => orpc.welcome.queryOptions({
8
+ input: get(text),
9
+ })))
10
+ }
@@ -0,0 +1 @@
1
+ export { get } from '@kevinmarrec/cloudstack-vue'
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ESNext", "DOM", "DOM.Iterable"]
5
+ }
6
+ }
@@ -0,0 +1 @@
1
+ export { default } from '@kevinmarrec/unocss-config'
@@ -0,0 +1 @@
1
+ export { default } from '@kevinmarrec/cloudstack-vite-config'
@@ -0,0 +1,17 @@
1
+ *.db*
2
+ *.local
3
+ *.log
4
+ *.sqlite
5
+ .cache
6
+ .DS_Store
7
+ .env.prod*
8
+ .eslintcache
9
+ .idea
10
+ .stylelintcache
11
+ .temp
12
+ .vite*
13
+ coverage
14
+ dev-dist
15
+ dist
16
+ node_modules
17
+ tmp
@@ -0,0 +1,23 @@
1
+ import type { KnipConfig } from 'knip'
2
+
3
+ Object.assign(import.meta.env, {
4
+ DATABASE_URL: 'foo.db',
5
+ })
6
+
7
+ export default {
8
+ stylelint: false,
9
+ workspaces: {
10
+ '.': {
11
+ entry: ['*.config.ts'],
12
+ },
13
+ 'backend': {
14
+ drizzle: {
15
+ config: ['src/config/drizzle.ts'],
16
+ },
17
+ ignoreDependencies: ['pino-pretty'],
18
+ },
19
+ 'frontend': {
20
+ entry: ['src/main.ts'],
21
+ },
22
+ },
23
+ } satisfies KnipConfig
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "app",
3
+ "type": "module",
4
+ "private": true,
5
+ "packageManager": "bun@1.2.21",
6
+ "engines": {
7
+ "node": "lts/*"
8
+ },
9
+ "workspaces": [
10
+ "backend",
11
+ "frontend"
12
+ ],
13
+ "scripts": {
14
+ "check": "bun run check:unused && bun run check:eslint && bun run check:stylelint && bun run check:types",
15
+ "check:eslint": "eslint . --cache",
16
+ "check:stylelint": "stylelint '**/*.{css,scss,vue}' --ignorePath .gitignore --cache",
17
+ "check:types": "vue-tsc --noEmit",
18
+ "check:unused": "knip -n",
19
+ "dev": "bun scripts/dev.ts",
20
+ "lint": "bun run check:eslint && bun run check:stylelint",
21
+ "lint:inspect": "bunx @eslint/config-inspector"
22
+ },
23
+ "devDependencies": {
24
+ "@kevinmarrec/eslint-config": "^1.0.0",
25
+ "@kevinmarrec/stylelint-config": "^1.0.0",
26
+ "@kevinmarrec/tsconfig": "^1.0.0",
27
+ "concurrently": "^9.2.1",
28
+ "eslint": "^9.34.0",
29
+ "knip": "^5.63.0",
30
+ "stylelint": "^16.23.1",
31
+ "taze": "^19.3.0",
32
+ "typescript": "~5.9.2",
33
+ "vue-tsc": "^3.0.6"
34
+ }
35
+ }
@@ -0,0 +1,8 @@
1
+ import concurrently, { type ConcurrentlyCommandInput } from 'concurrently'
2
+
3
+ const commandInputs: ConcurrentlyCommandInput[] = [
4
+ { name: 'backend', command: `bun --cwd backend dev | pino-pretty`, prefixColor: 'blue' },
5
+ { name: 'frontend', command: `bun --cwd frontend dev`, prefixColor: 'green' },
6
+ ]
7
+
8
+ concurrently(commandInputs)
@@ -0,0 +1 @@
1
+ export { default } from '@kevinmarrec/stylelint-config'
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'taze'
2
+
3
+ export default defineConfig({
4
+ install: true,
5
+ interactive: true,
6
+ recursive: true,
7
+ write: true,
8
+ })
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@kevinmarrec/tsconfig",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@backend/*": ["./backend/src/*"],
6
+ "@frontend/*": ["./frontend/src/*"]
7
+ }
8
+ },
9
+ "exclude": ["**/dist/**"]
10
+ }