@newt-app/templates 0.8.3 → 0.11.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 +1 -0
- package/dist/index.js +163 -151
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ declare const templates: {
|
|
|
47
47
|
deploymentSpa: Module;
|
|
48
48
|
deploymentVercel: Module;
|
|
49
49
|
nestDiOnly: Module;
|
|
50
|
+
apiControllers: Module;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
export { type File, type Module, type Package, type Script, type Template, type TemplateData, getStaticFilePath, staticDir, staticDirPath, templates };
|
package/dist/index.js
CHANGED
|
@@ -1042,123 +1042,27 @@ var tsconfig_build_default = {
|
|
|
1042
1042
|
}`
|
|
1043
1043
|
};
|
|
1044
1044
|
|
|
1045
|
-
// src/api/templates/app-controller.ts
|
|
1046
|
-
var app_controller_default = {
|
|
1047
|
-
filename: "apps/api/src/app.controller.ts",
|
|
1048
|
-
template: `import { Controller, Get } from '@nestjs/common';
|
|
1049
|
-
import {
|
|
1050
|
-
AllowAnonymous,
|
|
1051
|
-
Session,
|
|
1052
|
-
UserSession,
|
|
1053
|
-
} from '@thallesp/nestjs-better-auth';
|
|
1054
|
-
|
|
1055
|
-
@Controller()
|
|
1056
|
-
export class AppController {
|
|
1057
|
-
@AllowAnonymous()
|
|
1058
|
-
@Get('hello')
|
|
1059
|
-
getHello(@Session() session: UserSession | null) {
|
|
1060
|
-
if (session?.user.name) {
|
|
1061
|
-
return { message: \`Hello \${session.user.name}\` };
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
return { message: 'Hello from Nest' };
|
|
1065
|
-
}
|
|
1066
|
-
}`
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
1045
|
// src/api/templates/app-module.ts
|
|
1070
1046
|
var app_module_default = {
|
|
1071
1047
|
filename: "apps/api/src/app.module.ts",
|
|
1072
1048
|
template: `import { Module } from '@nestjs/common';
|
|
1073
|
-
import { APP_GUARD } from '@nestjs/core';
|
|
1074
|
-
import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
|
|
1075
|
-
import { auth } from '@<%= projectName %>/auth';
|
|
1076
|
-
import { AppController } from './app.controller';
|
|
1077
1049
|
import { TodosModule } from './todos/todos.module';
|
|
1078
1050
|
|
|
1079
1051
|
@Module({
|
|
1080
|
-
imports: [
|
|
1081
|
-
controllers: [AppController],
|
|
1082
|
-
providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
1052
|
+
imports: [TodosModule],
|
|
1083
1053
|
})
|
|
1084
1054
|
export class AppModule {}`
|
|
1085
1055
|
};
|
|
1086
1056
|
|
|
1087
|
-
// src/api/templates/main.ts
|
|
1088
|
-
var main_default = {
|
|
1089
|
-
filename: "apps/api/src/main.ts",
|
|
1090
|
-
template: `import dotenv from 'dotenv';
|
|
1091
|
-
import { resolve } from 'path';
|
|
1092
|
-
|
|
1093
|
-
// Load root .env first, then local .env (local takes precedence)
|
|
1094
|
-
dotenv.config({ path: resolve(process.cwd(), '../../.env') });
|
|
1095
|
-
dotenv.config({ path: resolve(process.cwd(), '.env') });
|
|
1096
|
-
|
|
1097
|
-
import { NestFactory } from '@nestjs/core';
|
|
1098
|
-
import { AppModule } from './app.module';
|
|
1099
|
-
|
|
1100
|
-
async function bootstrap() {
|
|
1101
|
-
const app = await NestFactory.create(AppModule, { bodyParser: false });
|
|
1102
|
-
app.setGlobalPrefix('api');
|
|
1103
|
-
app.enableCors({
|
|
1104
|
-
origin: process.env.CORS_ORIGIN ?? 'http://localhost:3000',
|
|
1105
|
-
credentials: true,
|
|
1106
|
-
});
|
|
1107
|
-
await app.listen(process.env.PORT ?? 3001);
|
|
1108
|
-
}
|
|
1109
|
-
void bootstrap();`
|
|
1110
|
-
};
|
|
1111
|
-
|
|
1112
|
-
// src/api/templates/todos-controller.ts
|
|
1113
|
-
var todos_controller_default = {
|
|
1114
|
-
filename: "apps/api/src/todos/todos.controller.ts",
|
|
1115
|
-
template: `import {
|
|
1116
|
-
Body,
|
|
1117
|
-
Controller,
|
|
1118
|
-
Delete,
|
|
1119
|
-
Get,
|
|
1120
|
-
Param,
|
|
1121
|
-
Patch,
|
|
1122
|
-
Post,
|
|
1123
|
-
} from '@nestjs/common';
|
|
1124
|
-
import { TodosService } from './todos.service';
|
|
1125
|
-
|
|
1126
|
-
@Controller('todos')
|
|
1127
|
-
export class TodosController {
|
|
1128
|
-
constructor(private readonly todosService: TodosService) {}
|
|
1129
|
-
|
|
1130
|
-
@Get()
|
|
1131
|
-
findAll() {
|
|
1132
|
-
return this.todosService.findAll();
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
@Post()
|
|
1136
|
-
create(@Body('title') title: string) {
|
|
1137
|
-
return this.todosService.create(title);
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
@Patch(':id/toggle')
|
|
1141
|
-
toggle(@Param('id') id: string) {
|
|
1142
|
-
return this.todosService.toggle(Number(id));
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
@Delete(':id')
|
|
1146
|
-
remove(@Param('id') id: string) {
|
|
1147
|
-
return this.todosService.remove(Number(id));
|
|
1148
|
-
}
|
|
1149
|
-
}`
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
1057
|
// src/api/templates/todos-module.ts
|
|
1153
1058
|
var todos_module_default = {
|
|
1154
1059
|
filename: "apps/api/src/todos/todos.module.ts",
|
|
1155
1060
|
template: `import { Module } from '@nestjs/common';
|
|
1156
|
-
import { TodosController } from './todos.controller';
|
|
1157
1061
|
import { TodosService } from './todos.service';
|
|
1158
1062
|
|
|
1159
1063
|
@Module({
|
|
1160
|
-
controllers: [TodosController],
|
|
1161
1064
|
providers: [TodosService],
|
|
1065
|
+
exports: [TodosService],
|
|
1162
1066
|
})
|
|
1163
1067
|
export class TodosModule {}`
|
|
1164
1068
|
};
|
|
@@ -1252,10 +1156,7 @@ var api = {
|
|
|
1252
1156
|
nest_cli_default,
|
|
1253
1157
|
tsconfig_default2,
|
|
1254
1158
|
tsconfig_build_default,
|
|
1255
|
-
app_controller_default,
|
|
1256
1159
|
app_module_default,
|
|
1257
|
-
main_default,
|
|
1258
|
-
todos_controller_default,
|
|
1259
1160
|
todos_module_default,
|
|
1260
1161
|
todos_service_default,
|
|
1261
1162
|
todos_service_spec_default,
|
|
@@ -8314,29 +8215,6 @@ var jest_e2e_config_default = {
|
|
|
8314
8215
|
}`
|
|
8315
8216
|
};
|
|
8316
8217
|
|
|
8317
|
-
// src/testing-jest/templates/app-controller-spec.ts
|
|
8318
|
-
var app_controller_spec_default = {
|
|
8319
|
-
filename: "apps/api/src/app.controller.spec.ts",
|
|
8320
|
-
template: `import { Test, TestingModule } from '@nestjs/testing';
|
|
8321
|
-
import { AppController } from './app.controller';
|
|
8322
|
-
|
|
8323
|
-
describe('AppController', () => {
|
|
8324
|
-
let appController: AppController;
|
|
8325
|
-
|
|
8326
|
-
beforeEach(async () => {
|
|
8327
|
-
const app: TestingModule = await Test.createTestingModule({
|
|
8328
|
-
controllers: [AppController],
|
|
8329
|
-
}).compile();
|
|
8330
|
-
|
|
8331
|
-
appController = app.get<AppController>(AppController);
|
|
8332
|
-
});
|
|
8333
|
-
|
|
8334
|
-
it('should be defined', () => {
|
|
8335
|
-
expect(appController).toBeDefined();
|
|
8336
|
-
});
|
|
8337
|
-
});`
|
|
8338
|
-
};
|
|
8339
|
-
|
|
8340
8218
|
// src/testing-jest/templates/e2e-spec.ts
|
|
8341
8219
|
var e2e_spec_default = {
|
|
8342
8220
|
filename: "apps/api/test/app.e2e-spec.ts",
|
|
@@ -8385,7 +8263,7 @@ module.exports = {
|
|
|
8385
8263
|
|
|
8386
8264
|
// src/testing-jest/index.ts
|
|
8387
8265
|
var testingJest = {
|
|
8388
|
-
templates: [jest_config_default, jest_e2e_config_default,
|
|
8266
|
+
templates: [jest_config_default, jest_e2e_config_default, e2e_spec_default, nestjs_better_auth_mock_default],
|
|
8389
8267
|
packages: [
|
|
8390
8268
|
{ package: "jest", module: "apps/api", version: "^30.0.0", dev: true },
|
|
8391
8269
|
{ package: "ts-jest", module: "apps/api", version: "^29.2.5", dev: true },
|
|
@@ -8438,30 +8316,6 @@ export default defineConfig({
|
|
|
8438
8316
|
});`
|
|
8439
8317
|
};
|
|
8440
8318
|
|
|
8441
|
-
// src/testing-vitest/templates/app-controller-spec.ts
|
|
8442
|
-
var app_controller_spec_default2 = {
|
|
8443
|
-
filename: "apps/api/src/app.controller.spec.ts",
|
|
8444
|
-
template: `import { describe, it, expect, beforeEach } from 'vitest';
|
|
8445
|
-
import { Test, TestingModule } from '@nestjs/testing';
|
|
8446
|
-
import { AppController } from './app.controller';
|
|
8447
|
-
|
|
8448
|
-
describe('AppController', () => {
|
|
8449
|
-
let appController: AppController;
|
|
8450
|
-
|
|
8451
|
-
beforeEach(async () => {
|
|
8452
|
-
const app: TestingModule = await Test.createTestingModule({
|
|
8453
|
-
controllers: [AppController],
|
|
8454
|
-
}).compile();
|
|
8455
|
-
|
|
8456
|
-
appController = app.get<AppController>(AppController);
|
|
8457
|
-
});
|
|
8458
|
-
|
|
8459
|
-
it('should be defined', () => {
|
|
8460
|
-
expect(appController).toBeDefined();
|
|
8461
|
-
});
|
|
8462
|
-
});`
|
|
8463
|
-
};
|
|
8464
|
-
|
|
8465
8319
|
// src/testing-vitest/templates/e2e-spec.ts
|
|
8466
8320
|
var e2e_spec_default2 = {
|
|
8467
8321
|
filename: "apps/api/test/app.e2e-spec.ts",
|
|
@@ -8495,7 +8349,7 @@ describe('AppController (e2e)', () => {
|
|
|
8495
8349
|
|
|
8496
8350
|
// src/testing-vitest/index.ts
|
|
8497
8351
|
var testingVitest = {
|
|
8498
|
-
templates: [vitest_config_default, vitest_config_e2e_default,
|
|
8352
|
+
templates: [vitest_config_default, vitest_config_e2e_default, e2e_spec_default2],
|
|
8499
8353
|
packages: [
|
|
8500
8354
|
{ package: "vitest", module: "apps/api", version: "^3.0.0", dev: true },
|
|
8501
8355
|
{ package: "@vitest/coverage-v8", module: "apps/api", version: "^3.0.0", dev: true },
|
|
@@ -9464,6 +9318,163 @@ var nestDiOnly = {
|
|
|
9464
9318
|
};
|
|
9465
9319
|
var nest_di_only_default = nestDiOnly;
|
|
9466
9320
|
|
|
9321
|
+
// src/api-controllers/templates/app-controller.ts
|
|
9322
|
+
var app_controller_default = {
|
|
9323
|
+
filename: "apps/api/src/app.controller.ts",
|
|
9324
|
+
template: `import { Controller, Get } from '@nestjs/common';
|
|
9325
|
+
import {
|
|
9326
|
+
AllowAnonymous,
|
|
9327
|
+
Session,
|
|
9328
|
+
UserSession,
|
|
9329
|
+
} from '@thallesp/nestjs-better-auth';
|
|
9330
|
+
|
|
9331
|
+
@Controller()
|
|
9332
|
+
export class AppController {
|
|
9333
|
+
@AllowAnonymous()
|
|
9334
|
+
@Get('hello')
|
|
9335
|
+
getHello(@Session() session: UserSession | null) {
|
|
9336
|
+
if (session?.user.name) {
|
|
9337
|
+
return { message: \`Hello \${session.user.name}\` };
|
|
9338
|
+
}
|
|
9339
|
+
|
|
9340
|
+
return { message: 'Hello from Nest' };
|
|
9341
|
+
}
|
|
9342
|
+
}`
|
|
9343
|
+
};
|
|
9344
|
+
|
|
9345
|
+
// src/api-controllers/templates/app-controller-spec.ts
|
|
9346
|
+
var app_controller_spec_default = {
|
|
9347
|
+
filename: "apps/api/src/app.controller.spec.ts",
|
|
9348
|
+
template: `import { Test, TestingModule } from '@nestjs/testing';
|
|
9349
|
+
import { AppController } from './app.controller';
|
|
9350
|
+
|
|
9351
|
+
describe('AppController', () => {
|
|
9352
|
+
let appController: AppController;
|
|
9353
|
+
|
|
9354
|
+
beforeEach(async () => {
|
|
9355
|
+
const app: TestingModule = await Test.createTestingModule({
|
|
9356
|
+
controllers: [AppController],
|
|
9357
|
+
}).compile();
|
|
9358
|
+
|
|
9359
|
+
appController = app.get<AppController>(AppController);
|
|
9360
|
+
});
|
|
9361
|
+
|
|
9362
|
+
it('should be defined', () => {
|
|
9363
|
+
expect(appController).toBeDefined();
|
|
9364
|
+
});
|
|
9365
|
+
});`
|
|
9366
|
+
};
|
|
9367
|
+
|
|
9368
|
+
// src/api-controllers/templates/app-module.ts
|
|
9369
|
+
var app_module_default2 = {
|
|
9370
|
+
filename: "apps/api/src/app.module.ts",
|
|
9371
|
+
template: `import { Module } from '@nestjs/common';
|
|
9372
|
+
import { APP_GUARD } from '@nestjs/core';
|
|
9373
|
+
import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
|
|
9374
|
+
import { auth } from '@<%= projectName %>/auth';
|
|
9375
|
+
import { AppController } from './app.controller';
|
|
9376
|
+
import { TodosModule } from './todos/todos.module';
|
|
9377
|
+
|
|
9378
|
+
@Module({
|
|
9379
|
+
imports: [AuthModule.forRoot({ auth }), TodosModule],
|
|
9380
|
+
controllers: [AppController],
|
|
9381
|
+
providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
9382
|
+
})
|
|
9383
|
+
export class AppModule {}`
|
|
9384
|
+
};
|
|
9385
|
+
|
|
9386
|
+
// src/api/templates/main.ts
|
|
9387
|
+
var main_default = {
|
|
9388
|
+
filename: "apps/api/src/main.ts",
|
|
9389
|
+
template: `import dotenv from 'dotenv';
|
|
9390
|
+
import { resolve } from 'path';
|
|
9391
|
+
|
|
9392
|
+
// Load root .env first, then local .env (local takes precedence)
|
|
9393
|
+
dotenv.config({ path: resolve(process.cwd(), '../../.env') });
|
|
9394
|
+
dotenv.config({ path: resolve(process.cwd(), '.env') });
|
|
9395
|
+
|
|
9396
|
+
import { NestFactory } from '@nestjs/core';
|
|
9397
|
+
import { AppModule } from './app.module';
|
|
9398
|
+
|
|
9399
|
+
async function bootstrap() {
|
|
9400
|
+
const app = await NestFactory.create(AppModule, { bodyParser: false });
|
|
9401
|
+
app.setGlobalPrefix('api');
|
|
9402
|
+
app.enableCors({
|
|
9403
|
+
origin: process.env.CORS_ORIGIN ?? 'http://localhost:3000',
|
|
9404
|
+
credentials: true,
|
|
9405
|
+
});
|
|
9406
|
+
await app.listen(process.env.PORT ?? 3001);
|
|
9407
|
+
}
|
|
9408
|
+
void bootstrap();`
|
|
9409
|
+
};
|
|
9410
|
+
|
|
9411
|
+
// src/api-controllers/templates/todos-controller.ts
|
|
9412
|
+
var todos_controller_default = {
|
|
9413
|
+
filename: "apps/api/src/todos/todos.controller.ts",
|
|
9414
|
+
template: `import {
|
|
9415
|
+
Body,
|
|
9416
|
+
Controller,
|
|
9417
|
+
Delete,
|
|
9418
|
+
Get,
|
|
9419
|
+
Param,
|
|
9420
|
+
Patch,
|
|
9421
|
+
Post,
|
|
9422
|
+
} from '@nestjs/common';
|
|
9423
|
+
import { TodosService } from './todos.service';
|
|
9424
|
+
|
|
9425
|
+
@Controller('todos')
|
|
9426
|
+
export class TodosController {
|
|
9427
|
+
constructor(private readonly todosService: TodosService) {}
|
|
9428
|
+
|
|
9429
|
+
@Get()
|
|
9430
|
+
findAll() {
|
|
9431
|
+
return this.todosService.findAll();
|
|
9432
|
+
}
|
|
9433
|
+
|
|
9434
|
+
@Post()
|
|
9435
|
+
create(@Body('title') title: string) {
|
|
9436
|
+
return this.todosService.create(title);
|
|
9437
|
+
}
|
|
9438
|
+
|
|
9439
|
+
@Patch(':id/toggle')
|
|
9440
|
+
toggle(@Param('id') id: string) {
|
|
9441
|
+
return this.todosService.toggle(Number(id));
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
@Delete(':id')
|
|
9445
|
+
remove(@Param('id') id: string) {
|
|
9446
|
+
return this.todosService.remove(Number(id));
|
|
9447
|
+
}
|
|
9448
|
+
}`
|
|
9449
|
+
};
|
|
9450
|
+
|
|
9451
|
+
// src/api-controllers/templates/todos-module.ts
|
|
9452
|
+
var todos_module_default2 = {
|
|
9453
|
+
filename: "apps/api/src/todos/todos.module.ts",
|
|
9454
|
+
template: `import { Module } from '@nestjs/common';
|
|
9455
|
+
import { TodosController } from './todos.controller';
|
|
9456
|
+
import { TodosService } from './todos.service';
|
|
9457
|
+
|
|
9458
|
+
@Module({
|
|
9459
|
+
controllers: [TodosController],
|
|
9460
|
+
providers: [TodosService],
|
|
9461
|
+
})
|
|
9462
|
+
export class TodosModule {}`
|
|
9463
|
+
};
|
|
9464
|
+
|
|
9465
|
+
// src/api-controllers/index.ts
|
|
9466
|
+
var apiControllers = {
|
|
9467
|
+
templates: [
|
|
9468
|
+
app_controller_default,
|
|
9469
|
+
app_controller_spec_default,
|
|
9470
|
+
app_module_default2,
|
|
9471
|
+
main_default,
|
|
9472
|
+
todos_controller_default,
|
|
9473
|
+
todos_module_default2
|
|
9474
|
+
]
|
|
9475
|
+
};
|
|
9476
|
+
var api_controllers_default = apiControllers;
|
|
9477
|
+
|
|
9467
9478
|
// src/index.ts
|
|
9468
9479
|
var staticDir = new URL("./static/", import.meta.url);
|
|
9469
9480
|
var staticDirPath = fileURLToPath(staticDir);
|
|
@@ -9485,7 +9496,8 @@ var templates = {
|
|
|
9485
9496
|
deploymentCustomServer: single_process_custom_server_default,
|
|
9486
9497
|
deploymentSpa: single_process_static_export_default,
|
|
9487
9498
|
deploymentVercel: single_process_pages_default,
|
|
9488
|
-
nestDiOnly: nest_di_only_default
|
|
9499
|
+
nestDiOnly: nest_di_only_default,
|
|
9500
|
+
apiControllers: api_controllers_default
|
|
9489
9501
|
};
|
|
9490
9502
|
export {
|
|
9491
9503
|
getStaticFilePath,
|