generator-nokode 1.0.0
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/README.md +214 -0
- package/generators/app/index.js +116 -0
- package/generators/app/templates/.gradle/9.0.0/checksums/checksums.lock +0 -0
- package/generators/app/templates/.gradle/9.0.0/fileChanges/last-build.bin +0 -0
- package/generators/app/templates/.gradle/9.0.0/fileHashes/fileHashes.lock +0 -0
- package/generators/app/templates/.gradle/9.0.0/gc.properties +0 -0
- package/generators/app/templates/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/generators/app/templates/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/generators/app/templates/.gradle/vcs-1/gc.properties +0 -0
- package/generators/app/templates/01-code/NokodeSampleApplication.java +13 -0
- package/generators/app/templates/01-code/config/AuthConfig.java +10 -0
- package/generators/app/templates/01-code/config/CloudStorageConfig.java +30 -0
- package/generators/app/templates/01-code/config/MongoConfig.java +43 -0
- package/generators/app/templates/01-code/config/NotificationConfig.java +47 -0
- package/generators/app/templates/01-code/config/PantherCrudBeans.java +33 -0
- package/generators/app/templates/01-code/config/ShedlockConfig.java +24 -0
- package/generators/app/templates/01-code/config/WebConfig.java +38 -0
- package/generators/app/templates/01-code/config/annotations/AppAuth.java +24 -0
- package/generators/app/templates/01-code/config/audit/UserAuditing.java +29 -0
- package/generators/app/templates/01-code/config/constants/PantherCrudConstants.java +24 -0
- package/generators/app/templates/01-code/config/converters/BsonDocumentToJsonNodeConverter.java +31 -0
- package/generators/app/templates/01-code/config/converters/JsonNodeToBsonDocumentConverter.java +32 -0
- package/generators/app/templates/01-code/config/converters/ModuleDefinitionDeserializer.java +25 -0
- package/generators/app/templates/01-code/config/converters/ModulePermissionDefinitionModule.java +16 -0
- package/generators/app/templates/01-code/config/converters/PermissionDefinitionDeserializer.java +25 -0
- package/generators/app/templates/01-code/config/converters/StringToModuleDefinitionConverter.java +26 -0
- package/generators/app/templates/01-code/config/converters/StringToPermissionDefinitionConverter.java +26 -0
- package/generators/app/templates/01-code/config/exception/RestExceptionHandlerService.java +14 -0
- package/generators/app/templates/01-code/config/init/ApplicationInit.java +31 -0
- package/generators/app/templates/01-code/config/init/DataBuilderService.java +22 -0
- package/generators/app/templates/01-code/config/init/UserAndRoleInitService.java +71 -0
- package/generators/app/templates/01-code/config/interceptors/AuthInterceptor.java +25 -0
- package/generators/app/templates/01-code/config/interceptors/CorsFilterConfig.java +28 -0
- package/generators/app/templates/01-code/config/interceptors/LocaleInterceptor.java +26 -0
- package/generators/app/templates/01-code/config/interceptors/RequestContextInterceptor.java +26 -0
- package/generators/app/templates/01-code/config/openapi/OpenAPIConfig.java +48 -0
- package/generators/app/templates/01-code/role/domain/Role.java +21 -0
- package/generators/app/templates/01-code/role/dto/RoleCreateDto.java +31 -0
- package/generators/app/templates/01-code/role/dto/RoleDetailDto.java +31 -0
- package/generators/app/templates/01-code/role/dto/RoleSearchDto.java +30 -0
- package/generators/app/templates/01-code/role/enums/ModuleEnum.java +9 -0
- package/generators/app/templates/01-code/role/enums/PermissionEnum.java +9 -0
- package/generators/app/templates/01-code/role/mapper/RoleCreateDtoMapper.java +19 -0
- package/generators/app/templates/01-code/role/mapper/RoleDetailDtoMapper.java +19 -0
- package/generators/app/templates/01-code/role/mapper/RoleSearchDtoMapper.java +19 -0
- package/generators/app/templates/01-code/role/repository/RoleRepository.java +11 -0
- package/generators/app/templates/01-code/role/service/RoleCrudService.java +36 -0
- package/generators/app/templates/01-code/user/domain/User.java +32 -0
- package/generators/app/templates/01-code/user/dto/EmailLoginDto.java +42 -0
- package/generators/app/templates/01-code/user/dto/ResetEmailPasswordDto.java +31 -0
- package/generators/app/templates/01-code/user/dto/UserCreateDto.java +29 -0
- package/generators/app/templates/01-code/user/dto/UserDetailDto.java +25 -0
- package/generators/app/templates/01-code/user/dto/UserSearchDto.java +25 -0
- package/generators/app/templates/01-code/user/dto/UserSignupDto.java +37 -0
- package/generators/app/templates/01-code/user/mapper/UserCreateDtoMapper.java +19 -0
- package/generators/app/templates/01-code/user/mapper/UserDetailDtoMapper.java +19 -0
- package/generators/app/templates/01-code/user/mapper/UserSearchDtoMapper.java +19 -0
- package/generators/app/templates/01-code/user/mapper/UserSignupDtoMapper.java +21 -0
- package/generators/app/templates/01-code/user/repository/UserRepository.java +10 -0
- package/generators/app/templates/01-code/user/service/UserCrudService.java +70 -0
- package/generators/app/templates/02-test-code/NokodeSampleApplicationTests.java +13 -0
- package/generators/app/templates/03-main-resources/META-INF/additional-spring-configuration-metadata.json +34 -0
- package/generators/app/templates/03-main-resources/application.properties +21 -0
- package/generators/app/templates/build.gradle +104 -0
- package/generators/app/templates/build.sh +7 -0
- package/generators/app/templates/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/generators/app/templates/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/generators/app/templates/gradlew +252 -0
- package/generators/app/templates/gradlew.bat +94 -0
- package/generators/app/templates/settings.gradle +1 -0
- package/generators/base-generator.js +70 -0
- package/generators/constants.js +14 -0
- package/index.js +74 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# generator-nokode
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/generator-nokode)
|
|
4
|
+
[](https://travis-ci.org/thepanther-io/nokode-yo-generator)
|
|
5
|
+
|
|
6
|
+
A Yeoman generator for creating Spring Boot applications with the Nokode framework. This generator scaffolds a complete Spring Boot application with authentication, user management, role-based access control, and MongoDB integration.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🚀 **Spring Boot 3.5.5** with Java 17
|
|
11
|
+
- 🔐 **Authentication & Authorization** with role-based access control
|
|
12
|
+
- 👥 **User Management** with CRUD operations
|
|
13
|
+
- 🗄️ **MongoDB Integration** with Spring Data
|
|
14
|
+
- 📝 **OpenAPI Documentation** with Swagger UI
|
|
15
|
+
- 🛠️ **MapStruct** for object mapping
|
|
16
|
+
- 🔒 **Security** with interceptors and CORS configuration
|
|
17
|
+
- 📊 **Auditing** and logging capabilities
|
|
18
|
+
- 🧪 **Testing** setup with JUnit
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
- Node.js (>= 14.0.0)
|
|
23
|
+
- Java 17
|
|
24
|
+
- Gradle
|
|
25
|
+
- MongoDB
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
First, install [Yeoman](http://yeoman.io) and generator-nokode using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g yo
|
|
33
|
+
npm install -g generator-nokode
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Interactive Mode
|
|
39
|
+
|
|
40
|
+
Run the generator in interactive mode:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
yo nokode
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The generator will prompt you for:
|
|
47
|
+
|
|
48
|
+
- Application name
|
|
49
|
+
- Group ID (e.g., com.example)
|
|
50
|
+
- Java package name (e.g., com.example.myapp)
|
|
51
|
+
- System email address
|
|
52
|
+
|
|
53
|
+
### Command Line Mode
|
|
54
|
+
|
|
55
|
+
You can also provide all parameters via command line:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
yo nokode --appName="MyApp" --groupId="com.example" --packageName="com.example.myapp" --systemEmailAddress="admin@example.com"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Generated Project Structure
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
my-app/
|
|
65
|
+
├── src/
|
|
66
|
+
│ ├── main/
|
|
67
|
+
│ │ ├── java/
|
|
68
|
+
│ │ │ └── com/example/myapp/
|
|
69
|
+
│ │ │ ├── MyAppApplication.java
|
|
70
|
+
│ │ │ ├── config/
|
|
71
|
+
│ │ │ │ ├── AuthConfig.java
|
|
72
|
+
│ │ │ │ ├── MongoConfig.java
|
|
73
|
+
│ │ │ │ ├── WebConfig.java
|
|
74
|
+
│ │ │ │ └── ...
|
|
75
|
+
│ │ │ ├── user/
|
|
76
|
+
│ │ │ │ ├── domain/
|
|
77
|
+
│ │ │ │ ├── dto/
|
|
78
|
+
│ │ │ │ ├── mapper/
|
|
79
|
+
│ │ │ │ ├── repository/
|
|
80
|
+
│ │ │ │ └── service/
|
|
81
|
+
│ │ │ └── role/
|
|
82
|
+
│ │ │ ├── domain/
|
|
83
|
+
│ │ │ ├── dto/
|
|
84
|
+
│ │ │ ├── mapper/
|
|
85
|
+
│ │ │ ├── repository/
|
|
86
|
+
│ │ │ └── service/
|
|
87
|
+
│ │ └── resources/
|
|
88
|
+
│ │ └── application.properties
|
|
89
|
+
│ └── test/
|
|
90
|
+
│ └── java/
|
|
91
|
+
│ └── com/example/myapp/
|
|
92
|
+
│ └── MyAppApplicationTests.java
|
|
93
|
+
├── build.gradle
|
|
94
|
+
├── settings.gradle
|
|
95
|
+
└── gradlew
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
After generation, update the `application.properties` file with your specific configuration:
|
|
101
|
+
|
|
102
|
+
```properties
|
|
103
|
+
# Database Configuration
|
|
104
|
+
spring.data.mongodb.uri=mongodb://localhost:27017/myapp
|
|
105
|
+
|
|
106
|
+
# Server Configuration
|
|
107
|
+
server.port=8080
|
|
108
|
+
|
|
109
|
+
# Security Configuration
|
|
110
|
+
app.security.jwt.secret=your-jwt-secret-key
|
|
111
|
+
app.security.jwt.expiration=86400000
|
|
112
|
+
|
|
113
|
+
# Email Configuration
|
|
114
|
+
app.email.host=smtp.gmail.com
|
|
115
|
+
app.email.port=587
|
|
116
|
+
app.email.username=your-email@gmail.com
|
|
117
|
+
app.email.password=your-app-password
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Running the Application
|
|
121
|
+
|
|
122
|
+
1. Start MongoDB:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
mongod
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
2. Run the application:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
./gradlew bootRun
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
3. Access the application:
|
|
135
|
+
|
|
136
|
+
- API: http://localhost:8080
|
|
137
|
+
- Swagger UI: http://localhost:8080/swagger-ui.html
|
|
138
|
+
|
|
139
|
+
## API Endpoints
|
|
140
|
+
|
|
141
|
+
The generated application includes the following endpoints:
|
|
142
|
+
|
|
143
|
+
### User Management
|
|
144
|
+
|
|
145
|
+
- `POST /api/users` - Create user
|
|
146
|
+
- `GET /api/users` - Get all users
|
|
147
|
+
- `GET /api/users/{id}` - Get user by ID
|
|
148
|
+
- `PUT /api/users/{id}` - Update user
|
|
149
|
+
- `DELETE /api/users/{id}` - Delete user
|
|
150
|
+
|
|
151
|
+
### Role Management
|
|
152
|
+
|
|
153
|
+
- `POST /api/roles` - Create role
|
|
154
|
+
- `GET /api/roles` - Get all roles
|
|
155
|
+
- `GET /api/roles/{id}` - Get role by ID
|
|
156
|
+
- `PUT /api/roles/{id}` - Update role
|
|
157
|
+
- `DELETE /api/roles/{id}` - Delete role
|
|
158
|
+
|
|
159
|
+
### Authentication
|
|
160
|
+
|
|
161
|
+
- `POST /api/auth/login` - User login
|
|
162
|
+
- `POST /api/auth/signup` - User signup
|
|
163
|
+
- `POST /api/auth/reset-password` - Reset password
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
### Running Tests
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
./gradlew test
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Building the Application
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
./gradlew build
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Running with Docker
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
docker-compose up
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
1. Fork the repository
|
|
188
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
189
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
190
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
191
|
+
5. Open a Pull Request
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
196
|
+
|
|
197
|
+
## Support
|
|
198
|
+
|
|
199
|
+
If you have any questions or need help, please:
|
|
200
|
+
|
|
201
|
+
1. Check the [Issues](https://github.com/thepanther-io/nokode-yo-generator/issues) page
|
|
202
|
+
2. Create a new issue if your problem isn't already reported
|
|
203
|
+
3. Contact the maintainers at info@thepanther.io
|
|
204
|
+
|
|
205
|
+
## Changelog
|
|
206
|
+
|
|
207
|
+
### 1.0.0
|
|
208
|
+
|
|
209
|
+
- Initial release
|
|
210
|
+
- Spring Boot 3.5.5 support
|
|
211
|
+
- User and Role management
|
|
212
|
+
- MongoDB integration
|
|
213
|
+
- Authentication and authorization
|
|
214
|
+
- OpenAPI documentation
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import BaseGenerator from '../base-generator.js';
|
|
2
|
+
|
|
3
|
+
export default class NokodeGenerator extends BaseGenerator {
|
|
4
|
+
constructor(args, opts) {
|
|
5
|
+
super(args, opts);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
writing() {
|
|
9
|
+
this._writeGradleFiles();
|
|
10
|
+
this._writeJavaSrcFiles();
|
|
11
|
+
this._writeConfigFiles();
|
|
12
|
+
this._writeMainResourceFiles();
|
|
13
|
+
this._writeJavaTestFiles();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_writeGradleFiles() {
|
|
17
|
+
this._writeDir('./gradle');
|
|
18
|
+
this._writeFile('build.sh');
|
|
19
|
+
this._writeFile('build.gradle');
|
|
20
|
+
this._writeFile('.gitignore');
|
|
21
|
+
this._writeFile('gradlew');
|
|
22
|
+
this._writeFile('gradlew.bat');
|
|
23
|
+
this._writeFile('settings.gradle');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_writeConfigFiles() {
|
|
27
|
+
const files = [
|
|
28
|
+
'WebConfig.java',
|
|
29
|
+
'NotificationConfig.java',
|
|
30
|
+
'MongoConfig.java',
|
|
31
|
+
'AuthConfig.java',
|
|
32
|
+
'CloudStorageConfig.java',
|
|
33
|
+
'ShedlockConfig.java',
|
|
34
|
+
'openapi/OpenAPIConfig.java',
|
|
35
|
+
'interceptors/AuthInterceptor.java',
|
|
36
|
+
'interceptors/LocaleInterceptor.java',
|
|
37
|
+
'interceptors/RequestContextInterceptor.java',
|
|
38
|
+
'interceptors/CorsFilterConfig.java',
|
|
39
|
+
'init/ApplicationInit.java',
|
|
40
|
+
'init/DataBuilderService.java',
|
|
41
|
+
'init/ApplicationInit.java',
|
|
42
|
+
'init/UserAndRoleInitService.java',
|
|
43
|
+
'annotations/AppAuth.java',
|
|
44
|
+
'audit/UserAuditing.java',
|
|
45
|
+
'converters/BsonDocumentToJsonNodeConverter.java',
|
|
46
|
+
'converters/JsonNodeToBsonDocumentConverter.java',
|
|
47
|
+
'converters/ModuleDefinitionDeserializer.java',
|
|
48
|
+
'converters/ModulePermissionDefinitionModule.java',
|
|
49
|
+
'converters/PermissionDefinitionDeserializer.java',
|
|
50
|
+
'converters/StringToModuleDefinitionConverter.java',
|
|
51
|
+
'converters/StringToPermissionDefinitionConverter.java',
|
|
52
|
+
'exception/RestExceptionHandlerService.java',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const relPath = 'config';
|
|
56
|
+
this._writeJavaMainFiles(files, relPath);
|
|
57
|
+
|
|
58
|
+
const configPrefix = `01-code/${relPath}`;
|
|
59
|
+
const destPath = `src/main/java/${this.configData['packageName'].split('.').join('/')}/${relPath}`;
|
|
60
|
+
|
|
61
|
+
this._writeFileWithPaths(`${configPrefix}/PantherCrudBeans.java`, `${destPath}/${this.configData['appNameTitleCase']}Beans.java`);
|
|
62
|
+
this._writeFileWithPaths(
|
|
63
|
+
`${configPrefix}/constants/PantherCrudConstants.java`,
|
|
64
|
+
`${destPath}/constants/${this.configData['appNameTitleCase']}Constants.java`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_writeJavaSrcFiles() {
|
|
69
|
+
const files = [
|
|
70
|
+
'role/domain/Role.java',
|
|
71
|
+
'role/dto/RoleCreateDto.java',
|
|
72
|
+
'role/dto/RoleDetailDto.java',
|
|
73
|
+
'role/dto/RoleSearchDto.java',
|
|
74
|
+
'role/enums/ModuleEnum.java',
|
|
75
|
+
'role/enums/PermissionEnum.java',
|
|
76
|
+
'role/mapper/RoleCreateDtoMapper.java',
|
|
77
|
+
'role/mapper/RoleDetailDtoMapper.java',
|
|
78
|
+
'role/mapper/RoleSearchDtoMapper.java',
|
|
79
|
+
'role/repository/RoleRepository.java',
|
|
80
|
+
'role/service/RoleCrudService.java',
|
|
81
|
+
|
|
82
|
+
'user/domain/User.java',
|
|
83
|
+
'user/dto/UserCreateDto.java',
|
|
84
|
+
'user/dto/UserDetailDto.java',
|
|
85
|
+
'user/dto/UserSignupDto.java',
|
|
86
|
+
'user/dto/EmailLoginDto.java',
|
|
87
|
+
'user/dto/ResetEmailPasswordDto.java',
|
|
88
|
+
'user/mapper/UserCreateDtoMapper.java',
|
|
89
|
+
'user/mapper/UserDetailDtoMapper.java',
|
|
90
|
+
'user/mapper/UserSignupDtoMapper.java',
|
|
91
|
+
'user/repository/UserRepository.java',
|
|
92
|
+
'user/service/UserCrudService.java',
|
|
93
|
+
];
|
|
94
|
+
this._writeJavaMainFiles(files, '');
|
|
95
|
+
const src = `01-code`;
|
|
96
|
+
const dest = `src/main/java/${this.configData['packageName'].split('.').join('/')}`;
|
|
97
|
+
this._writeFileWithPaths(`${src}/NokodeSampleApplication.java`, `${dest}/${this.configData['appNameTitleCase']}Application.java`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_writeJavaTestFiles() {
|
|
101
|
+
const srcPath = `02-test-code`;
|
|
102
|
+
const destPath = `src/test/java/${this.configData['packageName'].split('.').join('/')}`;
|
|
103
|
+
this._writeFileWithPaths(
|
|
104
|
+
`${srcPath}/NokodeSampleApplicationTests.java`,
|
|
105
|
+
`${destPath}/${this.configData['appNameTitleCase']}ApplicationTests.java`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_writeMainResourceFiles() {
|
|
110
|
+
const srcPath = `03-main-resources`;
|
|
111
|
+
const destPath = `src/main/resources`;
|
|
112
|
+
['application.properties', 'META-INF/additional-spring-configuration-metadata.json'].forEach((fileName) =>
|
|
113
|
+
this._writeFileWithPaths(`${srcPath}/${fileName}`, `${destPath}/${fileName}`)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package <%= packageName %>;
|
|
2
|
+
|
|
3
|
+
import org.springframework.boot.SpringApplication;
|
|
4
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
5
|
+
|
|
6
|
+
@SpringBootApplication
|
|
7
|
+
public class <%= appNameTitleCase %>Application {
|
|
8
|
+
|
|
9
|
+
public static void main(String[] args) {
|
|
10
|
+
SpringApplication.run(<%= appNameTitleCase %>Application.class, args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import org.springframework.context.annotation.ComponentScan;
|
|
4
|
+
import org.springframework.context.annotation.Configuration;
|
|
5
|
+
|
|
6
|
+
@Configuration
|
|
7
|
+
@ComponentScan(basePackages = "com.sixsprints.auth")
|
|
8
|
+
public class AuthConfig {
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import org.springframework.beans.factory.annotation.Value;
|
|
4
|
+
import org.springframework.context.annotation.Bean;
|
|
5
|
+
import org.springframework.context.annotation.Configuration;
|
|
6
|
+
import com.sixsprints.cloudservice.dto.Credentials;
|
|
7
|
+
import com.sixsprints.cloudservice.service.CloudStorage;
|
|
8
|
+
import com.sixsprints.cloudservice.service.impl.S3CloudStorage;
|
|
9
|
+
import software.amazon.awssdk.regions.Region;
|
|
10
|
+
|
|
11
|
+
@Configuration
|
|
12
|
+
public class CloudStorageConfig {
|
|
13
|
+
|
|
14
|
+
@Value(value = "${aws.s3.access.key:xxxxxxxxxxxxxxxx}")
|
|
15
|
+
private String accessKey;
|
|
16
|
+
|
|
17
|
+
@Value(value = "${aws.s3.secret.key:xxxxxxxxxxxxxxxx}")
|
|
18
|
+
private String secretKey;
|
|
19
|
+
|
|
20
|
+
@Value(value = "${aws.s3.region:ap-south-1}")
|
|
21
|
+
private String region;
|
|
22
|
+
|
|
23
|
+
@Bean
|
|
24
|
+
CloudStorage cloudStorage() {
|
|
25
|
+
Credentials cred = Credentials.builder().accessId(accessKey).secretKey(secretKey)
|
|
26
|
+
.region(Region.of(region)).build();
|
|
27
|
+
return new S3CloudStorage(cred);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import java.util.List;
|
|
4
|
+
|
|
5
|
+
import org.springframework.context.annotation.Configuration;
|
|
6
|
+
import org.springframework.core.convert.converter.Converter;
|
|
7
|
+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
|
|
8
|
+
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
|
9
|
+
|
|
10
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
11
|
+
import com.sixsprints.core.config.ParentMongoConfig;
|
|
12
|
+
|
|
13
|
+
import <%= packageName %>.config.converters.BsonDocumentToJsonNodeConverter;
|
|
14
|
+
import <%= packageName %>.config.converters.JsonNodeToBsonDocumentConverter;
|
|
15
|
+
import <%= packageName %>.config.converters.StringToModuleDefinitionConverter;
|
|
16
|
+
import <%= packageName %>.config.converters.StringToPermissionDefinitionConverter;
|
|
17
|
+
import lombok.RequiredArgsConstructor;
|
|
18
|
+
|
|
19
|
+
@Configuration
|
|
20
|
+
@EnableMongoRepositories(basePackages = { "com.sixsprints.core", "com.sixsprints.auth", "<%= packageName %>" })
|
|
21
|
+
@EnableMongoAuditing
|
|
22
|
+
@RequiredArgsConstructor
|
|
23
|
+
public class MongoConfig extends ParentMongoConfig {
|
|
24
|
+
|
|
25
|
+
private final ObjectMapper objectMapper;
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
protected List<Converter<?, ?>> converters() {
|
|
29
|
+
List<Converter<?, ?>> converters = super.converters();
|
|
30
|
+
converters.add(new StringToModuleDefinitionConverter());
|
|
31
|
+
converters.add(new StringToPermissionDefinitionConverter());
|
|
32
|
+
|
|
33
|
+
converters.add(new BsonDocumentToJsonNodeConverter(objectMapper));
|
|
34
|
+
converters.add(new JsonNodeToBsonDocumentConverter(objectMapper));
|
|
35
|
+
return converters;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
protected boolean autoIndexCreation() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import com.sixsprints.notification.dto.MessageAuthDto;
|
|
4
|
+
import com.sixsprints.notification.service.NotificationService;
|
|
5
|
+
import com.sixsprints.notification.service.impl.EmailServiceSmtp;
|
|
6
|
+
import org.springframework.beans.factory.annotation.Value;
|
|
7
|
+
import org.springframework.context.annotation.Bean;
|
|
8
|
+
import org.springframework.context.annotation.Configuration;
|
|
9
|
+
|
|
10
|
+
@Configuration
|
|
11
|
+
public class NotificationConfig {
|
|
12
|
+
|
|
13
|
+
@Value(value = "${email.from}")
|
|
14
|
+
private String from;
|
|
15
|
+
|
|
16
|
+
@Value(value = "${email.from.address}")
|
|
17
|
+
private String fromEmail;
|
|
18
|
+
|
|
19
|
+
@Value(value = "${email.hostname}")
|
|
20
|
+
private String hostName;
|
|
21
|
+
|
|
22
|
+
@Value(value = "${email.username}")
|
|
23
|
+
private String username;
|
|
24
|
+
|
|
25
|
+
@Value(value = "${email.password}")
|
|
26
|
+
private String password;
|
|
27
|
+
|
|
28
|
+
@Value(value = "${email.ssl.enabled}")
|
|
29
|
+
private boolean sslEnabled;
|
|
30
|
+
|
|
31
|
+
MessageAuthDto emailAuth() {
|
|
32
|
+
return MessageAuthDto.builder()
|
|
33
|
+
.from(from)
|
|
34
|
+
.fromEmail(fromEmail)
|
|
35
|
+
.hostName(hostName)
|
|
36
|
+
.username(username)
|
|
37
|
+
.password(password)
|
|
38
|
+
.sslEnabled(sslEnabled)
|
|
39
|
+
.build();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Bean("emailNotificationService")
|
|
43
|
+
NotificationService emailService() {
|
|
44
|
+
return new EmailServiceSmtp(emailAuth());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import org.springframework.context.annotation.Configuration;
|
|
4
|
+
|
|
5
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
6
|
+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
7
|
+
import com.sixsprints.core.config.ParentBeans;
|
|
8
|
+
|
|
9
|
+
import <%= packageName %>.config.constants.<%= appNameTitleCase %>Constants;
|
|
10
|
+
import <%= packageName %>.config.converters.ModulePermissionDefinitionModule;
|
|
11
|
+
|
|
12
|
+
@Configuration
|
|
13
|
+
public class <%= appNameTitleCase %>Beans extends ParentBeans {
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
protected String defaultShortDateFormat() {
|
|
17
|
+
return <%= appNameTitleCase %>Constants.DEFAULT_DATE_FORMAT;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
protected String defaultDateFormat() {
|
|
22
|
+
return <%= appNameTitleCase %>Constants.DEFAULT_DATE_TIME_FORMAT;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
protected ObjectMapper mapper() {
|
|
27
|
+
ObjectMapper mapper = super.mapper();
|
|
28
|
+
mapper.registerModule(new JavaTimeModule());
|
|
29
|
+
mapper.registerModule(new ModulePermissionDefinitionModule());
|
|
30
|
+
return mapper;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import org.springframework.beans.factory.annotation.Value;
|
|
4
|
+
import org.springframework.context.annotation.Bean;
|
|
5
|
+
import org.springframework.context.annotation.Configuration;
|
|
6
|
+
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
7
|
+
import com.mongodb.client.MongoClient;
|
|
8
|
+
import net.javacrumbs.shedlock.core.LockProvider;
|
|
9
|
+
import net.javacrumbs.shedlock.provider.mongo.MongoLockProvider;
|
|
10
|
+
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
|
|
11
|
+
|
|
12
|
+
@Configuration
|
|
13
|
+
@EnableScheduling
|
|
14
|
+
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
|
|
15
|
+
public class ShedlockConfig {
|
|
16
|
+
|
|
17
|
+
@Value(value = "${spring.data.mongodb.database}")
|
|
18
|
+
private String databaseName;
|
|
19
|
+
|
|
20
|
+
@Bean
|
|
21
|
+
LockProvider lockProvider(MongoClient mongo) {
|
|
22
|
+
return new MongoLockProvider(mongo.getDatabase(databaseName));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package <%= packageName %>.config;
|
|
2
|
+
|
|
3
|
+
import org.springframework.context.annotation.Bean;
|
|
4
|
+
import org.springframework.context.annotation.Configuration;
|
|
5
|
+
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
6
|
+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
7
|
+
|
|
8
|
+
import com.sixsprints.core.interceptor.ClearAllContextInterceptor;
|
|
9
|
+
|
|
10
|
+
import <%= packageName %>.config.interceptors.AuthInterceptor;
|
|
11
|
+
import <%= packageName %>.config.interceptors.LocaleInterceptor;
|
|
12
|
+
import <%= packageName %>.config.interceptors.RequestContextInterceptor;
|
|
13
|
+
import lombok.RequiredArgsConstructor;
|
|
14
|
+
|
|
15
|
+
@Configuration
|
|
16
|
+
@RequiredArgsConstructor
|
|
17
|
+
public class WebConfig implements WebMvcConfigurer {
|
|
18
|
+
|
|
19
|
+
private final AuthInterceptor authInterceptor;
|
|
20
|
+
|
|
21
|
+
private final RequestContextInterceptor requestContextInterceptor;
|
|
22
|
+
|
|
23
|
+
private final LocaleInterceptor localeInterceptor;
|
|
24
|
+
|
|
25
|
+
@Bean
|
|
26
|
+
ClearAllContextInterceptor clearAllContextInterceptor() {
|
|
27
|
+
return new ClearAllContextInterceptor();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public void addInterceptors(InterceptorRegistry registry) {
|
|
32
|
+
registry.addInterceptor(clearAllContextInterceptor());
|
|
33
|
+
registry.addInterceptor(localeInterceptor);
|
|
34
|
+
registry.addInterceptor(requestContextInterceptor);
|
|
35
|
+
registry.addInterceptor(authInterceptor);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package <%= packageName %>.config.annotations;
|
|
2
|
+
|
|
3
|
+
import java.lang.annotation.ElementType;
|
|
4
|
+
import java.lang.annotation.Retention;
|
|
5
|
+
import java.lang.annotation.RetentionPolicy;
|
|
6
|
+
import java.lang.annotation.Target;
|
|
7
|
+
|
|
8
|
+
import com.sixsprints.core.auth.Authenticated;
|
|
9
|
+
|
|
10
|
+
import <%= packageName %>.role.enums.ModuleEnum;
|
|
11
|
+
import <%= packageName %>.role.enums.PermissionEnum;
|
|
12
|
+
|
|
13
|
+
@Authenticated
|
|
14
|
+
@Retention(RetentionPolicy.RUNTIME)
|
|
15
|
+
@Target({ ElementType.METHOD, ElementType.TYPE })
|
|
16
|
+
public @interface AppAuth {
|
|
17
|
+
|
|
18
|
+
boolean required() default true;
|
|
19
|
+
|
|
20
|
+
ModuleEnum module() default ModuleEnum.ANY;
|
|
21
|
+
|
|
22
|
+
PermissionEnum permission() default PermissionEnum.ANY;
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package <%= packageName %>.config.audit;
|
|
2
|
+
|
|
3
|
+
import java.util.Optional;
|
|
4
|
+
import org.springframework.data.domain.AuditorAware;
|
|
5
|
+
import org.springframework.stereotype.Component;
|
|
6
|
+
import <%= packageName %>.config.constants.<%= appNameTitleCase %>Constants;
|
|
7
|
+
import <%= packageName %>.user.domain.User;
|
|
8
|
+
import com.sixsprints.core.utils.ApplicationContext;
|
|
9
|
+
|
|
10
|
+
@Component
|
|
11
|
+
public class UserAuditing implements AuditorAware<String> {
|
|
12
|
+
|
|
13
|
+
public static User getCurrentUser() {
|
|
14
|
+
User user = ApplicationContext.getCurrentUser();
|
|
15
|
+
return user == null ? <%= appNameTitleCase %>Constants.SYSTEM_USER : user;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static String getCurrentUserId() {
|
|
19
|
+
User user = getCurrentUser();
|
|
20
|
+
return user.authId();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
public Optional<String> getCurrentAuditor() {
|
|
25
|
+
String id = getCurrentUserId();
|
|
26
|
+
return Optional.of(id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package <%= packageName %>.config.constants;
|
|
2
|
+
|
|
3
|
+
import java.util.HashMap;
|
|
4
|
+
import java.util.Map;
|
|
5
|
+
|
|
6
|
+
import <%= packageName %>.role.domain.Role;
|
|
7
|
+
import <%= packageName %>.user.domain.User;
|
|
8
|
+
|
|
9
|
+
public interface <%= appNameTitleCase %>Constants {
|
|
10
|
+
|
|
11
|
+
String AUTH_TOKEN = "X-AUTH-TOKEN";
|
|
12
|
+
String API_PREFIX = "/api/v1";
|
|
13
|
+
|
|
14
|
+
String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
|
|
15
|
+
String DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss";
|
|
16
|
+
String DEFAULT_TIMEZONE = "UTC";
|
|
17
|
+
|
|
18
|
+
String ADMIN_ROLE = "admin";
|
|
19
|
+
String USER_ROLE = "user";
|
|
20
|
+
|
|
21
|
+
Map<String, Role> ROLES = new HashMap<>();
|
|
22
|
+
User SYSTEM_USER = User.builder().email("<%= systemEmailAddress %>").build();
|
|
23
|
+
|
|
24
|
+
}
|