Skip to content

Commit

Permalink
feat(repo): consolidate tsconfig paths to tsconfig.base.json and rena…
Browse files Browse the repository at this point in the history
…me import and require references and provide an initial backend lib with example exported interface (#8)
  • Loading branch information
benpsnyder authored May 13, 2024
1 parent 77b4712 commit b6db2c7
Show file tree
Hide file tree
Showing 3,177 changed files with 12,621 additions and 11,911 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
31 changes: 31 additions & 0 deletions libs/backend/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"exclude": [
"jest.config.ts",
".*.spec.tsx?$",
".*.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
],
"jsc": {
"externalHelpers": true,
"keepClassNames": true,
"loose": true,
"parser": {
"decorators": true,
"dynamicImport": true,
"syntax": "typescript"
},
"target": "es2022",
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
}
},
"module": {
"noInterop": true,
"strict": true,
"type": "commonjs"
},
"sourceMaps": true
}
11 changes: 11 additions & 0 deletions libs/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# bigcapital-libs-backend

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build bigcapital-libs-backend` to build the library.

## Running unit tests

Run `nx test bigcapital-libs-backend` to execute the unit tests via [Jest](https://jestjs.io).
15 changes: 15 additions & 0 deletions libs/backend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable */
import { readFileSync } from 'fs';

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(`${__dirname}/.swcrc`, 'utf-8'));
export default {
displayName: 'bigcapital-libs-backend',
preset: '../../../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../../coverage/libs/backend',
};
8 changes: 8 additions & 0 deletions libs/backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@bigcapial/libs-backend",
"version": "1.0.0",
"type": "commonjs",
"devDependencies": {
"@types/format-util": "^1.0.2"
}
}
26 changes: 26 additions & 0 deletions libs/backend/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"name": "bigcapital-libs-backend",
"projectType": "library",
"sourceRoot": "libs/backend/src",
"tags": ["stack:edge", "lang:typescript", "framework:agnostic", "ecosystem:shared", "domain:shared", "type:domain"],
"targets": {
"build": {
"executor": "@nx/js:swc",
"options": {
"assets": ["libs/backend/*.md"],
"main": "libs/backend/src/index.ts",
"outputPath": "dist/libs/backend",
"tsConfig": "libs/backend/tsconfig.lib.json"
},
"outputs": ["{options.outputPath}"]
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "libs/backend/jest.config.ts"
},
"outputs": ["{workspaceRoot}/coverage/libs/backend"]
}
}
}
3 changes: 3 additions & 0 deletions libs/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './lib/interfaces';
export * from './lib/backend';
export * from './lib/enums';
7 changes: 7 additions & 0 deletions libs/backend/src/lib/backend.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { edgeSharedDomain } from './bigcapital-libs-backend';

describe('edgeSharedDomain', () => {
it('should work', () => {
expect(edgeSharedDomain()).toEqual('bigcapital-libs-backend');
});
});
6 changes: 6 additions & 0 deletions libs/backend/src/lib/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
*
*/
export function edgeSharedDomain(): string {
return 'bigcapital-libs-backend';
}
8 changes: 8 additions & 0 deletions libs/backend/src/lib/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// enums

export enum EnumConsigneeType {
directConsumer = 'Direct Consumer',
governmentEntity = 'Government Entity',
reseller = 'Reseller',
other = 'Other/Unknown',
}
10 changes: 10 additions & 0 deletions libs/backend/src/lib/interfaces/Account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface IAccountDTO {
name: string;
code: string;
description: string;
accountType: string;
parentAccountId?: number;
active: boolean;
bankBalance?: number;
accountMask?: string;
}
2 changes: 2 additions & 0 deletions libs/backend/src/lib/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// interfaces
export * from './Account';
25 changes: 25 additions & 0 deletions libs/backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"module": "ES2022",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true
},
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions libs/backend/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"declaration": true,
"outDir": "../../dist/out-tsc",
"types": []
},
"exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"],
"extends": "./tsconfig.json",
"include": ["**/*.ts"]
}
9 changes: 9 additions & 0 deletions libs/backend/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"types": ["jest", "node"]
},
"extends": "./tsconfig.json",
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@faker-js/faker": "^8.4.1",
"@nx/jest": "^19.0.3",
"@nx/js": "^19.0.3",
"@playwright/test": "^1.44.0",
"@swc/helpers": "0.5.3",
"@swc-node/register": "1.9.0",
"swc-loader": "^0.2.6",
"@swc/cli": "0.3.12",
"@swc/core": "1.4.13",
"@swc/jest": "0.2.36",
"bun-types": "^1.1.7",
"gulp": "^4.0.2",
"gulp-sass": "^5.1.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/api/controllers/Account/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseController from '@/api/controllers/BaseController';
import AttachCurrentTenantUser from '@/api/middleware/AttachCurrentTenantUser';
import TenancyMiddleware from '@/api/middleware/TenancyMiddleware';
import JWTAuth from '@/api/middleware/jwtAuth';
import AuthenticatedAccount from '@/services/AuthenticatedAccount';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import AttachCurrentTenantUser from '@bigcapital/server/api/middleware/AttachCurrentTenantUser';
import TenancyMiddleware from '@bigcapital/server/api/middleware/TenancyMiddleware';
import JWTAuth from '@bigcapital/server/api/middleware/jwtAuth';
import AuthenticatedAccount from '@bigcapital/server/services/AuthenticatedAccount';
import { NextFunction, Request, Response, Router } from 'express';
import { Inject, Service } from 'typedi';

Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/api/controllers/AccountTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseController from '@/api/controllers/BaseController';
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
import AccountsTypesService from '@/services/Accounts/AccountsTypesServices';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import asyncMiddleware from '@bigcapital/server/api/middleware/asyncMiddleware';
import AccountsTypesService from '@bigcapital/server/services/Accounts/AccountsTypesServices';
import { NextFunction, Request, Response, Router } from 'express';
import { Inject, Service } from 'typedi';

Expand Down
18 changes: 9 additions & 9 deletions packages/server/src/api/controllers/Accounts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import BaseController from '@/api/controllers/BaseController';
import CheckPolicies from '@/api/middleware/CheckPolicies';
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
import { DATATYPES_LENGTH } from '@/data/DataTypes';
import { ServiceError } from '@/exceptions';
import { AbilitySubject, AccountAction, IAccountDTO, IAccountsStructureType } from '@/interfaces';
import { AccountsApplication } from '@/services/Accounts/AccountsApplication';
import DynamicListingService from '@/services/DynamicListing/DynamicListService';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import CheckPolicies from '@bigcapital/server/api/middleware/CheckPolicies';
import asyncMiddleware from '@bigcapital/server/api/middleware/asyncMiddleware';
import { DATATYPES_LENGTH } from '@bigcapital/server/data/DataTypes';
import { ServiceError } from '@bigcapital/server/exceptions';
import { AbilitySubject, AccountAction, IAccountDTO, IAccountsStructureType } from '@bigcapital/server/interfaces';
import { AccountsApplication } from '@bigcapital/server/services/Accounts/AccountsApplication';
import { MAX_ACCOUNTS_CHART_DEPTH } from '@bigcapital/server/services/Accounts/constants';
import DynamicListingService from '@bigcapital/server/services/DynamicListing/DynamicListService';
import { NextFunction, Request, Response, Router } from 'express';
import { check, param, query } from 'express-validator';
import { MAX_ACCOUNTS_CHART_DEPTH } from 'services/Accounts/constants';
import { Inject, Service } from 'typedi';

@Service()
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/api/controllers/Agendash.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import config from '@/config';
import config from '@bigcapital/server/config';
import agendash from 'agendash';
import { Router } from 'express';
import basicAuth from 'express-basic-auth';
Expand Down
18 changes: 9 additions & 9 deletions packages/server/src/api/controllers/Authentication.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import BaseController from '@/api/controllers/BaseController';
import LoginThrottlerMiddleware from '@/api/middleware/LoginThrottlerMiddleware';
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
import { DATATYPES_LENGTH } from '@/data/DataTypes';
import { ServiceError } from '@/exceptions';
import { ILoginDTO, IRegisterDTO } from '@/interfaces';
import AuthenticationApplication from '@/services/Authentication/AuthApplication';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import LoginThrottlerMiddleware from '@bigcapital/server/api/middleware/LoginThrottlerMiddleware';
import asyncMiddleware from '@bigcapital/server/api/middleware/asyncMiddleware';
import { DATATYPES_LENGTH } from '@bigcapital/server/data/DataTypes';
import { ServiceError } from '@bigcapital/server/exceptions';
import { ILoginDTO, IRegisterDTO } from '@bigcapital/server/interfaces';
import AuthenticationApplication from '@bigcapital/server/services/Authentication/AuthApplication';
import { Request, Response, Router } from 'express';
import { ValidationChain, check } from 'express-validator';
import { Inject, Service } from 'typedi';

import AttachCurrentTenantUser from '@/api/middleware/AttachCurrentTenantUser';
import JWTAuth from '@/api/middleware/jwtAuth';
import AttachCurrentTenantUser from '@bigcapital/server/api/middleware/AttachCurrentTenantUser';
import JWTAuth from '@bigcapital/server/api/middleware/jwtAuth';
@Service()
export default class AuthenticationController extends BaseController {
@Inject()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseController from '@/api/controllers/BaseController';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import { Router } from 'express';
import Container, { Service } from 'typedi';
import { PlaidBankingController } from './PlaidBankingController';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BaseController from '@/api/controllers/BaseController';
import { PlaidApplication } from '@/services/Banking/Plaid/PlaidApplication';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import { PlaidApplication } from '@bigcapital/server/services/Banking/Plaid/PlaidApplication';
import { Request, Response, Router } from 'express';
import { Inject, Service } from 'typedi';

Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/api/controllers/BaseController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
import asyncMiddleware from '@bigcapital/server/api/middleware/asyncMiddleware';
import accepts from 'accepts';
import { NextFunction, Request, Response } from 'express';
import { matchedData, validationResult } from 'express-validator';
import { camelCase, drop, first, get, isArray, omit, set, snakeCase } from 'lodash';
import { mapKeysDeep } from 'utils';
import { mapKeysDeep } from '@bigcapital/server/utils';

export default class BaseController {
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/api/controllers/Branches/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseController from '@/api/controllers/BaseController';
import { FeatureActivationGuard } from '@/api/middleware/FeatureActivationGuard';
import { ServiceError } from '@/exceptions';
import { Features, ICreateBranchDTO, IEditBranchDTO } from '@/interfaces';
import { BranchesApplication } from '@/services/Branches/BranchesApplication';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import { FeatureActivationGuard } from '@bigcapital/server/api/middleware/FeatureActivationGuard';
import { ServiceError } from '@bigcapital/server/exceptions';
import { Features, ICreateBranchDTO, IEditBranchDTO } from '@bigcapital/server/interfaces';
import { BranchesApplication } from '@bigcapital/server/services/Branches/BranchesApplication';
import { NextFunction, Request, Response, Router } from 'express';
import { check, param } from 'express-validator';
import { Inject, Service } from 'typedi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import CheckPolicies from '@/api/middleware/CheckPolicies';
import { ServiceError } from '@/exceptions';
import CheckPolicies from '@bigcapital/server/api/middleware/CheckPolicies';
import { ServiceError } from '@bigcapital/server/exceptions';
import { NextFunction, Request, Response, Router } from 'express';
import { param } from 'express-validator';
import { Inject, Service } from 'typedi';
import BaseController from '../BaseController';

import { AbilitySubject, CashflowAction } from '@/interfaces';
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
import { AbilitySubject, CashflowAction } from '@bigcapital/server/interfaces';
import { CashflowApplication } from '@bigcapital/server/services/Cashflow/CashflowApplication';

@Service()
export default class DeleteCashflowTransactionController extends BaseController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CheckPolicies from '@/api/middleware/CheckPolicies';
import { ServiceError } from '@/exceptions';
import { AbilitySubject, CashflowAction } from '@/interfaces';
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
import CheckPolicies from '@bigcapital/server/api/middleware/CheckPolicies';
import { ServiceError } from '@bigcapital/server/exceptions';
import { AbilitySubject, CashflowAction } from '@bigcapital/server/interfaces';
import { CashflowApplication } from '@bigcapital/server/services/Cashflow/CashflowApplication';
import { NextFunction, Request, Response, Router } from 'express';
import { query } from 'express-validator';
import { Inject, Service } from 'typedi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CheckPolicies from '@/api/middleware/CheckPolicies';
import { ServiceError } from '@/exceptions';
import { AbilitySubject, CashflowAction } from '@/interfaces';
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
import CheckPolicies from '@bigcapital/server/api/middleware/CheckPolicies';
import { ServiceError } from '@bigcapital/server/exceptions';
import { AbilitySubject, CashflowAction } from '@bigcapital/server/interfaces';
import { CashflowApplication } from '@bigcapital/server/services/Cashflow/CashflowApplication';
import { NextFunction, Request, Response, Router } from 'express';
import { param } from 'express-validator';
import { Inject, Service } from 'typedi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CheckPolicies from '@/api/middleware/CheckPolicies';
import { ServiceError } from '@/exceptions';
import { AbilitySubject, CashflowAction } from '@/interfaces';
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
import CheckPolicies from '@bigcapital/server/api/middleware/CheckPolicies';
import { ServiceError } from '@bigcapital/server/exceptions';
import { AbilitySubject, CashflowAction } from '@bigcapital/server/interfaces';
import { CashflowApplication } from '@bigcapital/server/services/Cashflow/CashflowApplication';
import { NextFunction, Request, Response, Router } from 'express';
import { check, param, query } from 'express-validator';
import { Inject, Service } from 'typedi';
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/api/controllers/Contacts/Contacts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseController from '@/api/controllers/BaseController';
import { DATATYPES_LENGTH } from '@/data/DataTypes';
import { ServiceError } from '@/exceptions';
import ContactsService from '@/services/Contacts/ContactsService';
import DynamicListingService from '@/services/DynamicListing/DynamicListService';
import BaseController from '@bigcapital/server/api/controllers/BaseController';
import { DATATYPES_LENGTH } from '@bigcapital/server/data/DataTypes';
import { ServiceError } from '@bigcapital/server/exceptions';
import ContactsService from '@bigcapital/server/services/Contacts/ContactsService';
import DynamicListingService from '@bigcapital/server/services/DynamicListing/DynamicListService';
import { NextFunction, Request, Response, Router } from 'express';
import { ValidationChain, body, check, param, query } from 'express-validator';
import { Inject, Service } from 'typedi';
Expand Down
Loading

0 comments on commit b6db2c7

Please sign in to comment.