Skip to content

Commit

Permalink
Updated API Server to version 9.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihaase committed Feb 25, 2023
1 parent 607b6ea commit f23260a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lenne.tech/cli",
"version": "0.0.86",
"version": "0.0.87",
"description": "lenne.Tech CLI: lt",
"keywords": [
"lenne.Tech",
Expand Down
24 changes: 24 additions & 0 deletions src/commands/server/create-secret.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as crypto from 'crypto';
import { GluegunCommand } from 'gluegun';
import { ExtendedGluegunToolbox } from '../../interfaces/extended-gluegun-toolbox';

/**
* Open regex tools in browser
*/
const NewCommand: GluegunCommand = {
name: 'createSecret',
alias: ['cs'],
description: 'Create a new secret string (for JWT config)',
hidden: false,
run: async (toolbox: ExtendedGluegunToolbox) => {
const {
print: { success },
} = toolbox;
success(crypto.randomBytes(512).toString('base64'));

// For tests
return `secret created`;
},
};

export default NewCommand;
44 changes: 14 additions & 30 deletions src/templates/nest-server-module/template.resolver.ts.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { FilterArgs, GraphQLUser, RoleEnum, Roles } from '@lenne.tech/nest-server';
import { FilterArgs, GraphQLServiceOptions, RoleEnum, Roles, ServiceOptions } from '@lenne.tech/nest-server';
import { Inject } from '@nestjs/common';
import { Args, Info, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
import { GraphQLResolveInfo } from 'graphql';
import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
import { PubSub } from 'graphql-subscriptions';
import { User } from '../user/user.model';
import { <%= props.namePascal %>CreateInput } from './inputs/<%= props.nameKebab %>-create.input';
import { <%= props.namePascal %>Input } from './inputs/<%= props.nameKebab %>.input';
import { FindAndCount<%= props.namePascal %>sResult } from './outputs/find-and-count-<%= props.nameKebab %>s-result.output';
Expand Down Expand Up @@ -35,13 +33,11 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Query(() => FindAndCount<%= props.namePascal %>sResult, { description: 'Find <%= props.namePascal %>s (via filter)' })
async findAndCount<%= props.namePascal %>s(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args() args?: FilterArgs
) {
return await this.<%= props.nameCamel %>Service.findAndCount(args, {
currentUser: user,
fieldSelection: { info, select: 'findAndCount<%= props.namePascal %>s.items' },
...serviceOptions,
inputType: FilterArgs,
});
}
Expand All @@ -52,13 +48,11 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Query(() => [<%= props.namePascal %>], { description: 'Find <%= props.namePascal %>s (via filter)' })
async find<%= props.namePascal %>s(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args() args?: FilterArgs
) {
return await this.<%= props.nameCamel %>Service.find(args, {
currentUser: user,
fieldSelection: { info, select: 'find<%= props.namePascal %>s' },
...serviceOptions,
inputType: FilterArgs
});
}
Expand All @@ -69,14 +63,10 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Query(() => <%= props.namePascal %>, { description: 'Get <%= props.namePascal %> with specified ID' })
async get<%= props.namePascal %>(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args('id') id: string,
): Promise<<%= props.namePascal %>> {
return await this.<%= props.nameCamel %>Service.get(id, {
currentUser: user,
fieldSelection: { info, select: 'get<%= props.namePascal %>' },
});
return await this.<%= props.nameCamel %>Service.get(id, serviceOptions);
}

// ===========================================================================
Expand All @@ -89,13 +79,11 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Mutation(() => <%= props.namePascal %>, { description: 'Create a new <%= props.namePascal %>' })
async create<%= props.namePascal %>(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args('input') input: <%= props.namePascal %>CreateInput
): Promise<<%= props.namePascal %>> {
return await this.<%= props.nameCamel %>Service.create(input, {
currentUser: user,
fieldSelection: { info, select: 'create<%= props.namePascal %>' },
...serviceOptions,
inputType: <%= props.namePascal %>CreateInput
});
}
Expand All @@ -106,13 +94,11 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Mutation(() => <%= props.namePascal %>, { description: 'Delete existing <%= props.namePascal %>' })
async delete<%= props.namePascal %>(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args('id') id: string
): Promise<<%= props.namePascal %>> {
return await this.<%= props.nameCamel %>Service.delete(id, {
currentUser: user,
fieldSelection: { info, select: 'delete<%= props.namePascal %>' },
...serviceOptions,
roles: [RoleEnum.ADMIN, RoleEnum.S_CREATOR]
});
}
Expand All @@ -123,14 +109,12 @@ export class <%= props.namePascal %>Resolver {
@Roles(RoleEnum.S_USER)
@Mutation(() => <%= props.namePascal %>, { description: 'Update existing <%= props.namePascal %>' })
async update<%= props.namePascal %>(
@Info() info: GraphQLResolveInfo,
@GraphQLUser() user: User,
@GraphQLServiceOptions() serviceOptions: ServiceOptions,
@Args('id') id: string,
@Args('input') input: <%= props.namePascal %>Input
): Promise<<%= props.namePascal %>> {
return await this.<%= props.nameCamel %>Service.update(id, input, {
currentUser: user,
fieldSelection: { info, select: 'update<%= props.namePascal %>' },
serviceOptions,
inputType: <%= props.namePascal %>Input,
roles: [RoleEnum.ADMIN, RoleEnum.S_CREATOR]
});
Expand Down

0 comments on commit f23260a

Please sign in to comment.