fix: swagger block event loop
This commit is contained in:
parent
60b0fdd5ca
commit
b0630005d9
@ -32,18 +32,21 @@ export class SwaggerManager {
|
|||||||
return this.generateSwagger();
|
return this.generateSwagger();
|
||||||
}
|
}
|
||||||
|
|
||||||
collection2Swagger(collectionName: string, withAssociation = true) {
|
async collection2Swagger(collectionName: string, withAssociation = true) {
|
||||||
const collection = this.db.getCollection(collectionName);
|
const collection = this.db.getCollection(collectionName);
|
||||||
return collectionToSwaggerObject(collection, {
|
return await (async () => {
|
||||||
withAssociation,
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
});
|
return collectionToSwaggerObject(collection, {
|
||||||
|
withAssociation,
|
||||||
|
});
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCollectionsSwagger(name?: string) {
|
async getCollectionsSwagger(name?: string) {
|
||||||
const base = await this.getBaseSwagger();
|
const base = await this.getBaseSwagger();
|
||||||
let others = {};
|
let others = {};
|
||||||
if (name) {
|
if (name) {
|
||||||
const collectionSwagger = this.collection2Swagger(name);
|
const collectionSwagger = await this.collection2Swagger(name);
|
||||||
others = merge(others, collectionSwagger);
|
others = merge(others, collectionSwagger);
|
||||||
} else {
|
} else {
|
||||||
const collections = await this.db.getRepository('collections').find({
|
const collections = await this.db.getRepository('collections').find({
|
||||||
@ -59,7 +62,7 @@ export class SwaggerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
others = merge(others, this.collection2Swagger(collection.name, false));
|
others = merge(others, await this.collection2Swagger(collection.name, false));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.app.log.error(e);
|
this.app.log.error(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user