diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index eaba126..fab6b78 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -66,5 +66,5 @@ jobs:
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- files: ./packages/api-gateway/coverage/lcov.info
+ files: ./packages/api-gateway/coverage/clover.xml
fail_ci_if_error: true
\ No newline at end of file
diff --git a/README.md b/README.md
index e477e97..ccebe71 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,9 @@
+
+
+
+
+
+
> WARNING: This software is not ready yet, please don't use in production. There are a [lot of things to do](#to-do) and is under active development. APIs and table schemas are subject to change without notice. Technical support is unavailable at this time.
Bitify Trading Platform
diff --git a/packages/api-gateway/package.json b/packages/api-gateway/package.json
index c5198fa..0d431af 100644
--- a/packages/api-gateway/package.json
+++ b/packages/api-gateway/package.json
@@ -16,7 +16,7 @@
"lint:fix": "eslint --fix",
"pretest": "node ./test/before-all-tests.js",
"test": "tap --ts",
- "test:ci": "pnpm pretest && tap --ts --coverage --coverage-report=lcov",
+ "test:ci": "tap --ts --coverage --coverage-report=clover",
"test:cov": "pnpm pretest && tap --ts --coverage",
"test:dev": "pnpm pretest && tap --ts --watch --coverage"
},
diff --git a/packages/api-gateway/src/base/base.service.ts b/packages/api-gateway/src/base/base.service.ts
index c0601a5..4a754a7 100644
--- a/packages/api-gateway/src/base/base.service.ts
+++ b/packages/api-gateway/src/base/base.service.ts
@@ -7,10 +7,7 @@ import {
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import { BaseEntity } from './base.entity';
import { IBaseService } from './interfaces/base-service.interface';
-import {
- InternalServerErrorException,
- UnprocessableEntityException,
-} from '@nestjs/common';
+import { UnprocessableEntityException } from '@nestjs/common';
export abstract class BaseService<
Entity extends BaseEntity,
@@ -27,10 +24,6 @@ export abstract class BaseService<
* @returns The entity
*/
createEntity(data: CreateDTO, userId: string): Entity {
- if (!data || !userId)
- throw new InternalServerErrorException(
- 'Missing data or userId for createEntity method',
- );
// Instantiating the entity before saving so hooks run
return this.repo.create({ ...data, userId: userId });
}
@@ -41,8 +34,6 @@ export abstract class BaseService<
* @returns The created resource
*/
save(data: Entity): Promise {
- if (!data)
- throw new InternalServerErrorException('Missing data for save method');
return this.repo.save(data);
}
@@ -66,10 +57,6 @@ export abstract class BaseService<
filter: FindOptionsWhere,
unselected = false,
): Promise {
- if (!filter)
- throw new InternalServerErrorException(
- 'Missing filter for findOne method',
- );
if (unselected === true) {
return this.repo.findOne({
select: this.getAllTableColumns(),
@@ -86,8 +73,6 @@ export abstract class BaseService<
* @returns The entity that match the conditions or null.
*/
findById(id: string, unselected = false): Promise {
- if (!id)
- throw new InternalServerErrorException('Missing id for findById method');
return this.findOne({ id } as FindOptionsWhere, unselected);
}
@@ -101,10 +86,6 @@ export abstract class BaseService<
filter: FindOptionsWhere,
data: UpdateDTO,
): Promise {
- if (!filter || !data)
- throw new InternalServerErrorException(
- 'Missing filter or data for update method',
- );
// @ts-expect-error Dto should not have userId, but we check anyway at runtime
if (data.userId)
throw new UnprocessableEntityException('Ownership can not be changed');
@@ -124,10 +105,6 @@ export abstract class BaseService<
data: UpdateDTO,
userId?: string,
): Promise {
- if (!id || !data)
- throw new InternalServerErrorException(
- 'Missing id or data for updateById method',
- );
// @ts-expect-error Dto should not have userId, but we check anyway at runtime
if (data.userId)
throw new UnprocessableEntityException('Ownership can not be changed');
@@ -149,10 +126,6 @@ export abstract class BaseService<
* @param {boolean} soft When true a soft delete is performed otherwise a real delete.
*/
async delete(filter: FindOptionsWhere, soft = true): Promise {
- if (!filter)
- throw new InternalServerErrorException(
- 'Missing filter for delete method',
- );
await this.repo[soft ? 'softDelete' : 'delete'](filter);
}
@@ -165,10 +138,6 @@ export abstract class BaseService<
* @param {boolean} soft When true a soft delete is performed otherwise a real delete.
*/
async deleteById(id: string, userId?: string, soft = true): Promise {
- if (!id)
- throw new InternalServerErrorException(
- 'Missing id for deleteById method',
- );
await this.repo[soft ? 'softDelete' : 'delete']({
id,
...(userId ? { userId: userId } : {}),
diff --git a/packages/api-gateway/test/base/base-service.test.ts b/packages/api-gateway/test/base/base-service.test.ts
index 7e7e671..5b7664e 100644
--- a/packages/api-gateway/test/base/base-service.test.ts
+++ b/packages/api-gateway/test/base/base-service.test.ts
@@ -1,9 +1,6 @@
import { test } from 'tap';
import { buildServer, createUser } from '../helper';
-import {
- InternalServerErrorException,
- UnprocessableEntityException,
-} from '@nestjs/common';
+import { UnprocessableEntityException } from '@nestjs/common';
import { RecoveryTokensService } from '../../src/recovery-tokens/recovery-tokens.service';
import { RecoveryToken } from '../../src/recovery-tokens/entities/recovery-token.entity';
import { randomUUID } from 'crypto';
@@ -25,31 +22,11 @@ test('base service creatEntity() and save() method', async ({
token: 'somerecoverytoken',
expiresAt: new Date(),
};
- // Test createEntity() method without required params
- try {
- // @ts-expect-error we now that userId is required
- service.createEntity(mockBody);
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- try {
- // @ts-expect-error we now that dto is required
- service.createEntity();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
+
// Test createEntity() method with right params
const tokenEntity = service.createEntity(mockBody, user.id);
equal(tokenEntity instanceof RecoveryToken, true);
- // Test save() method without required param
- try {
- // @ts-expect-error we now that dto is required
- service.save();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
-
// test save() method with right param
const token = await service.save(tokenEntity);
equal(token instanceof RecoveryToken, true);
@@ -107,16 +84,6 @@ test('base service findOne() method', async ({ equal, teardown }) => {
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test findOne() method without params
- {
- try {
- // @ts-expect-error we now that a filter is required in findOne
- await service.findOne();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
-
// Test findOne() method invalid ID
{
const res = await service.findOne({ id: randomUUID() });
@@ -145,16 +112,6 @@ test('base service findById() method', async ({ equal, teardown }) => {
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test findById() method without params
- {
- try {
- // @ts-expect-error we now that id is required
- await service.findById();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
-
// Test findById() method invalid ID
{
const res = await service.findById(randomUUID());
@@ -183,23 +140,6 @@ test('base service update() method', async ({ equal, teardown }) => {
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test update() method without params
- {
- try {
- // @ts-expect-error we now that filter is required
- await service.update();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
-
- try {
- // @ts-expect-error we now that dto is required
- await service.update({ id: token.id });
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
-
// Test update() method with right params
{
await service.update({ id: token.id }, { token: 'newtokenUpdate' });
@@ -232,22 +172,6 @@ test('base service updateById() method', async ({ equal, teardown }) => {
};
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test updateById() method without required params
- {
- try {
- // @ts-expect-error we now that filter is required
- await service.updateById();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
-
- try {
- // @ts-expect-error we now that dto is required
- await service.updateById(token.id);
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
// Test updatedById() method with right params
{
@@ -296,16 +220,6 @@ test('base service delete() method', async ({ equal, teardown }) => {
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test delete() method without params
- {
- try {
- // @ts-expect-error we now that filter is required
- await service.delete();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
-
// Test delete() method with right params
{
await service.delete({ id: token.id });
@@ -349,16 +263,6 @@ test('base service deleteById() method', async ({ equal, teardown }) => {
const tokenEntity = service.createEntity(mockBody, user.id);
const token = await service.save(tokenEntity);
- // Test deleteById() method without required params
- {
- try {
- // @ts-expect-error we now that filter is required
- await service.deleteById();
- } catch (error) {
- equal(error instanceof InternalServerErrorException, true);
- }
- }
-
// Test deleteById() method without passing userId
{
await service.deleteById(token.id);