@newt-app/templates 0.6.0 → 0.7.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/dist/index.d.ts CHANGED
@@ -42,9 +42,11 @@ declare const templates: {
42
42
  typescriptConfig: Module;
43
43
  testingJest: Module;
44
44
  testingVitest: Module;
45
+ deploymentStandalone: Module;
45
46
  deploymentCustomServer: Module;
46
47
  deploymentSpa: Module;
47
48
  deploymentVercel: Module;
49
+ nestDiOnly: Module;
48
50
  };
49
51
 
50
52
  export { type File, type Module, type Package, type Script, type Template, type TemplateData, getStaticFilePath, staticDir, staticDirPath, templates };
package/dist/index.js CHANGED
@@ -1229,20 +1229,24 @@ var package_json_default4 = {
1229
1229
  "version": "0.0.0",
1230
1230
  "private": true,
1231
1231
  "exports": {
1232
- ".": "./src/index.ts"
1232
+ ".": {
1233
+ "default": "./dist/index.js",
1234
+ "types": "./dist/index.d.ts"
1235
+ }
1233
1236
  },
1234
1237
  "scripts": {
1238
+ "build": "tsc",
1235
1239
  "migrate": "dotenv -e .env -- auth migrate --config src/index.ts",
1236
1240
  "generate": "dotenv -e .env -- auth generate --config src/index.ts"
1237
1241
  },
1238
1242
  "dependencies": {
1243
+ "auth": "^1.5.5",
1239
1244
  "better-auth": "^1.2.8",
1240
1245
  "pg": "^8.14.1"
1241
1246
  },
1242
1247
  "devDependencies": {
1243
1248
  "@<%= projectName %>/typescript-config": "workspace:*",
1244
1249
  "@types/pg": "^8.11.13",
1245
- "auth": "^1.5.5",
1246
1250
  "dotenv-cli": "^11.0.0",
1247
1251
  "typescript": "6.0.2"
1248
1252
  }
@@ -1270,10 +1274,18 @@ export type Auth = typeof auth;`
1270
1274
  var tsconfig_default3 = {
1271
1275
  filename: "packages/auth/tsconfig.json",
1272
1276
  template: `{
1273
- "extends": "@<%= projectName %>/typescript-config/base.json",
1274
1277
  "compilerOptions": {
1278
+ "declaration": true,
1279
+ "declarationMap": true,
1280
+ "esModuleInterop": true,
1281
+ "lib": ["es2022"],
1282
+ "module": "NodeNext",
1283
+ "moduleResolution": "NodeNext",
1275
1284
  "outDir": "dist",
1276
- "strictNullChecks": true
1285
+ "rootDir": "src",
1286
+ "skipLibCheck": true,
1287
+ "strict": true,
1288
+ "target": "ES2022"
1277
1289
  },
1278
1290
  "include": ["src"],
1279
1291
  "exclude": ["node_modules", "dist"]
@@ -8458,6 +8470,182 @@ var testingVitest = {
8458
8470
  };
8459
8471
  var testing_vitest_default = testingVitest;
8460
8472
 
8473
+ // src/deployment-standalone/templates/dockerfile.ts
8474
+ var dockerfile_default = {
8475
+ filename: "Dockerfile",
8476
+ template: `FROM node:22-alpine AS base
8477
+ ENV PNPM_HOME="/pnpm"
8478
+ ENV PATH="$PNPM_HOME:$PATH"
8479
+ RUN corepack enable
8480
+
8481
+ FROM base AS build
8482
+ WORKDIR /app
8483
+ COPY . .
8484
+ RUN pnpm install --frozen-lockfile
8485
+ ARG API_HOST=localhost
8486
+ ENV API_HOST=$API_HOST
8487
+ RUN pnpm build --filter=web --filter=api --filter=@<%= projectName %>/auth
8488
+ RUN pnpm deploy --filter=api --prod /deploy/api
8489
+ RUN pnpm deploy --filter=@<%= projectName %>/auth --prod /deploy/auth
8490
+
8491
+ # --- web ---
8492
+ FROM base AS web
8493
+ WORKDIR /app
8494
+ ENV NODE_ENV=production
8495
+ COPY --from=build /app/apps/web/.next/standalone ./
8496
+ COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static
8497
+ COPY --from=build /app/apps/web/public ./apps/web/public
8498
+ EXPOSE 3000
8499
+ CMD ["node", "apps/web/server.js"]
8500
+
8501
+ # --- api ---
8502
+ FROM base AS api
8503
+ ENV NODE_ENV=production
8504
+ COPY --from=build /deploy/api /app
8505
+ WORKDIR /app
8506
+ EXPOSE 3001
8507
+ CMD ["node", "dist/main"]
8508
+
8509
+ # --- migrate ---
8510
+ FROM base AS migrate
8511
+ COPY --from=build /deploy/auth /app
8512
+ WORKDIR /app
8513
+ CMD ["/app/node_modules/.bin/auth", "migrate", "--config", "src/index.ts", "-y"]`
8514
+ };
8515
+
8516
+ // src/deployment-standalone/templates/docker-compose.ts
8517
+ var docker_compose_default = {
8518
+ filename: "docker-compose.yml",
8519
+ template: `x-app-env: &app-env
8520
+ BETTER_AUTH_SECRET: \${BETTER_AUTH_SECRET}
8521
+ DATABASE_URL: postgresql://postgres:\${POSTGRES_PASSWORD:-postgres}@db:5432/postgres
8522
+
8523
+ services:
8524
+ web:
8525
+ build:
8526
+ context: .
8527
+ target: web
8528
+ args:
8529
+ - API_HOST=api
8530
+ ports:
8531
+ - "3000:3000"
8532
+ environment:
8533
+ <<: *app-env
8534
+ depends_on:
8535
+ - api
8536
+
8537
+ migrate:
8538
+ build:
8539
+ context: .
8540
+ target: migrate
8541
+ command: ["/app/node_modules/.bin/auth", "migrate", "--config", "src/index.ts", "-y"]
8542
+ environment:
8543
+ <<: *app-env
8544
+ depends_on:
8545
+ db:
8546
+ condition: service_healthy
8547
+ restart: "no"
8548
+
8549
+ api:
8550
+ build:
8551
+ context: .
8552
+ target: api
8553
+ ports:
8554
+ - "3001:3001"
8555
+ environment:
8556
+ <<: *app-env
8557
+ depends_on:
8558
+ db:
8559
+ condition: service_healthy
8560
+ migrate:
8561
+ condition: service_completed_successfully
8562
+
8563
+ db:
8564
+ image: postgres:17-alpine
8565
+ ports:
8566
+ - "5432:5432"
8567
+ environment:
8568
+ - POSTGRES_PASSWORD=\${POSTGRES_PASSWORD:-postgres}
8569
+ volumes:
8570
+ - db_data:/var/lib/postgresql/data
8571
+ healthcheck:
8572
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
8573
+ interval: 5s
8574
+ timeout: 5s
8575
+ retries: 5
8576
+
8577
+ volumes:
8578
+ db_data:`
8579
+ };
8580
+
8581
+ // src/deployment-standalone/templates/next-config.ts
8582
+ var next_config_default2 = {
8583
+ filename: "apps/web/next.config.js",
8584
+ template: `import dotenv from 'dotenv';
8585
+ import { resolve } from 'path';
8586
+
8587
+ // Load root .env first, then local .env (local takes precedence)
8588
+ dotenv.config({ path: resolve(process.cwd(), '../../.env') });
8589
+ dotenv.config({ path: resolve(process.cwd(), '.env') });
8590
+
8591
+ /** @type {import('next').NextConfig} */
8592
+ const nextConfig = {
8593
+ output: "standalone",
8594
+ async rewrites() {
8595
+ return [
8596
+ {
8597
+ source: '/api/:path*',
8598
+ destination: \`http://\${process.env.API_HOST ?? 'localhost'}:3001/api/:path*\`,
8599
+ },
8600
+ ];
8601
+ },
8602
+ };
8603
+
8604
+ export default nextConfig;`
8605
+ };
8606
+
8607
+ // src/deployment-standalone/templates/turbo-json.ts
8608
+ var turbo_json_default2 = {
8609
+ filename: "turbo.json",
8610
+ template: `{
8611
+ "$schema": "https://turborepo.dev/schema.json",
8612
+ "ui": "tui",
8613
+ "tasks": {
8614
+ "build": {
8615
+ "dependsOn": ["^build"],
8616
+ "inputs": ["$TURBO_DEFAULT$", ".env*"],
8617
+ "env": ["API_HOST"],
8618
+ "outputs": [".next/**", "!.next/cache/**"]
8619
+ },
8620
+ "lint": {
8621
+ "dependsOn": ["^lint"],
8622
+ "env": ["NODE_ENV"]
8623
+ },
8624
+ "test": {
8625
+ "dependsOn": ["^build"],
8626
+ "outputs": ["coverage/**"]
8627
+ },
8628
+ "dev": {
8629
+ "cache": false,
8630
+ "persistent": true
8631
+ },
8632
+ "migrate": {
8633
+ "cache": false,
8634
+ "interactive": true
8635
+ },
8636
+ "generate": {
8637
+ "cache": false
8638
+ }
8639
+ }
8640
+ }`
8641
+ };
8642
+
8643
+ // src/deployment-standalone/index.ts
8644
+ var deploymentStandalone = {
8645
+ templates: [dockerfile_default, docker_compose_default, next_config_default2, turbo_json_default2]
8646
+ };
8647
+ var deployment_standalone_default = deploymentStandalone;
8648
+
8461
8649
  // src/single-process-custom-server/templates/api-package-json.ts
8462
8650
  var api_package_json_default = {
8463
8651
  filename: "apps/api/package.json",
@@ -8944,6 +9132,290 @@ var singleProcessPages = {
8944
9132
  };
8945
9133
  var single_process_pages_default = singleProcessPages;
8946
9134
 
9135
+ // src/nest-di-only/templates/api-package-json.ts
9136
+ var api_package_json_default4 = {
9137
+ filename: "packages/api/package.json",
9138
+ template: `{
9139
+ "name": "@<%= projectName %>/api",
9140
+ "version": "0.0.1",
9141
+ "private": true,
9142
+ "exports": {
9143
+ ".": {
9144
+ "default": "./dist/index.js",
9145
+ "types": "./dist/index.d.ts"
9146
+ }
9147
+ },
9148
+ "scripts": {
9149
+ "build": "tsc",
9150
+ "dev": "tsc --watch"
9151
+ },
9152
+ "dependencies": {
9153
+ "@<%= projectName %>/auth": "workspace:*",
9154
+ "@nestjs/common": "^11.0.1",
9155
+ "@nestjs/core": "^11.0.1",
9156
+ "reflect-metadata": "^0.2.2",
9157
+ "rxjs": "^7.8.1"
9158
+ },
9159
+ "devDependencies": {
9160
+ "@<%= projectName %>/typescript-config": "workspace:*",
9161
+ "@types/node": "^22.15.3",
9162
+ "typescript": "6.0.2"
9163
+ }
9164
+ }`
9165
+ };
9166
+
9167
+ // src/nest-di-only/templates/api-tsconfig.ts
9168
+ var api_tsconfig_default = {
9169
+ filename: "packages/api/tsconfig.json",
9170
+ template: `{
9171
+ "compilerOptions": {
9172
+ "declaration": true,
9173
+ "declarationMap": true,
9174
+ "emitDecoratorMetadata": true,
9175
+ "experimentalDecorators": true,
9176
+ "module": "CommonJS",
9177
+ "outDir": "dist",
9178
+ "rootDir": "src",
9179
+ "skipLibCheck": true,
9180
+ "strict": true,
9181
+ "target": "ES2021"
9182
+ },
9183
+ "include": ["src"],
9184
+ "exclude": ["node_modules", "dist"]
9185
+ }`
9186
+ };
9187
+
9188
+ // src/nest-di-only/templates/api-index.ts
9189
+ var api_index_default = {
9190
+ filename: "packages/api/src/index.ts",
9191
+ template: `export { AppModule } from './app.module';
9192
+ export { TodosService } from './todos/todos.service';
9193
+ export type { Todo } from './todos/todos.service';`
9194
+ };
9195
+
9196
+ // src/nest-di-only/templates/api-app-module.ts
9197
+ var api_app_module_default2 = {
9198
+ filename: "packages/api/src/app.module.ts",
9199
+ template: `import { Module } from '@nestjs/common';
9200
+ import { TodosModule } from './todos/todos.module';
9201
+
9202
+ @Module({
9203
+ imports: [TodosModule],
9204
+ })
9205
+ export class AppModule {}`
9206
+ };
9207
+
9208
+ // src/nest-di-only/templates/api-todos-service.ts
9209
+ var api_todos_service_default = {
9210
+ filename: "packages/api/src/todos/todos.service.ts",
9211
+ template: `import { Injectable, NotFoundException } from '@nestjs/common';
9212
+
9213
+ export interface Todo {
9214
+ id: number;
9215
+ title: string;
9216
+ done: boolean;
9217
+ }
9218
+
9219
+ @Injectable()
9220
+ export class TodosService {
9221
+ private todos: Todo[] = [];
9222
+ private nextId = 1;
9223
+
9224
+ findAll(): Todo[] {
9225
+ return this.todos;
9226
+ }
9227
+
9228
+ create(title: string): Todo {
9229
+ const todo: Todo = { id: this.nextId++, title, done: false };
9230
+ this.todos.push(todo);
9231
+ return todo;
9232
+ }
9233
+
9234
+ toggle(id: number): Todo {
9235
+ const todo = this.todos.find((t) => t.id === id);
9236
+ if (!todo) throw new NotFoundException(\`Todo \${id} not found\`);
9237
+ todo.done = !todo.done;
9238
+ return todo;
9239
+ }
9240
+
9241
+ remove(id: number): void {
9242
+ const index = this.todos.findIndex((t) => t.id === id);
9243
+ if (index === -1) throw new NotFoundException(\`Todo \${id} not found\`);
9244
+ this.todos.splice(index, 1);
9245
+ }
9246
+ }`
9247
+ };
9248
+
9249
+ // src/nest-di-only/templates/api-todos-module.ts
9250
+ var api_todos_module_default = {
9251
+ filename: "packages/api/src/todos/todos.module.ts",
9252
+ template: `import { Module } from '@nestjs/common';
9253
+ import { TodosService } from './todos.service';
9254
+
9255
+ @Module({
9256
+ providers: [TodosService],
9257
+ exports: [TodosService],
9258
+ })
9259
+ export class TodosModule {}`
9260
+ };
9261
+
9262
+ // src/nest-di-only/templates/web-nest-context.ts
9263
+ var web_nest_context_default = {
9264
+ filename: "apps/web/lib/nest.ts",
9265
+ template: `import 'reflect-metadata';
9266
+ import { NestFactory } from '@nestjs/core';
9267
+ import { AppModule } from '@<%= projectName %>/api';
9268
+ import type { INestApplicationContext } from '@nestjs/common';
9269
+
9270
+ let context: INestApplicationContext | null = null;
9271
+
9272
+ export async function getNestApp(): Promise<INestApplicationContext> {
9273
+ if (!context) {
9274
+ context = await NestFactory.createApplicationContext(AppModule, {
9275
+ logger: false,
9276
+ });
9277
+ }
9278
+ return context;
9279
+ }`
9280
+ };
9281
+
9282
+ // src/nest-di-only/templates/web-todos-route.ts
9283
+ var web_todos_route_default = {
9284
+ filename: "apps/web/app/api/todos/route.ts",
9285
+ template: `import { NextResponse } from 'next/server';
9286
+ import { getNestApp } from '@/lib/nest';
9287
+ import { TodosService } from '@<%= projectName %>/api';
9288
+
9289
+ export async function GET() {
9290
+ const app = await getNestApp();
9291
+ const todos = app.get(TodosService);
9292
+ return NextResponse.json(todos.findAll());
9293
+ }
9294
+
9295
+ export async function POST(req: Request) {
9296
+ const { title } = await req.json();
9297
+ const app = await getNestApp();
9298
+ const todos = app.get(TodosService);
9299
+ return NextResponse.json(todos.create(title), { status: 201 });
9300
+ }`
9301
+ };
9302
+
9303
+ // src/nest-di-only/templates/web-todos-id-route.ts
9304
+ var web_todos_id_route_default = {
9305
+ filename: "apps/web/app/api/todos/[id]/route.ts",
9306
+ template: `import { NextResponse } from 'next/server';
9307
+ import { getNestApp } from '@/lib/nest';
9308
+ import { TodosService } from '@<%= projectName %>/api';
9309
+
9310
+ export async function DELETE(_req: Request, { params }: { params: Promise<{ id: string }> }) {
9311
+ const { id } = await params;
9312
+ const app = await getNestApp();
9313
+ const todos = app.get(TodosService);
9314
+ todos.remove(Number(id));
9315
+ return new NextResponse(null, { status: 204 });
9316
+ }`
9317
+ };
9318
+
9319
+ // src/nest-di-only/templates/web-todos-toggle-route.ts
9320
+ var web_todos_toggle_route_default = {
9321
+ filename: "apps/web/app/api/todos/[id]/toggle/route.ts",
9322
+ template: `import { NextResponse } from 'next/server';
9323
+ import { getNestApp } from '@/lib/nest';
9324
+ import { TodosService } from '@<%= projectName %>/api';
9325
+
9326
+ export async function PATCH(_req: Request, { params }: { params: Promise<{ id: string }> }) {
9327
+ const { id } = await params;
9328
+ const app = await getNestApp();
9329
+ const todos = app.get(TodosService);
9330
+ return NextResponse.json(todos.toggle(Number(id)));
9331
+ }`
9332
+ };
9333
+
9334
+ // src/nest-di-only/templates/web-package-json.ts
9335
+ var web_package_json_default3 = {
9336
+ filename: "apps/web/package.json",
9337
+ template: `{
9338
+ "name": "web",
9339
+ "version": "0.1.0",
9340
+ "type": "module",
9341
+ "private": true,
9342
+ "scripts": {
9343
+ "dev": "next dev --port 3000",
9344
+ "build": "next build",
9345
+ "start": "next start",
9346
+ "lint": "eslint --max-warnings 0 && next typegen && tsc --noEmit",
9347
+ "db:migrate": "better-auth migrate"
9348
+ },
9349
+ "dependencies": {
9350
+ "@<%= projectName %>/api": "workspace:*",
9351
+ "@<%= projectName %>/auth": "workspace:*",
9352
+ "@<%= projectName %>/ui": "workspace:*",
9353
+ "@nestjs/common": "^11.0.1",
9354
+ "@nestjs/core": "^11.0.1",
9355
+ "reflect-metadata": "^0.2.2",
9356
+ "@tailwindcss/postcss": "^4.2.1",
9357
+ "dotenv": "^17.3.1",
9358
+ "@tanstack/react-form": "^1.28.5",
9359
+ "@tanstack/react-query": "^5.90.21",
9360
+ "better-auth": "^1.2.8",
9361
+ "next": "16.2.1",
9362
+ "react": "^19.2.4",
9363
+ "react-dom": "^19.2.4",
9364
+ "tailwindcss": "^4.2.1"
9365
+ },
9366
+ "devDependencies": {
9367
+ "@<%= projectName %>/eslint-config": "workspace:*",
9368
+ "@<%= projectName %>/typescript-config": "workspace:*",
9369
+ "@types/node": "^22.15.3",
9370
+ "@types/react": "19.2.14",
9371
+ "@types/react-dom": "19.2.3",
9372
+ "eslint": "^9.39.1",
9373
+ "typescript": "6.0.2"
9374
+ }
9375
+ }`
9376
+ };
9377
+
9378
+ // src/nest-di-only/templates/web-next-config.ts
9379
+ var web_next_config_default4 = {
9380
+ filename: "apps/web/next.config.js",
9381
+ template: `import dotenv from 'dotenv';
9382
+ import { resolve } from 'path';
9383
+
9384
+ dotenv.config({ path: resolve(process.cwd(), '../../.env') });
9385
+ dotenv.config({ path: resolve(process.cwd(), '.env') });
9386
+
9387
+ /** @type {import('next').NextConfig} */
9388
+ const nextConfig = {
9389
+ serverExternalPackages: [
9390
+ '@<%= projectName %>/api',
9391
+ '@nestjs/core',
9392
+ '@nestjs/common',
9393
+ 'reflect-metadata',
9394
+ ],
9395
+ };
9396
+
9397
+ export default nextConfig;`
9398
+ };
9399
+
9400
+ // src/nest-di-only/index.ts
9401
+ var nestDiOnly = {
9402
+ templates: [
9403
+ api_package_json_default4,
9404
+ api_tsconfig_default,
9405
+ api_index_default,
9406
+ api_app_module_default2,
9407
+ api_todos_service_default,
9408
+ api_todos_module_default,
9409
+ web_nest_context_default,
9410
+ web_todos_route_default,
9411
+ web_todos_id_route_default,
9412
+ web_todos_toggle_route_default,
9413
+ web_package_json_default3,
9414
+ web_next_config_default4
9415
+ ]
9416
+ };
9417
+ var nest_di_only_default = nestDiOnly;
9418
+
8947
9419
  // src/index.ts
8948
9420
  var staticDir = new URL("./static/", import.meta.url);
8949
9421
  var staticDirPath = fileURLToPath(staticDir);
@@ -8961,9 +9433,11 @@ var templates = {
8961
9433
  typescriptConfig: typescript_config_default,
8962
9434
  testingJest: testing_jest_default,
8963
9435
  testingVitest: testing_vitest_default,
9436
+ deploymentStandalone: deployment_standalone_default,
8964
9437
  deploymentCustomServer: single_process_custom_server_default,
8965
9438
  deploymentSpa: single_process_static_export_default,
8966
- deploymentVercel: single_process_pages_default
9439
+ deploymentVercel: single_process_pages_default,
9440
+ nestDiOnly: nest_di_only_default
8967
9441
  };
8968
9442
  export {
8969
9443
  getStaticFilePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newt-app/templates",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "description": "Templates for newt-app",
6
6
  "type": "module",