@travetto/scaffold 3.1.5 → 3.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "App Scaffold for the Travetto framework",
5
5
  "keywords": [
6
6
  "generator",
@@ -4,11 +4,9 @@ import { Inject } from '@travetto/di';
4
4
  import { ModelQuery } from '@travetto/model-query';
5
5
  import { Schema } from '@travetto/schema';
6
6
  // {{#modules.auth_rest}}
7
- import { Authenticated } from '@travetto/auth-rest';
7
+ import { AuthService, Authenticated } from '@travetto/auth-rest';
8
+ import { } from '@travetto/auth-rest';
8
9
  // {{/modules.auth_rest}}
9
- // {{#modules.auth_rest_context}}
10
- import { AuthContextService } from '@travetto/auth-rest-context';
11
- // {{/modules.auth_rest_context}}
12
10
  import { $_modelService_$ } from '$_modelImport_$';
13
11
 
14
12
  import { Todo } from '../model/todo';
@@ -16,9 +14,9 @@ import { Todo } from '../model/todo';
16
14
  @Schema()
17
15
  class Query {
18
16
  q: {
19
- // {{#modules.auth_rest_context}}
17
+ // {{#modules.auth_rest}}
20
18
  userId?: string;
21
- // {{/modules.auth_rest_context}}
19
+ // {{/modules.auth_rest}}
22
20
  } = {};
23
21
  }
24
22
 
@@ -34,10 +32,10 @@ export class TodoController {
34
32
  @Inject()
35
33
  source: $_modelService_$;
36
34
 
37
- // {{#modules.auth_rest_context}}
35
+ // {{#modules.auth_rest}}
38
36
  @Inject()
39
- auth: AuthContextService;
40
- // {{/modules.auth_rest_context}}
37
+ auth: AuthService;
38
+ // {{/modules.auth_rest}}
41
39
 
42
40
  /**
43
41
  * Get all Todos
@@ -45,9 +43,9 @@ export class TodoController {
45
43
  @Get('/')
46
44
  async getAll(query: Query): Promise<Todo[]> {
47
45
  query.q ??= {};
48
- // {{#modules.auth_rest_context}}
49
- query.q.userId = this.auth.get()?.id;
50
- // {{/modules.auth_rest_context}}
46
+ // {{#modules.auth_rest}}
47
+ query.q.userId = this.auth.getPrincipal()?.id;
48
+ // {{/modules.auth_rest}}
51
49
  return this.source.query(Todo, { where: query.q });
52
50
  }
53
51
 
@@ -57,11 +55,11 @@ export class TodoController {
57
55
  @Get('/:id')
58
56
  async getOne(id: string): Promise<Todo> {
59
57
  const q: ModelQuery<Todo> = { where: { id } };
60
- // {{#modules.auth_rest_context}}
58
+ // {{#modules.auth_rest}}
61
59
  if (typeof q.where !== 'string') {
62
- q.where!.userId = this.auth.get()?.id;
60
+ q.where!.userId = this.auth.getPrincipal()?.id;
63
61
  }
64
- // {{/modules.auth_rest_context}}
62
+ // {{/modules.auth_rest}}
65
63
  return this.source.queryOne(Todo, q);
66
64
  }
67
65
 
@@ -70,9 +68,9 @@ export class TodoController {
70
68
  */
71
69
  @Post('/')
72
70
  async save(todo: Todo): Promise<Todo> {
73
- // {{#modules.auth_rest_context}}
74
- todo.userId = this.auth.get()?.id;
75
- // {{/modules.auth_rest_context}}
71
+ // {{#modules.auth_rest}}
72
+ todo.userId = this.auth.getPrincipal()?.id;
73
+ // {{/modules.auth_rest}}
76
74
  return this.source.create(Todo, todo);
77
75
  }
78
76
 
@@ -81,9 +79,9 @@ export class TodoController {
81
79
  */
82
80
  @Put('/:id')
83
81
  async update(todo: Todo): Promise<Todo> {
84
- // {{#modules.auth_rest_context}}
85
- todo.userId = this.auth.get()?.id;
86
- // {{/modules.auth_rest_context}}
82
+ // {{#modules.auth_rest}}
83
+ todo.userId = this.auth.getPrincipal()?.id;
84
+ // {{/modules.auth_rest}}
87
85
  return this.source.update(Todo, todo);
88
86
  }
89
87
 
@@ -93,11 +91,11 @@ export class TodoController {
93
91
  @Delete('/:id')
94
92
  async remove(id: string): Promise<void> {
95
93
  const q: ModelQuery<Todo> = { where: { id } };
96
- // {{#modules.auth_rest_context}}
94
+ // {{#modules.auth_rest}}
97
95
  if (typeof q.where !== 'string') {
98
- q.where!.userId = this.auth.get()?.id;
96
+ q.where!.userId = this.auth.getPrincipal()?.id;
99
97
  }
100
- // {{/modules.auth_rest_context}}
98
+ // {{/modules.auth_rest}}
101
99
  if (await this.source.deleteByQuery(Todo, q) !== 1) {
102
100
  throw new NotFoundError(Todo, id);
103
101
  }
@@ -47,7 +47,6 @@ export const FEATURES: Feature[] = [
47
47
  addons: [
48
48
  { title: 'Rest Session', package: '@travetto/rest-session' },
49
49
  { title: 'Auth Rest Session', package: '@travetto/auth-rest-session' },
50
- { title: 'Auth Rest Context', package: '@travetto/auth-rest-context' }
51
50
  ]
52
51
  },
53
52
  {