@mikemajesty/microservice-crud 0.0.5 → 0.0.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.
@@ -0,0 +1,24 @@
1
+ #### Mongo CRUD
2
+
3
+ ### Add Module to microservice.
4
+
5
+ - Access the app.module.ts file
6
+ ```
7
+ src/app.module.ts
8
+ ```
9
+ - Add your Mongo Module in the Imports array.
10
+ ```
11
+ imports: [NewModule]
12
+ ```
13
+
14
+ ---
15
+
16
+ The following is a list of all the people that have contributed Nestjs monorepo CLI. Thanks for your contributions!
17
+
18
+ [<img alt="mikemajesty" src="https://avatars1.githubusercontent.com/u/11630212?s=460&v=4&s=117" width="117">](https://github.com/mikemajesty)
19
+
20
+ ## License
21
+
22
+ It is available under the MIT license.
23
+ [License](https://opensource.org/licenses/mit-license.php)
24
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikemajesty/microservice-crud",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Monorepo CLI",
5
5
  "main": "src/cli.js",
6
6
  "scripts": {
@@ -0,0 +1,35 @@
1
+ #### Postgres CRUD
2
+
3
+ ### Add Schema to Sequelize.
4
+
5
+ - Access the config.ts file
6
+ ```
7
+ src/infra/database/postgres/config.ts
8
+ ```
9
+ - Add your Postgres schema in the addModels function.
10
+ ```
11
+ sequelizeConfig.addModels([NewSchema]);
12
+ ```
13
+
14
+ ### Add Module to microservice.
15
+
16
+ - Access the app.module.ts file
17
+ ```
18
+ src/app.module.ts
19
+ ```
20
+ - Add your Postgres Module in the Imports array.
21
+ ```
22
+ imports: [NewModule]
23
+ ```
24
+
25
+ ---
26
+
27
+ The following is a list of all the people that have contributed Nestjs monorepo CLI. Thanks for your contributions!
28
+
29
+ [<img alt="mikemajesty" src="https://avatars1.githubusercontent.com/u/11630212?s=460&v=4&s=117" width="117">](https://github.com/mikemajesty)
30
+
31
+ ## License
32
+
33
+ It is available under the MIT license.
34
+ [License](https://opensource.org/licenses/mit-license.php)
35
+
package/src/cli.js CHANGED
@@ -22,7 +22,7 @@ const { getModuleAdapter } = require('./templates/postgres/modules/adapter');
22
22
  const { getModuleController } = require('./templates/postgres/modules/controller');
23
23
  const { getModule } = require('./templates/postgres/modules/module');
24
24
  const { getModuleRepository } = require('./templates/postgres/modules/repository');
25
- const { getModuleSchema } = require('./templates/postgres/modules/schema');
25
+ const { getModuleSchema } = require('./templates/postgres/schemas/schema');
26
26
  const { getModuleSwagger } = require('./templates/postgres/modules/swagger');
27
27
  const { getModuleType } = require('./templates/postgres/modules/types');
28
28
 
@@ -43,7 +43,7 @@ const { getModuleAdapter: getModuleAdapterMongo } = require('./templates/mongo/m
43
43
  const { getModuleController: getModuleControllerMongo } = require('./templates/mongo/modules/controller');
44
44
  const { getModule: getModuleMongo } = require('./templates/mongo/modules/module');
45
45
  const { getModuleRepository: getModuleRepositoryMongo } = require('./templates/mongo/modules/repository');
46
- const { getModuleSchema: getModuleSchemaMongo } = require('./templates/mongo/modules/schema');
46
+ const { getModuleSchema: getModuleSchemaMongo } = require('./templates/mongo/schemas/schema');
47
47
  const { getModuleSwagger: getModuleSwaggerMongo } = require('./templates/mongo/modules/swagger');
48
48
  const { getModuleType: getModuleTypeMongo } = require('./templates/mongo/modules/types');
49
49
 
@@ -88,24 +88,29 @@ const createPostgresCrud = async (name) => {
88
88
 
89
89
  const useCasesPathTest = `${useCasesPath}/__tests__`
90
90
  fs.mkdirSync(useCasesPathTest)
91
-
92
91
  fs.writeFileSync(`${useCasesPathTest}/${name}-create.spec.ts`, getCoreUsecaseCreateTest(name))
93
92
  fs.writeFileSync(`${useCasesPathTest}/${name}-update.spec.ts`, getCoreUsecaseUpdateTest(name))
94
93
  fs.writeFileSync(`${useCasesPathTest}/${name}-delete.spec.ts`, getCoreUsecaseDeleteTest(name))
95
94
  fs.writeFileSync(`${useCasesPathTest}/${name}-list.spec.ts`, getCoreUsecaseListTest(name))
96
95
  fs.writeFileSync(`${useCasesPathTest}/${name}-getByID.spec.ts`, getCoreUsecaseGetByIDTest(name))
97
96
 
97
+ const schemasPath = `${__dirname}/scafold/postgres/schemas`;
98
+ if (fs.existsSync(schemasPath)) {
99
+ fs.rmSync(schemasPath, { recursive: true });
100
+ }
101
+ fs.mkdirSync(schemasPath)
102
+ fs.writeFileSync(`${schemasPath}/${name}.ts`, getModuleSchema(name))
103
+
98
104
  const modulesPath = `${dirRoot}/modules/${name}`;
99
105
  fs.mkdirSync(modulesPath)
100
-
101
106
  fs.writeFileSync(`${modulesPath}/adapter.ts`, getModuleAdapter(name))
102
107
  fs.writeFileSync(`${modulesPath}/controller.ts`, getModuleController(name))
103
108
  fs.writeFileSync(`${modulesPath}/module.ts`, getModule(name))
104
109
  fs.writeFileSync(`${modulesPath}/repository.ts`, getModuleRepository(name))
105
- fs.writeFileSync(`${modulesPath}/schema.ts`, getModuleSchema(name))
106
110
  fs.writeFileSync(`${modulesPath}/swagger.ts`, getModuleSwagger(name))
107
111
  fs.writeFileSync(`${modulesPath}/types.ts`, getModuleType(name))
108
112
 
113
+
109
114
  return `${name}`
110
115
  } catch (error) {
111
116
  console.log('error', error)
@@ -164,6 +169,15 @@ const createMongoCrud = async (name) => {
164
169
  fs.writeFileSync(`${useCasesPathTest}/${name}-list.spec.ts`, getCoreUsecaseListMongoTest(name))
165
170
  fs.writeFileSync(`${useCasesPathTest}/${name}-getByID.spec.ts`, getCoreUsecaseGetByIDMongoTest(name))
166
171
 
172
+ const schemasPath = `${__dirname}/scafold/mongo/schemas`;
173
+
174
+ if (fs.existsSync(schemasPath)) {
175
+ fs.rmSync(schemasPath, { recursive: true });
176
+ }
177
+
178
+ fs.mkdirSync(schemasPath)
179
+ fs.writeFileSync(`${schemasPath}/${name}.ts`, getModuleSchemaMongo(name))
180
+
167
181
  const modulesPath = `${dirRoot}/modules/${name}`;
168
182
  fs.mkdirSync(modulesPath)
169
183
 
@@ -280,11 +294,30 @@ export async function cli(args) {
280
294
  const destination = `${dest}/src/${folder}`.replace('\n', '');
281
295
 
282
296
  fse.copySync(source, destination, { overwrite: true });
297
+
298
+ const destPathSchema = `${dest}/src/infra/database/${userInput.type === 'postgres:crud' ? 'postgres' : 'mongo'}/schemas`;
299
+
300
+ console.log('destPathSchema', destPathSchema)
301
+
302
+ const pathSchema = path.resolve(src, '../schemas');
303
+
304
+ console.log('pathSchema', pathSchema)
305
+ fse.copySync(pathSchema, destPathSchema, { overwrite: true });
283
306
 
284
307
  if (fs.existsSync(source)) {
285
308
  fs.rmSync(source, { recursive: true });
286
309
  }
287
310
  }
311
+
312
+ console.log(bold(green('===done===')))
313
+
314
+ if (userInput.type === 'postgres:crud') {
315
+ console.log(red('!!!!!!!!!!REAMDE!!!!!!!'), green(bold('https://github.com/mikemajesty/nestjs-microservice-api-cli/blob/main/potgres.README.md')))
316
+ }
317
+
318
+ if (userInput.type === 'mongo:crud') {
319
+ console.log(red('!!!!!!!!!!REAMDE!!!!!!!'), green(bold('https://github.com/mikemajesty/nestjs-microservice-api-cli/blob/main/mongo.README.md')))
320
+ }
288
321
  });
289
322
 
290
323
  } catch (error) {
@@ -0,0 +1,35 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { Document } from 'mongoose';
3
+ import * as paginate from 'mongoose-paginate-v2';
4
+
5
+ import { BirdEntity } from '@/core/bird/entity/bird';
6
+
7
+ export type BirdDocument = Document & BirdEntity;
8
+
9
+ @Schema({
10
+ collection: 'birds',
11
+ autoIndex: true,
12
+ timestamps: true
13
+ })
14
+ export class Bird {
15
+ @Prop({ type: String })
16
+ _id: string;
17
+
18
+ @Prop({ index: true, min: 1, max: 200, required: true, type: String })
19
+ name: string;
20
+
21
+ @Prop({ type: Date, default: null })
22
+ deletedAt: Date;
23
+ }
24
+
25
+ const BirdSchema = SchemaFactory.createForClass(Bird);
26
+
27
+ BirdSchema.index({ name: 1 });
28
+
29
+ BirdSchema.plugin(paginate);
30
+
31
+ BirdSchema.virtual('id').get(function () {
32
+ return this._id;
33
+ });
34
+
35
+ export { BirdSchema };
@@ -0,0 +1,13 @@
1
+ import { Column, DataType, Model, Table } from 'sequelize-typescript';
2
+
3
+ @Table({ timestamps: true, tableName: 'dogs' })
4
+ export class DogSchema extends Model {
5
+ @Column({ primaryKey: true, type: DataType.UUID })
6
+ id: string;
7
+
8
+ @Column(DataType.STRING)
9
+ name: string;
10
+
11
+ @Column({ allowNull: true, type: DataType.DATE })
12
+ deletedAt?: Date;
13
+ }
@@ -9,8 +9,9 @@ import { PaginateModel } from 'mongoose';
9
9
 
10
10
  import { I${capitalizeFirstLetter(name)}Repository } from '@/core/${name}/repository/${name}';
11
11
  import { MongoRepository } from '@/infra/repository';
12
- import { ValidateDatabaseSort } from '@/utils/decorators/validate-allowed-sort-order.decorator';
13
- import { SearchTypeEnum, ValidateMongoFilter } from '@/utils/decorators/validate-mongo-filter.decorator';
12
+ import { ValidateMongooseFilter } from '@/utils/decorators/database/mongo/validate-mongoose-filter.decorator';
13
+ import { ValidateDatabaseSortAllowed } from '@/utils/decorators/database/validate-database-sort-allowed.decorator';
14
+ import { SearchTypeEnum } from '@/utils/decorators/types';
14
15
 
15
16
  import { ${capitalizeFirstLetter(name)}, ${capitalizeFirstLetter(name)}Document } from './schema';
16
17
  import { ${capitalizeFirstLetter(name)}ListInput, ${capitalizeFirstLetter(name)}ListOutput } from './types';
@@ -21,8 +22,8 @@ export class ${capitalizeFirstLetter(name)}Repository extends MongoRepository<${
21
22
  super(entity);
22
23
  }
23
24
 
24
- @ValidateMongoFilter([{ name: 'name', type: SearchTypeEnum.like }])
25
- @ValidateDatabaseSort(['name', 'createdAt'])
25
+ @ValidateMongooseFilter([{ name: 'name', type: SearchTypeEnum.like }])
26
+ @ValidateDatabaseSortAllowed(['name', 'createdAt'])
26
27
  async paginate({ limit, page, sort, search }: ${capitalizeFirstLetter(name)}ListInput): Promise<${capitalizeFirstLetter(name)}ListOutput> {
27
28
  const ${name}s = await this.entity.paginate(search, { page, limit, sort });
28
29
 
@@ -1,4 +1,6 @@
1
1
 
2
+ const pluralize = require('pluralize')
3
+
2
4
  function capitalizeFirstLetter(string) {
3
5
  return string.charAt(0).toUpperCase() + string.slice(1);
4
6
  }
@@ -12,7 +14,7 @@ import { ${capitalizeFirstLetter(name)}Entity } from '@/core/${name}/entity/${na
12
14
  export type ${capitalizeFirstLetter(name)}Document = Document & ${capitalizeFirstLetter(name)}Entity;
13
15
 
14
16
  @Schema({
15
- collection: '${name}-collection',
17
+ collection: '${pluralize(name)}',
16
18
  autoIndex: true,
17
19
  timestamps: true
18
20
  })
@@ -5,11 +5,12 @@ function capitalizeFirstLetter(string) {
5
5
 
6
6
  const getCoreRepository = (name) => `import { IRepository } from '@/infra/repository';
7
7
  import { ${capitalizeFirstLetter(name)}ListInput, ${capitalizeFirstLetter(name)}ListOutput } from '@/modules/${name}/types';
8
+ import { DatabaseOptionsType } from '@/utils/database/sequelize';
8
9
 
9
10
  import { ${capitalizeFirstLetter(name)}Entity } from '../entity/${name}';
10
11
 
11
12
  export abstract class I${capitalizeFirstLetter(name)}Repository extends IRepository<${capitalizeFirstLetter(name)}Entity> {
12
- abstract paginate(input: ${capitalizeFirstLetter(name)}ListInput): Promise<${capitalizeFirstLetter(name)}ListOutput>;
13
+ abstract paginate<TOptions = DatabaseOptionsType>(input: ${capitalizeFirstLetter(name)}ListInput, options?: TOptions): Promise<${capitalizeFirstLetter(name)}ListOutput>;
13
14
  }
14
15
  `
15
16
 
@@ -4,8 +4,7 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getModule = (name) => `import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
7
- import { getRepositoryToken, TypeOrmModule } from '@nestjs/typeorm';
8
- import { Repository } from 'typeorm';
7
+ import { ModelCtor, Sequelize } from 'sequelize-typescript';
9
8
 
10
9
  import { ${capitalizeFirstLetter(name)}Entity } from '@/core/${name}/entity/${name}';
11
10
  import { I${capitalizeFirstLetter(name)}Repository } from '@/core/${name}/repository/${name}';
@@ -15,7 +14,10 @@ import { ${capitalizeFirstLetter(name)}GetByIdUsecase } from '@/core/${name}/use
15
14
  import { ${capitalizeFirstLetter(name)}ListUsecase } from '@/core/${name}/use-cases/${name}-list';
16
15
  import { ${capitalizeFirstLetter(name)}UpdateUsecase } from '@/core/${name}/use-cases/${name}-update';
17
16
  import { RedisCacheModule } from '@/infra/cache/redis';
18
- import { LoggerModule } from '@/infra/logger';
17
+ import { IDataBaseAdapter } from '@/infra/database';
18
+ import { PostgresDatabaseModule } from '@/infra/database/postgres/module';
19
+ import { ${capitalizeFirstLetter(name)}Schema } from '@/infra/database/postgres/schemas/${name}';
20
+ import { ILoggerAdapter, LoggerModule } from '@/infra/logger';
19
21
  import { TokenModule } from '@/libs/auth';
20
22
  import { IsLoggedMiddleware } from '@/utils/middlewares/is-logged.middleware';
21
23
 
@@ -28,18 +30,18 @@ import {
28
30
  } from './adapter';
29
31
  import { ${capitalizeFirstLetter(name)}Controller } from './controller';
30
32
  import { ${capitalizeFirstLetter(name)}Repository } from './repository';
31
- import { ${capitalizeFirstLetter(name)}Schema } from './schema';
32
33
 
33
34
  @Module({
34
- imports: [TokenModule, LoggerModule, TypeOrmModule.forFeature([${capitalizeFirstLetter(name)}Schema]), RedisCacheModule],
35
+ imports: [TokenModule, LoggerModule, RedisCacheModule, PostgresDatabaseModule],
35
36
  controllers: [${capitalizeFirstLetter(name)}Controller],
36
37
  providers: [
37
38
  {
38
39
  provide: I${capitalizeFirstLetter(name)}Repository,
39
- useFactory: (repository: Repository<${capitalizeFirstLetter(name)}Schema & ${capitalizeFirstLetter(name)}Entity>) => {
40
- return new ${capitalizeFirstLetter(name)}Repository(repository);
40
+ useFactory: (database: IDataBaseAdapter) => {
41
+ const repository = database.getDatabase<Sequelize>().model(${capitalizeFirstLetter(name)}Schema);
42
+ return new ${capitalizeFirstLetter(name)}Repository(repository as ModelCtor<${capitalizeFirstLetter(name)}Schema> & ${capitalizeFirstLetter(name)}Entity);
41
43
  },
42
- inject: [getRepositoryToken(${capitalizeFirstLetter(name)}Schema)]
44
+ inject: [IDataBaseAdapter]
43
45
  },
44
46
  {
45
47
  provide: I${capitalizeFirstLetter(name)}CreateAdapter,
@@ -49,7 +51,7 @@ import { ${capitalizeFirstLetter(name)}Schema } from './schema';
49
51
  {
50
52
  provide: I${capitalizeFirstLetter(name)}UpdateAdapter,
51
53
  useFactory: (repository: I${capitalizeFirstLetter(name)}Repository) => new ${capitalizeFirstLetter(name)}UpdateUsecase(repository),
52
- inject: [I${capitalizeFirstLetter(name)}Repository]
54
+ inject: [ILoggerAdapter, I${capitalizeFirstLetter(name)}Repository]
53
55
  },
54
56
  {
55
57
  provide: I${capitalizeFirstLetter(name)}GetByIDAdapter,
@@ -4,40 +4,38 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getModuleRepository = (name) => `import { Injectable } from '@nestjs/common';
7
- import { Repository } from 'typeorm';
7
+ import { ModelCtor } from 'sequelize-typescript';
8
8
 
9
9
  import { ${capitalizeFirstLetter(name)}Entity } from '@/core/${name}/entity/${name}';
10
10
  import { I${capitalizeFirstLetter(name)}Repository } from '@/core/${name}/repository/${name}';
11
- import { PostgresRepository } from '@/infra/repository/postgres/repository';
12
- import { ValidateDatabaseSort } from '@/utils/decorators/validate-allowed-sort-order.decorator';
13
- import { SearchTypeEnum, ValidatePostgresFilter } from '@/utils/decorators/validate-postgres-filter.decorator';
14
- import { calucaleSkip } from '@/utils/pagination';
11
+ import { ${capitalizeFirstLetter(name)}Schema } from '@/infra/database/postgres/schemas/${name}';
12
+ import { SequelizeRepository } from '@/infra/repository/postgres/repository';
13
+ import { ${capitalizeFirstLetter(name)}ListInput, ${capitalizeFirstLetter(name)}ListOutput } from '@/modules/${name}/types';
14
+ import { DatabaseOptionsSchema, DatabaseOptionsType } from '@/utils/database/sequelize';
15
+ import { ConvertPaginateInputToSequelizeFilter } from '@/utils/decorators/database/postgres/convert-paginate-input-to-sequelize-filter.decorator';
16
+ import { ValidateDatabaseSortAllowed } from '@/utils/decorators/database/validate-database-sort-allowed.decorator';
17
+ import { SearchTypeEnum } from '@/utils/decorators/types';
15
18
 
16
- import { ${capitalizeFirstLetter(name)}Schema } from './schema';
17
- import { ${capitalizeFirstLetter(name)}ListInput, ${capitalizeFirstLetter(name)}ListOutput } from './types';
19
+ type Model = ModelCtor<${capitalizeFirstLetter(name)}Schema> & ${capitalizeFirstLetter(name)}Entity;
18
20
 
19
21
  @Injectable()
20
- export class ${capitalizeFirstLetter(name)}Repository
21
- extends PostgresRepository<${capitalizeFirstLetter(name)}Schema & ${capitalizeFirstLetter(name)}Entity>
22
- implements Omit<I${capitalizeFirstLetter(name)}Repository, 'updateMany' | 'seed'>
23
- {
24
- constructor(readonly repository: Repository<${capitalizeFirstLetter(name)}Schema & ${capitalizeFirstLetter(name)}Entity>) {
22
+ export class ${capitalizeFirstLetter(name)}Repository extends SequelizeRepository<Model> implements I${capitalizeFirstLetter(name)}Repository {
23
+ constructor(readonly repository: Model) {
25
24
  super(repository);
26
25
  }
27
26
 
28
- @ValidatePostgresFilter([{ name: 'name', type: SearchTypeEnum.like }])
29
- @ValidateDatabaseSort(['createdAt', 'name'])
30
- async paginate(input: ${capitalizeFirstLetter(name)}ListInput): Promise<${capitalizeFirstLetter(name)}ListOutput> {
31
- const skip = calucaleSkip(input);
27
+ @ValidateDatabaseSortAllowed(['createdAt', 'name', 'breed', 'age'])
28
+ @ConvertPaginateInputToSequelizeFilter([
29
+ { name: 'name', type: SearchTypeEnum.like },
30
+ { name: 'breed', type: SearchTypeEnum.like },
31
+ { name: 'age', type: SearchTypeEnum.equal }
32
+ ])
33
+ async paginate(input: ${capitalizeFirstLetter(name)}ListInput, options: DatabaseOptionsType): Promise<${capitalizeFirstLetter(name)}ListOutput> {
34
+ const { schema } = DatabaseOptionsSchema.parse(options);
32
35
 
33
- const [docs, total] = await this.repository.findAndCount({
34
- take: input.limit,
35
- skip,
36
- order: input.sort,
37
- where: input.search
38
- });
36
+ const list = await this.repository.schema(schema).findAndCountAll(input);
39
37
 
40
- return { docs, total, page: input.page, limit: input.limit };
38
+ return { docs: list.rows, limit: input.limit, page: input.page, total: list.count };
41
39
  }
42
40
  }
43
41
  `
@@ -0,0 +1,25 @@
1
+
2
+ const pluralize = require('pluralize')
3
+
4
+ function capitalizeFirstLetter(string) {
5
+ return string.charAt(0).toUpperCase() + string.slice(1);
6
+ }
7
+
8
+ const getModuleSchema = (name) => `import { Column, DataType, Model, Table } from 'sequelize-typescript';
9
+
10
+ @Table({ timestamps: true, tableName: '${pluralize(name)}' })
11
+ export class ${capitalizeFirstLetter(name)}Schema extends Model {
12
+ @Column({ primaryKey: true, type: DataType.UUID })
13
+ id: string;
14
+
15
+ @Column(DataType.STRING)
16
+ name: string;
17
+
18
+ @Column({ allowNull: true, type: DataType.DATE })
19
+ deletedAt?: Date;
20
+ }
21
+ `
22
+
23
+ module.exports = {
24
+ getModuleSchema
25
+ }
package/README.md DELETED
@@ -1,92 +0,0 @@
1
- # Nestjs CLI monorepo
2
-
3
- ### [Monorepo](https://github.com/mikemajesty/nestjs-monorepo) CLI
4
-
5
- ### install
6
- -
7
- ```
8
- $ npm i -g @mikemajesty/microservice-crud
9
- ```
10
- ---
11
- ### Usage
12
- - 1 - type cli command
13
- ```bash
14
- $ microservice-crud
15
- ```
16
- - 2 select template type [API, MODULE, TEST]
17
- <br>[<img alt="mikemajesty" src="https://raw.githubusercontent.com/mikemajesty/microservice-crud/master/img/select-template.png">](https://github.com/mikemajesty)
18
-
19
-
20
-
21
-
22
- - 3 - type template name
23
- <br>[<img alt="mikemajesty" src="https://raw.githubusercontent.com/mikemajesty/microservice-crud/master/img/template-name.png">](https://github.com/mikemajesty)
24
-
25
-
26
-
27
- - 4 - Select path template
28
- ```bash
29
- # API must be inside [apps] folder - nestjs-monorepo/apps/
30
- # MODULE must be inside [api] folder - nestjs-monorepo/apps/auth-api/src/modules/
31
- # TEST must be inside [*] folder - nestjs-monorepo/*
32
- ```
33
-
34
- ---
35
- ### API skeleton
36
- ```
37
- .
38
- └── main-api
39
- ├── Dockerfile
40
- ├── jest.config.js
41
- ├── package.json
42
- ├── src
43
- │   ├── main.ts
44
- │   └── modules
45
- │   ├── health
46
- │   │   ├── adapter.ts
47
- │   │   ├── controller.ts
48
- │   │   ├── module.ts
49
- │   │   ├── service.ts
50
- │   │   ├── swagger.ts
51
- │   │   └── __tests__
52
- │   │   ├── controller.e2e.spec.ts
53
- │   │   ├── module.spec.ts
54
- │   │   └── service.spec.ts
55
- │   └── module.ts
56
- ├── tests
57
- │   └── initialization.js
58
- ├── tsconfig.build.json
59
- └── tsconfig.json
60
- ```
61
-
62
- ### MODULE skeleton
63
- ```
64
- .
65
- └── module
66
- ├── adapter.ts
67
- ├── controller.ts
68
- ├── module.ts
69
- ├── service.ts
70
- ├── swagger.ts
71
- └── __tests__
72
- ├── controller.e2e.spec.ts
73
- ├── module.spec.ts
74
- └── service.spec.ts
75
- ```
76
- ### TEST skeleton
77
- ```
78
- .
79
- └── __tests__
80
- ├── controller.e2e.spec.ts
81
- ├── module.spec.ts
82
- └── service.spec.ts
83
- ```
84
- ---
85
- The following is a list of all the people that have contributed Nestjs monorepo CLI. Thanks for your contributions!
86
-
87
- [<img alt="mikemajesty" src="https://avatars1.githubusercontent.com/u/11630212?s=460&v=4&s=117" width="117">](https://github.com/mikemajesty)
88
-
89
- ## License
90
-
91
- It is available under the MIT license.
92
- [License](https://opensource.org/licenses/mit-license.php)
File without changes
File without changes
@@ -1,32 +0,0 @@
1
-
2
- function capitalizeFirstLetter(string) {
3
- return string.charAt(0).toUpperCase() + string.slice(1);
4
- }
5
-
6
- const getModuleSchema = (name) => `import { Max, Min } from 'class-validator';
7
- import { BaseEntity, Column, CreateDateColumn, DeleteDateColumn, Entity, UpdateDateColumn } from 'typeorm';
8
-
9
- @Entity({ name: '${name}_collection' })
10
- export class ${capitalizeFirstLetter(name)}Schema extends BaseEntity {
11
- @Column({ type: 'uuid', primary: true })
12
- id: string;
13
-
14
- @Column('text')
15
- @Min(1)
16
- @Max(200)
17
- name: string;
18
-
19
- @CreateDateColumn()
20
- createdAt: Date;
21
-
22
- @UpdateDateColumn()
23
- updatedAt: Date;
24
-
25
- @DeleteDateColumn({ nullable: true })
26
- deletedAt: Date;
27
- }
28
- `
29
-
30
- module.exports = {
31
- getModuleSchema
32
- }