@simitgroup/simpleapp-generator 1.0.1

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.
Files changed (55) hide show
  1. package/.prettierrc +6 -0
  2. package/LICENSE +201 -0
  3. package/README.md +668 -0
  4. package/definations/person.pes.jsonschema.json +84 -0
  5. package/definations/salesinvoice.si.jsonschema.json +84 -0
  6. package/dist/app.module.ts +14 -0
  7. package/dist/constant.js +6 -0
  8. package/dist/constant.js.map +1 -0
  9. package/dist/createproject.js +123 -0
  10. package/dist/createproject.js.map +1 -0
  11. package/dist/generate.js +225 -0
  12. package/dist/generate.js.map +1 -0
  13. package/dist/index.js +65 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/libs.js +15 -0
  16. package/dist/libs.js.map +1 -0
  17. package/dist/processors/jsonschemabuilder.js +116 -0
  18. package/dist/processors/jsonschemabuilder.js.map +1 -0
  19. package/dist/type.js +13 -0
  20. package/dist/type.js.map +1 -0
  21. package/package.json +44 -0
  22. package/sampleconfig.json +6 -0
  23. package/src/constant.ts +2 -0
  24. package/src/createproject.ts +96 -0
  25. package/src/generate.ts +254 -0
  26. package/src/index.ts +73 -0
  27. package/src/libs.ts +14 -0
  28. package/src/processors/jsonschemabuilder.ts +137 -0
  29. package/src/type.ts +42 -0
  30. package/templates/SimpleAppClient.eta +111 -0
  31. package/templates/SimpleAppController.eta +66 -0
  32. package/templates/SimpleAppService.eta +134 -0
  33. package/templates/app.module.eta +15 -0
  34. package/templates/app.vue.eta +21 -0
  35. package/templates/basic/apiclient.eta +56 -0
  36. package/templates/basic/apischema.eta +29 -0
  37. package/templates/basic/backend.config.eta +1 -0
  38. package/templates/basic/beforesave.eta +7 -0
  39. package/templates/basic/controller.eta +103 -0
  40. package/templates/basic/controller2.eta +86 -0
  41. package/templates/basic/frontend.config.eta +1 -0
  42. package/templates/basic/jsonschema.eta +6 -0
  43. package/templates/basic/model-converter.etabackup +21 -0
  44. package/templates/basic/model.eta +35 -0
  45. package/templates/basic/module.eta +20 -0
  46. package/templates/basic/readme.eta +3 -0
  47. package/templates/basic/service.eta +32 -0
  48. package/templates/basic/service.etabackupe +106 -0
  49. package/templates/basic/type.eta +27 -0
  50. package/templates/basic/type.etabackup +23 -0
  51. package/templates/basic/uischema.eta +13 -0
  52. package/templates/nest.env.eta +5 -0
  53. package/templates/nest.main.eta +20 -0
  54. package/templates/nuxt.env.eta +2 -0
  55. package/tsconfig.json +17 -0
@@ -0,0 +1,103 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * You can add your additional custom api in this file.
4
+ * CODE GENERATOR WONT OVERRIDE THIS FILE
5
+ */
6
+ import {
7
+ Controller,
8
+ Get,
9
+ Put,
10
+ Post,
11
+ Delete,
12
+ Body,
13
+ Param,
14
+ Type,
15
+ } from '@nestjs/common';
16
+ import { SimpleAppController } from '../../class/SimpleAppController';
17
+ import { <%= it.typename %>Service } from './<%= it.doctype %>.service';
18
+ import * as <%= it.doctype %>type from './<%= it.doctype %>.type';
19
+ import * as <%= it.doctype %>apischema from './<%= it.doctype %>.apischema';
20
+ import { ApiTags, ApiBody, ApiResponse,ApiOperation } from '@nestjs/swagger';
21
+
22
+ const doctype = '<%= it.doctype %>'.toUpperCase();
23
+ @ApiTags(doctype)
24
+ @Controller(doctype.toLowerCase())
25
+ export class <%= it.typename %>Controller extends SimpleAppController<
26
+ <%= it.typename %>Service,
27
+ <%= it.doctype %>apischema.<%= it.typename %>,
28
+ <%= it.doctype %>type.<%= it.typename %>
29
+ > {
30
+ constructor(service: <%= it.typename %>Service) {
31
+ super(service);
32
+ }
33
+
34
+ @Get()
35
+ @ApiResponse({
36
+ status: 200,
37
+ description: 'Found',
38
+ type: [<%= it.fullApiSchemaName%>]
39
+ })
40
+ @ApiResponse({ status: 500, description: 'Internal error' })
41
+ @ApiOperation({ operationId: 'runList' })
42
+ async list() {
43
+ return this._list();
44
+ }
45
+
46
+ @Get(':id')
47
+ @ApiResponse({
48
+ status: 200,
49
+ description: 'Founds',
50
+ type: <%= it.fullApiSchemaName%>
51
+ })
52
+ @ApiResponse({ status: 404, description: 'Document not found' })
53
+ @ApiResponse({ status: 500, description: 'Internal error' })
54
+ @ApiOperation({ operationId: 'runFindOne' })
55
+ async findOne(@Param('id') id: string) {
56
+ return await this._findOne(id);
57
+ }
58
+
59
+ @Post()
60
+ @ApiResponse({
61
+ status: 201,
62
+ description: 'success',
63
+ type: <%= it.fullApiSchemaName%>
64
+ })
65
+ @ApiResponse({ status: 400, description: 'bad request' })
66
+ @ApiResponse({ status: 500, description: 'internal error' })
67
+ @ApiBody({ description: 'Data',type:<%= it.fullApiSchemaName%> })
68
+ @ApiOperation({ operationId: 'runCreate' })
69
+ async create(@Body() data: <%= it.fullApiSchemaName%>) {
70
+ return await this._create(data)
71
+ }
72
+
73
+ @Put(':id')
74
+ @ApiResponse({
75
+ status: 200,
76
+ description: 'success',
77
+ })
78
+ @ApiResponse({ status: 404, description: 'Document not found' })
79
+ @ApiResponse({ status: 500, description: 'Internal error' })
80
+ @ApiBody({ description: 'Data',type: <%= it.fullApiSchemaName%> })
81
+ @ApiOperation({ operationId: 'runUpdate' })
82
+ async update(@Param('id') id: string, @Body() data: <%= it.fullApiSchemaName%>) {
83
+ return await this._update(id, data) ;
84
+ }
85
+
86
+ @Delete(':id')
87
+ @ApiResponse({
88
+ status: 200,
89
+ description: 'success',
90
+ type: <%= it.fullApiSchemaName%>
91
+ })
92
+ @ApiResponse({ status: 404, description: 'Document not found' })
93
+ @ApiResponse({ status: 500, description: 'Internal error' })
94
+ @ApiOperation({ operationId: 'runDelete' })
95
+ async delete(@Param('id') id: string) {
96
+ return this._delete(id);
97
+ }
98
+
99
+
100
+ /*****************************customized code begin here *****************************************/
101
+ <%~ it.controllerCode %>
102
+
103
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+ import {
7
+ Controller,
8
+ Get,
9
+ Put,
10
+ Post,
11
+ Delete,
12
+ Body,
13
+ Param,
14
+ Type,
15
+ } from '@nestjs/common';
16
+ import { <%= it.doctype %>Service } from './<%= it.doctype %>.service';
17
+ import * as <%= it.doctype %>type from './<%= it.doctype %>.type';
18
+ import * as <%= it.doctype %>apischema from './<%= it.doctype %>.apischema';
19
+ import { ApiTags, ApiBody, ApiResponse,ApiOperation } from '@nestjs/swagger';
20
+
21
+ const doctype = '<%= it.doctype %>'.toUpperCase();
22
+ @ApiTags(doctype)
23
+ @Controller(doctype.toLowerCase())
24
+ export class <%= it.doctype %>Controller {
25
+ constructor(private readonly service: <%= it.doctype %>Service) {}
26
+
27
+ /********************ok*****************/
28
+ @Get()
29
+ @ApiResponse({
30
+ status: 200,
31
+ description: 'Found',
32
+ })
33
+ @ApiResponse({ status: 500, description: 'Internal error' })
34
+ @ApiOperation({ operationId: 'runList' })
35
+ async list() {
36
+ return this.service.list();
37
+ }
38
+ /********************ok*****************/
39
+ @Get(':id')
40
+ @ApiResponse({ status: 200, description: 'Founds', type: <%= it.fullApiSchemaName %> })
41
+ @ApiResponse({ status: 404, description: 'Document not found' })
42
+ @ApiResponse({ status: 500, description: 'Internal error' })
43
+ @ApiOperation({ operationId: 'runFindOne' })
44
+ async findOne(@Param('id') id: string) {
45
+ const result = await this.service.findById(id)
46
+ return result as <%= it.fullApiSchemaName %>;
47
+ }
48
+
49
+ /********************ok*****************/
50
+ @Post()
51
+ @ApiResponse({ status: 201, description: 'success', type: <%= it.fullApiSchemaName %> })
52
+ @ApiResponse({ status: 400, description: 'bad request' })
53
+ @ApiResponse({ status: 500, description: 'internal error' })
54
+ @ApiBody({ description: 'Data', type: <%= it.fullApiSchemaName %> })
55
+ @ApiOperation({ operationId: 'runCreate' })
56
+ async create(@Body() data: <%= it.fullApiSchemaName %>) {
57
+ //const newdata: <%= it.fullTypeName %> = { ...data };
58
+ const newdata: persontype.Person = {} as persontype.Person; //= { ...data };
59
+ Object.assign(newdata, data); //
60
+ return this.service.setData(newdata).create();
61
+ }
62
+
63
+ /********************ok*****************/
64
+ @Put(':id')
65
+ @ApiResponse({ status: 200, description: 'success', type: <%= it.fullApiSchemaName %> })
66
+ @ApiResponse({ status: 404, description: 'Document not found' })
67
+ @ApiResponse({ status: 500, description: 'Internal error' })
68
+ @ApiBody({ description: 'Data', type: <%= it.fullApiSchemaName %> })
69
+ @ApiOperation({ operationId: 'runUpdate' })
70
+ async update(@Param('id') id: string, @Body() data: <%= it.fullApiSchemaName %>) {
71
+ //const newdata: <%= it.fullTypeName %> = { ...data };
72
+ const newdata: persontype.Person = {} as persontype.Person; //= { ...data };
73
+ Object.assign(newdata, data); //
74
+ return this.service.findIdThenUpdate(id, newdata);
75
+ }
76
+
77
+ /********************ok*****************/
78
+ @Delete(':id')
79
+ @ApiResponse({ status: 200, description: 'success', type: <%= it.fullApiSchemaName %> })
80
+ @ApiResponse({ status: 404, description: 'Document not found' })
81
+ @ApiResponse({ status: 500, description: 'Internal error' })
82
+ @ApiOperation({ operationId: 'runDelete' })
83
+ async delete(@Param('id') id: string) {
84
+ return this.service.findIdThenDelete(id);
85
+ }
86
+ }
@@ -0,0 +1 @@
1
+ export const API_BASE_URL = useRuntimeConfig().public.API_BASE_URL
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+ export const <%= it.typename%>JsonSchema = <%~ JSON.stringify(it.jsonschema) %>
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+ <% const schema = it.schema %>
7
+ <% const typeclass = it.doctype+'type' %>
8
+ import { Schema } from 'mongoose';
9
+ import { beforeSave } from './<%= it.doctype %>.beforesave';
10
+ import {<%= it.typename%>JsonSchema } from './<%= it.doctype %>.jsonschema'
11
+ import { createMongooseSchema } from 'convert-json-schema-to-mongoose';
12
+ import { <%= it.typename%> } from './<%= it.doctype %>.type';
13
+
14
+ // import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from './<%= it.doctype %>.type';
15
+ const schema1 = <%= it.typename%>JsonSchema
16
+
17
+ const schemasetting = createMongooseSchema(schema1,schema1)
18
+
19
+ export const <%= it.doctype %>MongoSchema = new Schema(schemasetting)
20
+ .post('validate', (doc: <%= it.typename %>) => beforeSave(doc))
21
+ .pre('save', () => {});
@@ -0,0 +1,35 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ * ALL FIELDS not compulsory, it control at microservice level using AJV
6
+ */
7
+
8
+ <% const schema = it.schema %>
9
+ <% const typeclass = it.doctype+'type' %>
10
+ import { Schema } from 'mongoose';
11
+ import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from './<%= it.doctype %>.type';
12
+ import { beforeSave } from './<%= it.doctype %>.beforesave';
13
+
14
+
15
+ const schemasetting = {
16
+
17
+ <%Object.keys(it.schema).forEach(function(key) { %>
18
+
19
+ <% if(key == '_id'){%>
20
+ //<%= key %>: {type:'string', required:false} //force _id not inside
21
+ <% } else if(typeof schema[key] == 'string') {%>
22
+ <%= key %>: {type: <<%=schema[key]%>>{}, required:false}, //object
23
+ <% }else if( Array.isArray( schema[key])){%>
24
+ <%= key %>: [{type: <<%=schema[key]%>>{}, required:false}], //custom array
25
+ <% }else if( schema[key].type == 'array'){%>
26
+ <%= key %>: [{type: <%= schema[key].item.type %>, required:false}] //basic array
27
+ <% }else{%>
28
+ <%= key %>: {type: <%= capitalizeFirstLetter(schema[key].type) %>, required:false}, //field
29
+ <% } %>
30
+ <%}) %>
31
+ };
32
+
33
+ export const <%= it.doctype %>MongoSchema = new Schema(schemasetting)
34
+ .post('validate', (doc: <%= it.typename %>) => beforeSave(doc))
35
+ .pre('save', () => {});
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+ import { Module } from '@nestjs/common';
7
+ import { <%= it.typename %>Controller } from './<%= it.doctype %>.controller';
8
+ import { <%= it.typename %>Service } from './<%= it.doctype %>.service';
9
+ import { MongooseModule } from '@nestjs/mongoose';
10
+ import { <%= it.doctype %>MongoSchema } from './<%= it.doctype %>.model';
11
+ @Module({
12
+ imports: [
13
+ MongooseModule.forFeature([
14
+ { name: '<%= it.name %>', schema: <%= it.doctype %>MongoSchema },
15
+ ]),
16
+ ],
17
+ controllers: [<%= it.typename %>Controller],
18
+ providers: [<%= it.typename %>Service],
19
+ })
20
+ export class <%= it.typename %>Module {}
@@ -0,0 +1,3 @@
1
+ Installation
2
+ 1. copy `import { <%= it.typename%>Module } from './docs/<%= it.doctype%>/<%= it.doctype%>.module';` into src/app.module.ts
3
+ 2. append `<%= it.typename%>Module` into array `imports`
@@ -0,0 +1,32 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+ import { Injectable } from '@nestjs/common';
7
+ import { InjectModel } from '@nestjs/mongoose';
8
+ import { Model } from 'mongoose';
9
+ import {<%= it.typename%>JsonSchema } from './<%= it.doctype %>.jsonschema'
10
+ import { SimpleAppService } from '../../class/SimpleAppService';
11
+ import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from './<%= it.doctype %>.type';
12
+
13
+
14
+ @Injectable()
15
+ export class <%= it.typename %>Service extends SimpleAppService<<%= it.typename %>> {
16
+ constructor(@InjectModel('<%= it.name %>') mydoc: Model<<%= it.typename %>>,
17
+ ) {
18
+ super(mydoc);
19
+ this.setSchema(<%= it.typename%>JsonSchema)
20
+ }
21
+
22
+
23
+ /*****************************customized frontend + backend code*****************************************/
24
+
25
+
26
+ <%~ it.bothEndCode %>
27
+
28
+ /*****************************customized backend only code*****************************************/
29
+
30
+ <%~ it.backEndCode %>
31
+
32
+ }
@@ -0,0 +1,106 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectModel } from '@nestjs/mongoose';
3
+ import { Model } from 'mongoose';
4
+ import Ajv from 'ajv';
5
+ import addFormats from 'ajv-formats';
6
+ import addKeyword from "ajv-keywords";
7
+
8
+
9
+ import * as <%= it.doctype %>type from './<%= it.doctype %>.type';
10
+ import * as <%= it.doctype %>apischema from './<%= it.doctype %>.apischema';
11
+
12
+ //import { <%= it.typename %> } from './<%= it.doctype %>.type';
13
+ //import { <%= it.apiSchemaName %> } from './<%= it.doctype %>.apischema';
14
+ import {
15
+ NotFoundException,
16
+ InternalServerErrorException,
17
+ } from '@nestjs/common/exceptions';
18
+ @Injectable()
19
+ export class <%= it.doctype %>Service {
20
+ private jsonschema = <%~ JSON.stringify(it.jsonschema) %>;
21
+
22
+ constructor(
23
+ @InjectModel('<%= it.name %>') private readonly doc: Model<<%= it.fullTypeName %>>,
24
+ ) {}
25
+
26
+ getSchema() {
27
+ return this.doc.schema.obj;
28
+ }
29
+ async list() {
30
+ try {
31
+ const products = await this.doc.find();
32
+ const productlist = products.map((p: <%= it.fullTypeName %>) => {
33
+ return p;
34
+ });
35
+ // console.log(products);
36
+ return productlist;
37
+ } catch (err) {
38
+ throw new InternalServerErrorException(err.message);
39
+ }
40
+ }
41
+ async findById(id: string) {
42
+ let data;
43
+
44
+ try {
45
+ data = await this.doc.findById(id);
46
+ } catch (err) {
47
+ //error
48
+ throw new InternalServerErrorException(err.message);
49
+ }
50
+
51
+ if (!data) {
52
+ //data not found
53
+ throw new NotFoundException('Document Not found:');
54
+ }
55
+ return data;
56
+ }
57
+ async create(data: <%= it.fullTypeName %>) {
58
+ let result;
59
+
60
+ try {
61
+ delete data._id;
62
+ this.validateData(data);
63
+ const newdoc = new this.doc(data);
64
+ result = await newdoc.save();
65
+ } catch (err) {
66
+ throw new InternalServerErrorException(err.message);
67
+ }
68
+ return result as <%= it.fullTypeName %>;
69
+ }
70
+ async update(id: string, data: <%= it.fullTypeName %>) {
71
+ const existingdata = await this.findById(id);
72
+ try {
73
+ this.validateData(data);
74
+ const result = await existingdata.updateOne(data);
75
+ return result;
76
+ } catch (err) {
77
+ throw new InternalServerErrorException(err.message);
78
+ }
79
+ }
80
+ async delete(id: string) {
81
+ const data = await this.findById(id);
82
+ try {
83
+ const deleteresult = await this.doc.findByIdAndDelete(id);
84
+ return deleteresult;
85
+ } catch (err) {
86
+ throw new InternalServerErrorException(err.message);
87
+ }
88
+ }
89
+
90
+ validateData(data: <%=it.doctype %>type.<%= it.typename %>) {
91
+ const ajv = new Ajv({ allErrors: true });
92
+ addFormats(ajv);
93
+ ajv.addKeyword('example');
94
+
95
+ const validate = ajv.compile(this.jsonschema);
96
+ const valid = validate(data);
97
+ if (!valid) {
98
+ console.log(validate.errors);
99
+ const erromsg: string[] = [];
100
+ for (let i = 0; i < validate.errors.length; i++) {
101
+ erromsg.push(validate.errors[i].message);
102
+ }
103
+ throw new InternalServerErrorException(erromsg.join('\n'));
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This file was automatically generated by simpleapp generator.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and regenerate this file.
5
+ */
6
+
7
+
8
+ <%Object.keys(it.models).forEach(function(prop){ %>
9
+ <% let schema = it.models[prop] %>
10
+ export type <%= prop %> = {
11
+
12
+ <%Object.keys(schema.model).forEach(function(key){ %>
13
+ <% const obj = schema.model[key] %>
14
+ <% if(typeof obj == 'string') {%>
15
+ <%= key %>?: <%= obj %>; //child object
16
+ <% }else if( Array.isArray( obj)){%>
17
+ <%= key %>?: <%= obj[0] %>[]; //array
18
+ <% }else if( obj.type == 'array'){%>
19
+ <%= key %>?: <%= obj.items.type %>[]; //array
20
+ <% }else{%>
21
+ <%= key %> <% if(!obj.required || obj.required==false){%>?<%}%>: <%= obj.type %>; // <%~ JSON.stringify(obj) %>
22
+ <% } %>
23
+ <%})%>
24
+
25
+ }
26
+ <%})%>
27
+
@@ -0,0 +1,23 @@
1
+ <%Object.keys(it.models).forEach(function(prop){ %>
2
+ <% let schema = it.models[prop] %>
3
+ export type <%= prop %> = {
4
+ <% if(it.apiSchemaName == prop ) {%>
5
+ _id?: string;
6
+ doctype?: string;
7
+ <% } %>
8
+ <%Object.keys(schema.model).forEach(function(key){ %>
9
+ <% const obj = schema.model[key] %>
10
+ <% if(typeof obj == 'string') {%>
11
+ <%= key %>?: <%= obj %>; //child object
12
+ <% }else if( Array.isArray( obj)){%>
13
+ <%= key %>?: <%= obj[0] %>[]; //array
14
+ <% }else if( obj.type == 'array'){%>
15
+ <%= key %>?: <%= obj.items.type %>[]; //array
16
+ <% }else{%>
17
+ <%= key %> <% if(!obj.required || obj.required==false){%>?<%}%>: <%= obj.type %>; // <%~ JSON.stringify(obj) %>
18
+ <% } %>
19
+ <%})%>
20
+
21
+ }
22
+ <%})%>
23
+
@@ -0,0 +1,13 @@
1
+ export <%= it.typename %>UiSchema <%= it.typename %> = {
2
+ id: {type: "string",format:"text",title:"ID"},
3
+ doctype: {type: "string",format:"text",title:"ID"},
4
+ <%Object.keys(it.schema).forEach(function(prop) { %>
5
+ <%=prop %>: {
6
+ <% Object.keys(it.schema[prop]).forEach(function(fkey){ %>
7
+ <%=fkey %>: {type: "<%= it.schema[prop][fkey].datatype %>;",format:"<%= it.schema[prop][fkey].type %>;",title:"<%= it.schema[prop][fkey].title %>;"},
8
+
9
+
10
+ <% }) %>
11
+ };
12
+ <%}) %>
13
+ };
@@ -0,0 +1,5 @@
1
+ MONGODB_URL='mongodb://<user>:<pass>@<host>:<port>/<db>?authMechanism=DEFAULT'
2
+ HTTP_PORT=8000
3
+ PROJECT_NAME='SimpleApp Demo1'
4
+ PROJECT_DESCRIPTION='Try CRUD'
5
+ PROJECT_Version='1.0.0'
@@ -0,0 +1,20 @@
1
+ import { NestFactory } from '@nestjs/core';
2
+ import { AppModule } from './app.module';
3
+ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
4
+
5
+ async function bootstrap() {
6
+ const app = await NestFactory.create(AppModule);
7
+ app.enableCors();
8
+ const config = new DocumentBuilder()
9
+ .setTitle(process.env.PROJECT_NAME)
10
+ .setDescription(process.env.PROJECT_DESCRIPTION)
11
+ .setVersion(process.env.PROJECT_VERSION)
12
+ .build();
13
+ const document = SwaggerModule.createDocument(app, config);
14
+ SwaggerModule.setup('api', app, document, {
15
+ swaggerOptions: { showExtensions: true },
16
+ });
17
+
18
+ await app.listen(process.env.HTTP_PORT); //listen which port
19
+ }
20
+ bootstrap();
@@ -0,0 +1,2 @@
1
+ PORT=8800
2
+ SIMPLEAPP_BACKEND_URL=http://localhost:8000
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "outDir": "dist",
5
+ "strict": true,
6
+ "target": "es2017",
7
+ "module": "commonjs",
8
+ "sourceMap": true,
9
+ "esModuleInterop": true,
10
+ "moduleResolution": "node",
11
+
12
+ "strictNullChecks": false,
13
+ "noImplicitAny": false,
14
+ "strictBindCallApply": false,
15
+ "paths": {"@": ["./"]}
16
+ }
17
+ }