Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit e44ef9f

Browse files
committed
resolves #231
1 parent 24f91c4 commit e44ef9f

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sakuraapi/core",
3-
"version": "0.19.0",
3+
"version": "0.19.1",
44
"description": "MongoDB and TypeScript MEAN Stack Framework for NodeJS",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

src/core/@injectable/injectable.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { IRoutableLocals, Routable, Route, SapiRoutableMixin } from '../@routabl
66
import { OK } from '../lib';
77
import { SakuraApi } from '../sakura-api';
88
import {
9-
Injectable, injectableSymbols, NonInjectableConstructorParameterError, ProviderNotRegistered,
9+
Injectable,
10+
injectableSymbols,
11+
NonInjectableConstructorParameterError,
12+
ProviderNotRegistered,
1013
ProvidersMustBeDecoratedWithInjectableError
1114
} from './injectable';
1215

@@ -30,8 +33,8 @@ describe('@Injectable', () => {
3033
});
3134
});
3235

33-
afterEach(() => {
34-
sapi.close();
36+
afterEach(async () => {
37+
await sapi.close();
3538
});
3639

3740
it('decorates @Injectable class', () => {

src/core/@model/model-operators/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function create(this: InstanceType<ReturnType<typeof SapiModelMixin
3030
throw new Error(`Database '${(constructor[modelSymbols.dbName] || {} as any).name}' not found`);
3131
}
3232

33-
this.emitBeforeCreate(context);
33+
await this.emitBeforeCreate(context);
3434

3535
const dbObj = this.toDb();
3636
const result = await col.insertOne(dbObj, options);

src/core/@model/model-operators/save.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function save(this: InstanceType<ReturnType<typeof SapiModelMixin>>
3838
throw new SapiMissingIdErr('Model missing id field, cannot save. Did you mean to use create?', this);
3939
}
4040

41-
this.emitBeforeSave(context);
41+
await this.emitBeforeSave(context);
4242

4343
const dbObj = changeSet || this.toDb(this);
4444
delete dbObj._id;

src/core/@routable/routable.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { ObjectID } from 'mongodb';
33
import * as request from 'supertest';
44
import { testSapi, testUrl } from '../../../spec/helpers/sakuraapi';
55
import { getAllRouteHandler, getRouteHandler } from '../../handlers';
6-
import { Db, Json, Model, SapiModelMixin } from '../@model';
7-
import { Id } from '../@model/id';
6+
import { Db, Id, Json, Model, SapiModelMixin } from '../@model';
87
import { BAD_REQUEST, DUPLICATE_RESOURCE, NOT_FOUND, OK } from '../lib';
98
import { AuthenticatorPlugin, AuthenticatorPluginResult, IAuthenticator, IAuthenticatorConstructor } from '../plugins';
109
import { SakuraApi } from '../sakura-api';
@@ -683,7 +682,7 @@ describe('core/@Routable', () => {
683682
it('without results', async (done) => {
684683

685684
try {
686-
BeforeAfterInjectRouteTestModel.removeAll({});
685+
await BeforeAfterInjectRouteTestModel.removeAll({});
687686
const res = await request(sapi.app)
688687
.get(testUrl('/GetAllRouteHandlerBeforeAfterTest/beforeTest/get'))
689688
.expect(OK);
@@ -1767,7 +1766,7 @@ describe('core/@Routable', () => {
17671766
const routableSuppressApiTrueTest = new RoutableSuppressApiTrueTest();
17681767
expect(routableSuppressApiTrueTest[routableSymbols.routes].length).toBe(0);
17691768

1770-
sapi2.close();
1769+
await sapi2.close();
17711770
});
17721771

17731772
it('suppressess only generated endpoints that are not suppressed', async () => {

src/core/@routable/sapi-routable.mixin.spec.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import {
2-
NextFunction,
3-
Request,
4-
Response
5-
} from 'express';
1+
import { NextFunction, Request, Response } from 'express';
62
import * as request from 'supertest';
7-
import {
8-
testSapi,
9-
testUrl
10-
} from '../../../spec/helpers/sakuraapi';
3+
import { testSapi, testUrl } from '../../../spec/helpers/sakuraapi';
114
import { SakuraApi } from '../sakura-api';
125
import { Routable } from './routable';
136
import { Route } from './route';
@@ -72,7 +65,7 @@ describe('SapiRoutableMixin', () => {
7265
]
7366
});
7467

75-
sapi.listen({bootMessage: ''});
68+
await sapi.listen({bootMessage: ''});
7669

7770
const result1 = await request(sapi.app)
7871
.get(testUrl('baseApi'))
@@ -97,7 +90,7 @@ describe('SapiRoutableMixin', () => {
9790
done.fail(err);
9891
} finally {
9992
if (sapi) {
100-
sapi.close();
93+
await sapi.close();
10194
}
10295
}
10396

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
true,
2121
"dev"
2222
],
23+
"no-floating-promises": true,
2324
"no-object-literal-type-assertion": false,
2425
"prefer-for-of": false,
2526
"prefer-object-spread": false,

0 commit comments

Comments
 (0)