very-express 0.6.1-alpha → 0.6.2-alpha

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.
@@ -1,5 +1,5 @@
1
1
  // {{headerComment}}
2
- import { Model, Document, FilterQuery } from "mongoose";
2
+ import { Model, Document } from "mongoose";
3
3
  import { IVexRepository } from "../_types/IVexRepository.gen";
4
4
  import { Select, Filter, Join } from "../_types/VexRequest.gen";
5
5
 
@@ -11,18 +11,18 @@ export class MongooseRepositoryAdapter<T extends Document> implements IVexReposi
11
11
  }
12
12
 
13
13
  find(filter: Filter, join?: Join, select?: Select): Promise<T[]> {
14
- // TODO: handle join and select
15
- return this.model.find((filter || {}) as FilterQuery<T>).exec();
14
+ // TODO: complete mongoose support, handle join and select
15
+ return this.model.find((filter || {}) as any).exec();
16
16
  }
17
17
 
18
18
  findOne(filter: Filter, join?: Join, select?: Select): Promise<T | null> {
19
- // TODO: handle join and select
20
- return this.model.findOne(filter as FilterQuery<T>).exec();
19
+ // TODO: complete mongoose support, handle join and select
20
+ return this.model.findOne(filter as any).exec();
21
21
  }
22
22
 
23
23
  findOneWhere(filter: Filter, join?: Join, select?: Select): Promise<T | null> {
24
- // TODO: handle join and select
25
- return this.model.findOne(filter as FilterQuery<T>).exec();
24
+ // TODO: complete mongoose support, handle join and select
25
+ return this.model.findOne(filter as any).exec();
26
26
  }
27
27
 
28
28
  async create(data: Partial<T>): Promise<T> {
@@ -108,31 +108,36 @@ export class VexDbConnector {
108
108
  }
109
109
  }
110
110
 
111
+ // TODO: complete mongoose support, handle join and select
111
112
  connectMongo(): void {
112
- utils.log.infoSql("Connecting to MongoDB (Mongoose)...");
113
+ console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
114
+ utils.log.infoMongo("Connecting to MongoDB (Driver: Mongoose)...");
113
115
  const connectWithRetry = (retryTime = 10): void => {
114
116
  mongoose.connect(this.mongoUrl)
115
- .then(() => utils.log.infoSql("Mongoose connected"))
117
+ .then(() => utils.log.infoMongo("Mongoose connected"))
116
118
  .catch((err) => {
117
- utils.log.errorSql(`Failed to connect Mongoose, retrying in ${retryTime}s`, err);
119
+ utils.log.errorMongo(`Failed to connect Mongoose, retrying in ${retryTime}s`, err);
118
120
  setTimeout(() => connectWithRetry(retryTime), retryTime * 1000);
119
121
  });
120
122
  };
121
123
  connectWithRetry(10);
122
124
  }
123
125
 
126
+ // TODO: complete mongoose support, handle join and select
124
127
  closeMongo(): void {
128
+ console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
125
129
  mongoose.disconnect()
126
- .then(() => utils.log.infoSql("Mongoose disconnected"))
127
- .catch((err) => utils.log.errorSql("Error disconnecting Mongoose", err));
130
+ .then(() => utils.log.infoMongo("Mongoose disconnected"))
131
+ .catch((err) => utils.log.errorMongo("Error disconnecting Mongoose", err));
128
132
  }
129
133
 
130
- getRepository<T extends Document>(target: { schema: unknown; modelName: string }): IVexRepository<T>;
134
+ // getRepository<T extends Document>(target: { schema: unknown; modelName: string }): IVexRepository<T>;
131
135
  getRepository<T extends ObjectLiteral>(target: EntityTarget<T>): IVexRepository<T>;
132
136
  getRepository<T>(target: EntityTarget<ObjectLiteral> | any): IVexRepository<T> {
133
- // Mongoose Model: has .schema and .modelName properties
137
+ // TODO: complete mongoose support, handle join and select
134
138
  if (target?.schema && target?.modelName) {
135
- return new MongooseRepositoryAdapter<T & Document>(target);
139
+ console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
140
+ // return new MongooseRepositoryAdapter<T & Document>(target);
136
141
  }
137
142
  if (!this.dataSource) throw new Error("SQL DataSource not initialized");
138
143
  return new TypeOrmRepositoryAdapter<T & ObjectLiteral>(this.dataSource.getRepository(target));
@@ -29,13 +29,13 @@ export function verifyPassword(
29
29
  plainPassword: string,
30
30
  ): boolean {
31
31
  if(!user.email || !user.userAuthProfiles) {
32
- console.log(`User "${user._id}" email or userAuthProfiles missing for local auth's password verification.`);
32
+ // log.error(`User "${user._id}" email or userAuthProfiles missing for local auth's password verification.`);
33
33
  return false;
34
34
  }
35
35
 
36
36
  const hashedPassword = user.userAuthProfiles.find((profile:any) => profile.provider === "local")?.password;
37
37
  if(!hashedPassword) {
38
- console.log(`User "${user._id}" Local auth profile or password missing.`);
38
+ // log.error(`User "${user._id}" Local auth profile or password missing.`);
39
39
  return false;
40
40
  }
41
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.6.1-alpha",
3
+ "version": "0.6.2-alpha",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "Justin26l",
6
6
  "license": "MIT",
package/vex.config.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "localAuth": true,
16
16
  "useHttpOnlyCookieToken": true,
17
17
  "oauthProviders": {
18
- "google": false,
18
+ "google": true,
19
19
  "github": false
20
20
  }
21
21
  },