@newt-app/templates 0.8.3 → 0.9.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
@@ -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,44 +1042,14 @@ 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: [AuthModule.forRoot({ auth }), TodosModule],
1081
- controllers: [AppController],
1082
- providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
1052
+ imports: [TodosModule],
1083
1053
  })
1084
1054
  export class AppModule {}`
1085
1055
  };
@@ -1109,56 +1079,15 @@ async function bootstrap() {
1109
1079
  void bootstrap();`
1110
1080
  };
1111
1081
 
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
1082
  // src/api/templates/todos-module.ts
1153
1083
  var todos_module_default = {
1154
1084
  filename: "apps/api/src/todos/todos.module.ts",
1155
1085
  template: `import { Module } from '@nestjs/common';
1156
- import { TodosController } from './todos.controller';
1157
1086
  import { TodosService } from './todos.service';
1158
1087
 
1159
1088
  @Module({
1160
- controllers: [TodosController],
1161
1089
  providers: [TodosService],
1090
+ exports: [TodosService],
1162
1091
  })
1163
1092
  export class TodosModule {}`
1164
1093
  };
@@ -1252,10 +1181,8 @@ var api = {
1252
1181
  nest_cli_default,
1253
1182
  tsconfig_default2,
1254
1183
  tsconfig_build_default,
1255
- app_controller_default,
1256
1184
  app_module_default,
1257
1185
  main_default,
1258
- todos_controller_default,
1259
1186
  todos_module_default,
1260
1187
  todos_service_default,
1261
1188
  todos_service_spec_default,
@@ -8314,29 +8241,6 @@ var jest_e2e_config_default = {
8314
8241
  }`
8315
8242
  };
8316
8243
 
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
8244
  // src/testing-jest/templates/e2e-spec.ts
8341
8245
  var e2e_spec_default = {
8342
8246
  filename: "apps/api/test/app.e2e-spec.ts",
@@ -8385,7 +8289,7 @@ module.exports = {
8385
8289
 
8386
8290
  // src/testing-jest/index.ts
8387
8291
  var testingJest = {
8388
- templates: [jest_config_default, jest_e2e_config_default, app_controller_spec_default, e2e_spec_default, nestjs_better_auth_mock_default],
8292
+ templates: [jest_config_default, jest_e2e_config_default, e2e_spec_default, nestjs_better_auth_mock_default],
8389
8293
  packages: [
8390
8294
  { package: "jest", module: "apps/api", version: "^30.0.0", dev: true },
8391
8295
  { package: "ts-jest", module: "apps/api", version: "^29.2.5", dev: true },
@@ -8438,30 +8342,6 @@ export default defineConfig({
8438
8342
  });`
8439
8343
  };
8440
8344
 
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
8345
  // src/testing-vitest/templates/e2e-spec.ts
8466
8346
  var e2e_spec_default2 = {
8467
8347
  filename: "apps/api/test/app.e2e-spec.ts",
@@ -8495,7 +8375,7 @@ describe('AppController (e2e)', () => {
8495
8375
 
8496
8376
  // src/testing-vitest/index.ts
8497
8377
  var testingVitest = {
8498
- templates: [vitest_config_default, vitest_config_e2e_default, app_controller_spec_default2, e2e_spec_default2],
8378
+ templates: [vitest_config_default, vitest_config_e2e_default, e2e_spec_default2],
8499
8379
  packages: [
8500
8380
  { package: "vitest", module: "apps/api", version: "^3.0.0", dev: true },
8501
8381
  { package: "@vitest/coverage-v8", module: "apps/api", version: "^3.0.0", dev: true },
@@ -9464,6 +9344,137 @@ var nestDiOnly = {
9464
9344
  };
9465
9345
  var nest_di_only_default = nestDiOnly;
9466
9346
 
9347
+ // src/api-controllers/templates/app-controller.ts
9348
+ var app_controller_default = {
9349
+ filename: "apps/api/src/app.controller.ts",
9350
+ template: `import { Controller, Get } from '@nestjs/common';
9351
+ import {
9352
+ AllowAnonymous,
9353
+ Session,
9354
+ UserSession,
9355
+ } from '@thallesp/nestjs-better-auth';
9356
+
9357
+ @Controller()
9358
+ export class AppController {
9359
+ @AllowAnonymous()
9360
+ @Get('hello')
9361
+ getHello(@Session() session: UserSession | null) {
9362
+ if (session?.user.name) {
9363
+ return { message: \`Hello \${session.user.name}\` };
9364
+ }
9365
+
9366
+ return { message: 'Hello from Nest' };
9367
+ }
9368
+ }`
9369
+ };
9370
+
9371
+ // src/api-controllers/templates/app-controller-spec.ts
9372
+ var app_controller_spec_default = {
9373
+ filename: "apps/api/src/app.controller.spec.ts",
9374
+ template: `import { Test, TestingModule } from '@nestjs/testing';
9375
+ import { AppController } from './app.controller';
9376
+
9377
+ describe('AppController', () => {
9378
+ let appController: AppController;
9379
+
9380
+ beforeEach(async () => {
9381
+ const app: TestingModule = await Test.createTestingModule({
9382
+ controllers: [AppController],
9383
+ }).compile();
9384
+
9385
+ appController = app.get<AppController>(AppController);
9386
+ });
9387
+
9388
+ it('should be defined', () => {
9389
+ expect(appController).toBeDefined();
9390
+ });
9391
+ });`
9392
+ };
9393
+
9394
+ // src/api-controllers/templates/app-module.ts
9395
+ var app_module_default2 = {
9396
+ filename: "apps/api/src/app.module.ts",
9397
+ template: `import { Module } from '@nestjs/common';
9398
+ import { APP_GUARD } from '@nestjs/core';
9399
+ import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
9400
+ import { auth } from '@<%= projectName %>/auth';
9401
+ import { AppController } from './app.controller';
9402
+ import { TodosModule } from './todos/todos.module';
9403
+
9404
+ @Module({
9405
+ imports: [AuthModule.forRoot({ auth }), TodosModule],
9406
+ controllers: [AppController],
9407
+ providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
9408
+ })
9409
+ export class AppModule {}`
9410
+ };
9411
+
9412
+ // src/api-controllers/templates/todos-controller.ts
9413
+ var todos_controller_default = {
9414
+ filename: "apps/api/src/todos/todos.controller.ts",
9415
+ template: `import {
9416
+ Body,
9417
+ Controller,
9418
+ Delete,
9419
+ Get,
9420
+ Param,
9421
+ Patch,
9422
+ Post,
9423
+ } from '@nestjs/common';
9424
+ import { TodosService } from './todos.service';
9425
+
9426
+ @Controller('todos')
9427
+ export class TodosController {
9428
+ constructor(private readonly todosService: TodosService) {}
9429
+
9430
+ @Get()
9431
+ findAll() {
9432
+ return this.todosService.findAll();
9433
+ }
9434
+
9435
+ @Post()
9436
+ create(@Body('title') title: string) {
9437
+ return this.todosService.create(title);
9438
+ }
9439
+
9440
+ @Patch(':id/toggle')
9441
+ toggle(@Param('id') id: string) {
9442
+ return this.todosService.toggle(Number(id));
9443
+ }
9444
+
9445
+ @Delete(':id')
9446
+ remove(@Param('id') id: string) {
9447
+ return this.todosService.remove(Number(id));
9448
+ }
9449
+ }`
9450
+ };
9451
+
9452
+ // src/api-controllers/templates/todos-module.ts
9453
+ var todos_module_default2 = {
9454
+ filename: "apps/api/src/todos/todos.module.ts",
9455
+ template: `import { Module } from '@nestjs/common';
9456
+ import { TodosController } from './todos.controller';
9457
+ import { TodosService } from './todos.service';
9458
+
9459
+ @Module({
9460
+ controllers: [TodosController],
9461
+ providers: [TodosService],
9462
+ })
9463
+ export class TodosModule {}`
9464
+ };
9465
+
9466
+ // src/api-controllers/index.ts
9467
+ var apiControllers = {
9468
+ templates: [
9469
+ app_controller_default,
9470
+ app_controller_spec_default,
9471
+ app_module_default2,
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newt-app/templates",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "Templates for newt-app",
6
6
  "type": "module",