@solidstarters/solid-core 1.2.1 → 1.2.2
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/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +17 -0
- package/dist/cli.js.map +1 -0
- package/dist/decorators/active-user.decorator.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/solid-core-cli-db.module.d.ts +3 -0
- package/dist/solid-core-cli-db.module.d.ts.map +1 -0
- package/dist/solid-core-cli-db.module.js +44 -0
- package/dist/solid-core-cli-db.module.js.map +1 -0
- package/dist/solid-core-cli.module.d.ts +3 -0
- package/dist/solid-core-cli.module.d.ts.map +1 -0
- package/dist/solid-core-cli.module.js +45 -0
- package/dist/solid-core-cli.module.js.map +1 -0
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +7 -5
- package/dist/solid-core.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/winston.logger.d.ts +19 -0
- package/dist/winston.logger.d.ts.map +1 -0
- package/dist/winston.logger.js +106 -0
- package/dist/winston.logger.js.map +1 -0
- package/logs/application.log +1855 -0
- package/logs/error.log +0 -0
- package/package.json +44 -22
- package/rebuild.sh +6 -0
- package/src/cli.ts +34 -0
- package/src/index.ts +3 -1
- package/src/solid-core-cli-db.module.ts +62 -0
- package/src/solid-core-cli.module.ts +40 -0
- package/src/solid-core.module.ts +7 -5
- package/src/winston.logger.ts +70 -0
package/logs/error.log
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"solidCore": "dist/cli.js"
|
|
13
|
+
},
|
|
11
14
|
"scripts": {
|
|
12
15
|
"build": "nest build",
|
|
13
16
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
@@ -30,20 +33,6 @@
|
|
|
30
33
|
"@aws-sdk/client-s3": "^3.637.0",
|
|
31
34
|
"@elasticemail/elasticemail-client": "^4.0.23",
|
|
32
35
|
"@hapi/joi": "^17.1.1",
|
|
33
|
-
"@nestjs/axios": "^3.0.2",
|
|
34
|
-
"@nestjs/cache-manager": "^2.2.2",
|
|
35
|
-
"@nestjs/common": "^10.0.0",
|
|
36
|
-
"@nestjs/core": "^10.0.0",
|
|
37
|
-
"@nestjs/event-emitter": "^2.0.4",
|
|
38
|
-
"@nestjs/jwt": "^10.2.0",
|
|
39
|
-
"@nestjs/mapped-types": "^2.0.4",
|
|
40
|
-
"@nestjs/mongoose": "^10.0.10",
|
|
41
|
-
"@nestjs/passport": "^10.0.3",
|
|
42
|
-
"@nestjs/platform-express": "^10.0.0",
|
|
43
|
-
"@nestjs/serve-static": "^4.0.2",
|
|
44
|
-
"@nestjs/swagger": "^7.2.0",
|
|
45
|
-
"@nestjs/typeorm": "^10.0.1",
|
|
46
|
-
"@types/luxon": "^3.4.2",
|
|
47
36
|
"amqplib": "^0.10.4",
|
|
48
37
|
"axios": "^1.7.0",
|
|
49
38
|
"bcrypt": "^5.1.1",
|
|
@@ -57,8 +46,6 @@
|
|
|
57
46
|
"luxon": "^3.4.4",
|
|
58
47
|
"mailgen": "^2.0.28",
|
|
59
48
|
"mongoose": "^8.7.0",
|
|
60
|
-
"nest-commander": "^3.12.5",
|
|
61
|
-
"nest-winston": "^1.9.7",
|
|
62
49
|
"nodemailer": "^6.9.13",
|
|
63
50
|
"passport": "^0.7.0",
|
|
64
51
|
"passport-google-oauth2": "^0.2.0",
|
|
@@ -70,22 +57,53 @@
|
|
|
70
57
|
"reflect-metadata": "^0.1.13",
|
|
71
58
|
"rxjs": "^7.8.1",
|
|
72
59
|
"swagger-ui-express": "^5.0.0",
|
|
73
|
-
"typeorm": "^0.3.20",
|
|
74
|
-
"typeorm-naming-strategies": "^4.1.0",
|
|
75
60
|
"uuid": "^9.0.1",
|
|
76
|
-
"winston": "^3.17.0",
|
|
77
61
|
"xlsx": "^0.18.5"
|
|
78
62
|
},
|
|
79
63
|
"peerDependencies": {
|
|
80
|
-
"@nestjs/
|
|
64
|
+
"@nestjs/axios": "^3.0.2",
|
|
65
|
+
"@nestjs/cache-manager": "^2.2.2",
|
|
66
|
+
"@nestjs/common": "^10.0.0",
|
|
67
|
+
"@nestjs/config": "^3.2.0",
|
|
68
|
+
"@nestjs/core": "^10.0.0",
|
|
69
|
+
"@nestjs/event-emitter": "^2.0.4",
|
|
70
|
+
"@nestjs/jwt": "^10.2.0",
|
|
71
|
+
"@nestjs/mapped-types": "^2.0.4",
|
|
72
|
+
"@nestjs/mongoose": "^10.0.10",
|
|
73
|
+
"@nestjs/passport": "^10.0.3",
|
|
74
|
+
"@nestjs/platform-express": "^10.0.0",
|
|
75
|
+
"@nestjs/serve-static": "^4.0.2",
|
|
76
|
+
"@nestjs/swagger": "^7.2.0",
|
|
77
|
+
"@nestjs/typeorm": "^10.0.1",
|
|
78
|
+
"nest-commander": "^3.12.5",
|
|
79
|
+
"nest-winston": "^1.9.7",
|
|
80
|
+
"typeorm": "^0.3.20",
|
|
81
|
+
"typeorm-naming-strategies": "^4.1.0",
|
|
82
|
+
"winston": "^3.17.0"
|
|
81
83
|
},
|
|
82
84
|
"devDependencies": {
|
|
85
|
+
"@nestjs/axios": "^3.0.2",
|
|
86
|
+
"@nestjs/cache-manager": "^2.2.2",
|
|
83
87
|
"@nestjs/cli": "^10.0.0",
|
|
88
|
+
"@nestjs/common": "^10.0.0",
|
|
84
89
|
"@nestjs/config": "^3.2.0",
|
|
90
|
+
"@nestjs/core": "^10.0.0",
|
|
91
|
+
"@nestjs/event-emitter": "^2.0.4",
|
|
92
|
+
"@nestjs/jwt": "^10.2.0",
|
|
93
|
+
"@nestjs/mapped-types": "^2.0.4",
|
|
94
|
+
"@nestjs/mongoose": "^10.0.10",
|
|
95
|
+
"@nestjs/passport": "^10.0.3",
|
|
96
|
+
"@nestjs/platform-express": "^10.0.0",
|
|
97
|
+
"@nestjs/serve-static": "^4.0.2",
|
|
98
|
+
"@nestjs/swagger": "^7.2.0",
|
|
85
99
|
"@nestjs/testing": "^10.0.0",
|
|
100
|
+
"@nestjs/typeorm": "^10.0.1",
|
|
101
|
+
"nest-commander": "^3.12.5",
|
|
102
|
+
"nest-winston": "^1.9.7",
|
|
86
103
|
"@types/express": "^4.17.17",
|
|
87
104
|
"@types/hapi__joi": "^17.1.12",
|
|
88
105
|
"@types/jest": "^29.5.2",
|
|
106
|
+
"@types/luxon": "^3.4.2",
|
|
89
107
|
"@types/mongoose": "^5.11.97",
|
|
90
108
|
"@types/multer": "^1.4.11",
|
|
91
109
|
"@types/node": "^20.3.1",
|
|
@@ -110,7 +128,11 @@
|
|
|
110
128
|
"ts-loader": "^9.4.3",
|
|
111
129
|
"ts-node": "^10.9.1",
|
|
112
130
|
"tsconfig-paths": "^4.2.0",
|
|
113
|
-
"
|
|
131
|
+
"typeorm": "^0.3.20",
|
|
132
|
+
"typeorm-naming-strategies": "^4.1.0",
|
|
133
|
+
"typescript": "^5.1.3",
|
|
134
|
+
"winston": "^3.17.0",
|
|
135
|
+
"@solidstarters/solid-code-builder": "^1.0.2"
|
|
114
136
|
},
|
|
115
137
|
"jest": {
|
|
116
138
|
"moduleFileExtensions": [
|
package/rebuild.sh
ADDED
package/src/cli.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { CommandFactory } from "nest-commander";
|
|
4
|
+
import { SolidCoreCliModule } from "./solid-core-cli.module";
|
|
5
|
+
|
|
6
|
+
async function bootstrap() {
|
|
7
|
+
|
|
8
|
+
// const app = await NestFactory.create(appModule);
|
|
9
|
+
|
|
10
|
+
// Create an instance of the application, capture the application context so we can inject it into a service in itself.
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const app = await CommandFactory.createWithoutRunning(SolidCoreCliModule, ['debug', 'error', 'fatal', 'log', 'verbose', 'warn']);
|
|
13
|
+
// const app = await CommandFactory.createWithoutRunning(AppModule, ['debug', 'error', 'fatal', 'log', 'verbose', 'warn']);
|
|
14
|
+
// const app = await CommandFactory.createWithoutRunning(AppModule, ['error', 'fatal']);
|
|
15
|
+
|
|
16
|
+
// Now run the command factory.
|
|
17
|
+
try {
|
|
18
|
+
await CommandFactory.runApplication(app);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Exit explicitly, make sure that any commands you have created and are using Promises, you do not keep them orphan/dangling.
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// https://github.com/typeorm/typeorm/issues/8583
|
|
29
|
+
// const types = require('pg').types;
|
|
30
|
+
// types.setTypeParser(types.builtins.INT8, function(val) {
|
|
31
|
+
// return parseInt(val)
|
|
32
|
+
// });
|
|
33
|
+
|
|
34
|
+
bootstrap();
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
|
5
|
+
import { WinstonTypeORMLogger } from './winston.logger';
|
|
6
|
+
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [
|
|
10
|
+
TypeOrmModule.forRootAsync({
|
|
11
|
+
// This becomes the default by default.
|
|
12
|
+
// name: 'default',
|
|
13
|
+
useFactory: (logger: Logger) => {
|
|
14
|
+
|
|
15
|
+
const entities = [
|
|
16
|
+
join(__dirname, './entities/*.entity.{ts,js}'),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// DO NOT REMOVE BELOW COMMENT
|
|
20
|
+
// We no longer register subscribers on the TypeORM datasource.
|
|
21
|
+
// instead we register them directly as NestJS providers, and they register themselves as subscribers on the data source during service instantiation in their respective constructor.
|
|
22
|
+
// check ModelSubscriber for a reference.
|
|
23
|
+
// Steps are
|
|
24
|
+
// 1. Create the subscriber like a NestJS injectable service.
|
|
25
|
+
// 2. Register the subscriber in the respective module like you would any other NestJS service.
|
|
26
|
+
// 3. Make sure to not provide the subscribers array below.
|
|
27
|
+
// const subscribers = [
|
|
28
|
+
// join(__dirname, './app-builder/subscribers/*.subscriber.{ts,js}'),
|
|
29
|
+
// join(__dirname, './common/subscribers/*.subscriber.{ts,js}'),
|
|
30
|
+
// join(__dirname, './iam/subscribers/*.subscriber.{ts,js}'),
|
|
31
|
+
// join(__dirname, './queues/subscribers/*.subscriber.{ts,js}'),
|
|
32
|
+
// ...enabledModules.map(module =>
|
|
33
|
+
// join(__dirname, `./${module}/subscribers/*.subscriber.{ts,js}`)
|
|
34
|
+
// ),
|
|
35
|
+
// ];
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
// type of our database.
|
|
39
|
+
type: 'postgres',
|
|
40
|
+
host: process.env.DEFAULT_DATABASE_HOST,
|
|
41
|
+
port: +process.env.DEFAULT_DATABASE_PORT,
|
|
42
|
+
username: process.env.DEFAULT_DATABASE_USER,
|
|
43
|
+
password: process.env.DEFAULT_DATABASE_PASSWORD,
|
|
44
|
+
// name of our database
|
|
45
|
+
database: process.env.DEFAULT_DATABASE_NAME,
|
|
46
|
+
// models will be loaded automatically
|
|
47
|
+
// autoLoadEntities: true,
|
|
48
|
+
entities: entities,
|
|
49
|
+
// your entities will be synced with the database (recommended: disable in prod)
|
|
50
|
+
synchronize: Boolean(process.env.DEFAULT_DATABASE_SYNCHRONIZE),
|
|
51
|
+
logging: Boolean(process.env.DEFAULT_DATABASE_LOGGING),
|
|
52
|
+
// logger: new WinstonTypeORMLogger(logger), // Pass in the custom WinstonLogger
|
|
53
|
+
namingStrategy: new SnakeNamingStrategy(),
|
|
54
|
+
// subscribers: subscribers
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
inject: [WINSTON_MODULE_PROVIDER]
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
})
|
|
61
|
+
export class SolidCoreCliDBModule{
|
|
62
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { SolidCoreCliDBModule } from './solid-core-cli-db.module';
|
|
3
|
+
import { SolidCoreModule } from './solid-core.module'; // Import main module
|
|
4
|
+
import { WinstonLoggerConfig } from './winston.logger';
|
|
5
|
+
import { WinstonModule } from 'nest-winston';
|
|
6
|
+
import { CacheModule } from '@nestjs/cache-manager';
|
|
7
|
+
import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
8
|
+
import { RedisOptions } from './config/redis.options';
|
|
9
|
+
import { ConfigModule } from '@nestjs/config';
|
|
10
|
+
import Joi from '@hapi/joi';
|
|
11
|
+
|
|
12
|
+
@Module({
|
|
13
|
+
imports: [
|
|
14
|
+
WinstonModule.forRoot(WinstonLoggerConfig),
|
|
15
|
+
ConfigModule.forRoot({
|
|
16
|
+
isGlobal: true,
|
|
17
|
+
// Here we are specifying the path of the environment file.
|
|
18
|
+
// If not specified then it assumes a file named .env
|
|
19
|
+
// envFilePath: '.environment'
|
|
20
|
+
|
|
21
|
+
// This we do in live environments, where these variables should ideally come
|
|
22
|
+
// from the OS provided environment.
|
|
23
|
+
// ignoreEnvFile: true
|
|
24
|
+
|
|
25
|
+
validationSchema: Joi.object({
|
|
26
|
+
DEFAULT_DATABASE_HOST: Joi.required(),
|
|
27
|
+
DEFAULT_DATABASE_PORT: Joi.number().default(5432),
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
// load: [appConfig],
|
|
31
|
+
}),
|
|
32
|
+
|
|
33
|
+
SolidCoreCliDBModule,
|
|
34
|
+
CacheModule.registerAsync(RedisOptions),
|
|
35
|
+
EventEmitterModule.forRoot(),
|
|
36
|
+
SolidCoreModule, // Import main module without exposing forRoot()
|
|
37
|
+
],
|
|
38
|
+
exports: [SolidCoreModule], // Ensure CLI can use all exports
|
|
39
|
+
})
|
|
40
|
+
export class SolidCoreCliModule{}
|
package/src/solid-core.module.ts
CHANGED
|
@@ -121,17 +121,17 @@ import { Msg91SMSService } from './services/sms/Msg91SMSService';
|
|
|
121
121
|
import { Msg91WhatsappService } from './services/whatsapp/Msg91WhatsappService';
|
|
122
122
|
import { SoftDeleteAwareEventSubscriber } from './subscribers/softDeleteAwareEventSubscriber.subscriber';
|
|
123
123
|
|
|
124
|
+
import { PermissionMetadataController } from './controllers/permission-metadata.controller';
|
|
124
125
|
import { PermissionMetadata } from './entities/permission-metadata.entity';
|
|
125
126
|
import { PermissionMetadataService } from './services/permission-metadata.service';
|
|
126
|
-
import { PermissionMetadataController } from './controllers/permission-metadata.controller';
|
|
127
127
|
|
|
128
|
-
import { RoleMetadata } from './entities/role-metadata.entity';
|
|
129
|
-
import { RoleMetadataService } from './services/role-metadata.service';
|
|
130
128
|
import { RoleMetadataController } from './controllers/role-metadata.controller';
|
|
131
|
-
import {
|
|
129
|
+
import { UserController } from './controllers/user.controller';
|
|
130
|
+
import { RoleMetadata } from './entities/role-metadata.entity';
|
|
132
131
|
import { User } from './entities/user.entity';
|
|
132
|
+
import { PermissionMetadataSeederService } from './seeders/permission-metadata-seeder.service';
|
|
133
|
+
import { RoleMetadataService } from './services/role-metadata.service';
|
|
133
134
|
import { UserService } from './services/user.service';
|
|
134
|
-
import { UserController } from './controllers/user.controller';
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
@Global()
|
|
@@ -311,6 +311,8 @@ import { UserController } from './controllers/user.controller';
|
|
|
311
311
|
AuthenticationService,
|
|
312
312
|
MqMessageQueueService,
|
|
313
313
|
MqMessageService,
|
|
314
|
+
RefreshModelCommand,
|
|
315
|
+
RefreshModuleCommand,
|
|
314
316
|
],
|
|
315
317
|
})
|
|
316
318
|
export class SolidCoreModule { }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
import { Logger as TypeORMLogger, QueryRunner } from 'typeorm';
|
|
3
|
+
import { Logger } from 'winston';
|
|
4
|
+
import { Inject } from '@nestjs/common';
|
|
5
|
+
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
|
6
|
+
import * as winston from 'winston';
|
|
7
|
+
|
|
8
|
+
export const WinstonLoggerConfig = {
|
|
9
|
+
level: 'debug', // Allow all log levels for debugging
|
|
10
|
+
format: winston.format.combine(
|
|
11
|
+
winston.format.timestamp(),
|
|
12
|
+
winston.format.errors({ stack: true }),
|
|
13
|
+
winston.format.printf(({ level, message, timestamp }) => {
|
|
14
|
+
if (!message) {
|
|
15
|
+
return `[${timestamp}] ${level.toUpperCase()}: (No message provided)`;
|
|
16
|
+
}
|
|
17
|
+
return `[${timestamp}] ${level.toUpperCase()}: ${message}`;
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
transports: [
|
|
21
|
+
new winston.transports.Console({
|
|
22
|
+
format: winston.format.combine(
|
|
23
|
+
// winston.format.colorize(),
|
|
24
|
+
// winston.format.timestamp(),
|
|
25
|
+
winston.format.printf(({ level, message, timestamp }) => {
|
|
26
|
+
return `[${timestamp}] ${level.toUpperCase()}: ${message}`;
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
}),
|
|
30
|
+
new winston.transports.File({
|
|
31
|
+
filename: 'logs/application.log',
|
|
32
|
+
// format: winston.format.json(),
|
|
33
|
+
}),
|
|
34
|
+
new winston.transports.File({
|
|
35
|
+
filename: 'logs/error.log',
|
|
36
|
+
level: 'error',
|
|
37
|
+
// format: winston.format.json(),
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export class WinstonTypeORMLogger implements TypeORMLogger {
|
|
43
|
+
constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) { }
|
|
44
|
+
|
|
45
|
+
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {
|
|
46
|
+
if (Boolean(process.env.DEFAULT_DATABASE_LOGGING)) {
|
|
47
|
+
this.logger.info(`Query: ${query} Parameters: ${parameters}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
logQueryError(error: string, query: string, parameters?: any[], queryRunner?: QueryRunner): void {
|
|
52
|
+
this.logger.error(`Query failed: ${error} | Query: ${query} | Parameters: ${parameters}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
logQuerySlow(time: number, query: string, parameters?: any[], queryRunner?: QueryRunner): void {
|
|
56
|
+
this.logger.warn(`Slow query: ${time}ms | Query: ${query} | Parameters: ${parameters}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
logSchemaBuild(message: string, queryRunner?: QueryRunner): void {
|
|
60
|
+
this.logger.info(`Schema Build: ${message}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
logMigration(message: string, queryRunner?: QueryRunner): void {
|
|
64
|
+
this.logger.info(`Migration: ${message}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
log(level: 'log' | 'info' | 'warn' | 'error', message: any): void {
|
|
68
|
+
this.logger[level](message);
|
|
69
|
+
}
|
|
70
|
+
}
|