Skip to content

Commit f0f3089

Browse files
authored
Merge pull request #24 from Onix-Systems/feature/json-api
Feature/json api
2 parents 3d242ab + 2985003 commit f0f3089

File tree

391 files changed

+5820
-1088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+5820
-1088
lines changed

generators/app/dependencies/dependencies.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"mongodb": {
33
"general": {
4-
"mongoose": "5.10.17",
4+
"mongoose": "5.11.15",
55
"@nestjs/mongoose": "7.1.2",
6-
"mongodb": "3.6.3"
6+
"mongodb": "4.1.0"
77
},
88
"dev": { "@types/mongoose": "5.10.2" }
99
},
@@ -14,5 +14,12 @@
1414
"typeorm": "0.2.30"
1515
},
1616
"dev": {}
17+
},
18+
"postgresql": {
19+
"general": {
20+
"pg": "8.7.1",
21+
"@nestjs/typeorm": "7.1.5"
22+
},
23+
"dev": {}
1724
}
1825
}

generators/app/questions/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module.exports = [
33
type: 'list',
44
name: 'db',
55
message: 'Choose db for your api.(Sql - Typeorm, Mongo - Mongoose)',
6-
choices: ['Mongodb', 'Mysql'],
6+
choices: ['Mongodb', 'Mysql', 'Postgresql'],
77
},
88
]

generators/app/questions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const mailer = require('./mailer');
1111
const socket = require('./socket');
1212
const additionalMailerQuestions = require('./additionalMailerQuestions');
1313
const dependencies = require('./dependenciesVersions');
14+
const jsonapi = require('./jsonapi');
1415

1516
module.exports = {
1617
packageManager,
@@ -30,4 +31,5 @@ module.exports = {
3031
additionalQuestions: additionalMailerQuestions,
3132
},
3233
socket,
34+
jsonapi,
3335
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = [
2+
{
3+
type: 'list',
4+
name: 'wantedJsonApi',
5+
message: 'Add json:api',
6+
choices: ['Yes', 'No'],
7+
},
8+
]

generators/app/steps/prompting.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ module.exports = {
4545
);
4646
},
4747

48+
askAboutJsonApi() {
49+
askQuestions.call(this, 'JSON:API', questions.jsonapi, this.async())
50+
},
51+
4852
askAboutDatabase() {
4953
askQuestions.call(this, 'Database', questions.db, this.async());
5054
},

generators/app/templates/package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
"rxjs": "6.6.3",
4040
"@nestjs/swagger": "4.6.1",
4141
"swagger-ui-express": "4.1.4",
42-
"open": "7.2.1"
42+
"open": "7.2.1",
43+
"jsonapi-serializer": "3.6.7",
44+
"lodash": "4.17.21",
45+
"nest-router": "1.0.9"
4346
},
4447
"devDependencies": {
4548
"@nestjs/cli": "7.5.1",
@@ -64,7 +67,9 @@
6467
"ts-loader": "6.2.2",
6568
"ts-node": "8.10.2",
6669
"tsconfig-paths": "3.9.0",
67-
"typescript": "4.0.3"
70+
"typescript": "4.0.3",
71+
"@types/jsonapi-serializer": "3.6.4",
72+
"@types/lodash": "4.14.168"
6873
},
6974
"jest": {
7075
"moduleNameMapper": {
@@ -77,7 +82,9 @@
7782
"^@dto(.*)$": "<rootDir>/dto$1",
7883
"^@responses(.*)$": "<rootDir>/responses$1",
7984
"^@interceptors(.*)$": "<rootDir>/interceptors$1",
80-
"^@decorators(.*)$": "<rootDir>/decorators$1"
85+
"^@decorators(.*)$": "<rootDir>/decorators$1",
86+
"^@v1(.*)$": "<rootDir>/src/routes/v1$1",
87+
"^@exceptions(.*)$": "<rootDir>/src/exceptions/v1$1"
8188
},
8289
"moduleFileExtensions": [
8390
"js",
@@ -107,7 +114,8 @@
107114
"@dto": "./dist/dto",
108115
"@responses": "./dist/responses",
109116
"@interceptors": "./dist/interceptors",
110-
"@decorators": "./dist/decorators"
117+
"@decorators": "./dist/decorators",
118+
"@utils": "./dist/utils"
111119
},
112120
"husky": {
113121
"hooks": {

generators/app/templates/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"@dto/*": ["./src/dto/*"],
2525
"@responses/*": ["./src/responses/*"],
2626
"@interceptors/*": ["./src/interceptors/*"],
27-
"@decorators/*": ["./src/decorators/*"]
27+
"@decorators/*": ["./src/decorators/*"],
28+
"@v1/*": ["src/routes/v1/*"],
29+
"@exceptions/*": ["./src/exceptions/*"],
30+
"@utils/*": ["./src/utils/*"]
2831
}
2932
}
3033
}

generators/auth/steps/end.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
module.exports = function() {
7-
const { wantedMailer, wantedSocket } = this.options.answers;
7+
const { wantedMailer, wantedSocket, wantedJsonApi } = this.options.answers;
88

99
if (wantedMailer === 'Yes') {
1010
this.composeWith('nest-js-boilerplate:mailer', {
@@ -17,4 +17,10 @@
1717
answers: this.options.answers,
1818
});
1919
}
20+
21+
if (wantedJsonApi === 'Yes') {
22+
this.composeWith('nest-js-boilerplate:jsonapi', {
23+
answers: this.options.answers,
24+
});
25+
}
2026
};

generators/auth/steps/writing.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module.exports = function() {
2525
const rootFolder = answers.identifier;
2626

2727
this.fs.copyTpl(
28-
this.templatePath(`${authFolder}/src/components/`),
29-
this.destinationPath(`${rootFolder}/src/components/`),
28+
this.templatePath(`${authFolder}/src/routes/`),
29+
this.destinationPath(`${rootFolder}/src/routes/`),
3030
payload,
3131
);
3232
this.fs.copyTpl(
@@ -109,6 +109,20 @@ module.exports = function() {
109109
payload,
110110
);
111111
}
112+
if (fs.existsSync(`${fullPathToAuthFolder}/src/constants`)) {
113+
this.fs.copyTpl(
114+
this.templatePath(`${authFolder}/src/constants`),
115+
this.destinationPath(`${rootFolder}/src/constants`),
116+
payload,
117+
);
118+
}
119+
if (fs.existsSync(`${fullPathToAuthFolder}/src/utils`)) {
120+
this.fs.copyTpl(
121+
this.templatePath(`${authFolder}/src/utils`),
122+
this.destinationPath(`${rootFolder}/src/utils`),
123+
payload,
124+
);
125+
}
112126

113127
// DOCKER
114128
if (answers.wantedDocker.toLowerCase() === 'yes') {

generators/auth/templates/mongodb/jwt/src/_main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ValidationPipe, ValidationError } from '@nestjs/common';
66
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
77
import ValidationExceptions from './exceptions/validation.exceptions';
88

9-
import AppModule from './components/app/app.module';
9+
import AppModule from './routes/app/app.module';
1010

1111
import AllExceptionsFilter from './filters/all-exceptions.filter';
1212

0 commit comments

Comments
 (0)