test(ns-paystack): initialize transaction

This commit is contained in:
Brian Pooe 2023-06-11 15:59:11 +02:00
parent 68a336f21b
commit 9fa40831ca
67 changed files with 25189 additions and 26544 deletions

View file

@ -1,42 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}

View file

@ -1,32 +1,32 @@
name: CI
on:
push:
branches:
- master
pull_request:
push:
branches:
- master
pull_request:
env:
HUSKY: 0
HUSKY: 0
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- run: npm ci
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- run: npm ci
- run: npx nx format:check
- run: npx nx affected -t lint --parallel=3
- run: npx nx affected -t test --parallel=3 --configuration=ci
- run: npx nx affected -t build --parallel=3
- run: npx nx format:check
- run: npx nx affected -t lint --parallel=3
- run: npx nx affected -t test --parallel=3 --configuration=ci
- run: npx nx affected -t build --parallel=3
- name: Release
if: ${{ success() && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npx nx run-many --target release --all
- name: Release
if: ${{ success() && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npx nx run-many --target release --all

View file

@ -1,6 +1,7 @@
{
"singleQuote": true,
"tabWidth": 4,
"printWidth": 80,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"printWidth": 80,
"trailingComma": "none",
"bracketSpacing": true
}

View file

@ -1,8 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}

View file

@ -6,10 +6,10 @@ with Angular, you'll find a range of useful libraries and tools here.
## Table of Contents
- [Getting Started](#getting-started)
- [Libraries](#libraries)
- [Contributing](#contributing)
- [License](#license)
- [Getting Started](#getting-started)
- [Libraries](#libraries)
- [Contributing](#contributing)
- [License](#license)
## Getting Started
@ -28,9 +28,9 @@ To get started with the devtools-bp monorepo, follow these steps:
1. **ns-paystack**: Powerful library that provides seamless integration with the Paystack payment gateway for your
NestJS applications. You can easily handle payment transactions with minimal effort.
- Usage:
- Installation: `npm install @devtools-bp/ns-paystack`
- Documentation: [Link to documentation](https://github.com/brianpooe/devtools-bp/blob/main/libs/ns-paystack/README.md)
- Usage:
- Installation: `npm install @devtools-bp/ns-paystack`
- Documentation: [Link to documentation](https://github.com/brianpooe/devtools-bp/blob/main/libs/ns-paystack/README.md)
### Angular Libraries

View file

@ -1,18 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View file

@ -1,14 +1,11 @@
/* eslint-disable */
export default {
displayName: 'ns-paystack-demo',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{ tsconfig: '<rootDir>/tsconfig.spec.json' }
]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/ns-paystack-demo'
displayName: 'ns-paystack-demo',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/ns-paystack-demo'
};

View file

@ -1,64 +1,64 @@
{
"name": "ns-paystack-demo",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/ns-paystack-demo/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/ns-paystack-demo",
"main": "apps/ns-paystack-demo/src/main.ts",
"tsConfig": "apps/ns-paystack-demo/tsconfig.app.json",
"assets": ["apps/ns-paystack-demo/src/assets"],
"isolatedConfig": true,
"webpackConfig": "apps/ns-paystack-demo/webpack.config.js"
},
"configurations": {
"development": {},
"production": {}
}
},
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "ns-paystack-demo:build"
},
"configurations": {
"development": {
"buildTarget": "ns-paystack-demo:build:development"
},
"production": {
"buildTarget": "ns-paystack-demo:build:production"
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/ns-paystack-demo/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/ns-paystack-demo/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
"name": "ns-paystack-demo",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/ns-paystack-demo/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/ns-paystack-demo",
"main": "apps/ns-paystack-demo/src/main.ts",
"tsConfig": "apps/ns-paystack-demo/tsconfig.app.json",
"assets": ["apps/ns-paystack-demo/src/assets"],
"isolatedConfig": true,
"webpackConfig": "apps/ns-paystack-demo/webpack.config.js"
},
"configurations": {
"development": {},
"production": {}
}
},
"tags": []
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "ns-paystack-demo:build"
},
"configurations": {
"development": {
"buildTarget": "ns-paystack-demo:build:development"
},
"production": {
"buildTarget": "ns-paystack-demo:build:production"
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/ns-paystack-demo/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/ns-paystack-demo/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}

View file

@ -6,17 +6,17 @@ import { TransactionsService } from './transactions/services/transactions.servic
import { TransactionController } from './transactions/controllers/transaction.controller';
@Module({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
],
controllers: [TransactionController],
providers: [TransactionsService, ConfigService]
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
],
controllers: [TransactionController],
providers: [TransactionsService, ConfigService]
})
export class AppModule {}

View file

@ -2,45 +2,45 @@ import { Test, TestingModule } from '@nestjs/testing';
import { TransactionController } from './transaction.controller';
import { TransactionsService } from '../services/transactions.service';
import {
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN,
NsPaystackModule,
PsTransactionsService
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN,
NsPaystackModule,
PsTransactionsService
} from '@devtools-bp/ns-paystack';
import { ConfigService } from '@nestjs/config';
import { HttpModule } from '@nestjs/axios';
describe(TransactionController.name, () => {
let controller: TransactionController;
let controller: TransactionController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
}),
HttpModule
],
controllers: [TransactionController],
providers: [
TransactionsService,
PsTransactionsService,
{
provide: MODULE_OPTIONS_TOKEN,
useClass: ConfigurableModuleClass
}
]
}).compile();
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
}),
HttpModule
],
controllers: [TransactionController],
providers: [
TransactionsService,
PsTransactionsService,
{
provide: MODULE_OPTIONS_TOKEN,
useClass: ConfigurableModuleClass
}
]
}).compile();
controller = module.get<TransactionController>(TransactionController);
});
controller = module.get<TransactionController>(TransactionController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View file

@ -1,88 +1,88 @@
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import {
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel,
PsTransactionTotalsRequestModel,
PsTransactionTotalsResponseModel,
PsVerifyTransactionResponseModel,
PsViewTransactionTimeLineResponseModel
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel,
PsTransactionTotalsRequestModel,
PsTransactionTotalsResponseModel,
PsVerifyTransactionResponseModel,
PsViewTransactionTimeLineResponseModel
} from '@devtools-bp/ns-paystack';
import { Observable } from 'rxjs';
import { TransactionsService } from '../services/transactions.service';
@Controller('transaction')
export class TransactionController {
constructor(private readonly transactionsService: TransactionsService) {}
constructor(private readonly transactionsService: TransactionsService) {}
@Post('initialize')
initialize(
@Body() payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.transactionsService.initializeTransaction(payload);
}
@Post('initialize')
initialize(
@Body() payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.transactionsService.initializeTransaction(payload);
}
@Get('verify/:reference')
verifyTransaction(
@Param('reference') reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.transactionsService.verifyTransaction(reference);
}
@Get('verify/:reference')
verifyTransaction(
@Param('reference') reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.transactionsService.verifyTransaction(reference);
}
@Get()
listTransactions(
@Query() queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.transactionsService.listTransactions(queryParamsPayload);
}
@Get()
listTransactions(
@Query() queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.transactionsService.listTransactions(queryParamsPayload);
}
@Get(':transactionId')
fetchTransaction(
@Param('transactionId') transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.transactionsService.fetchTransaction(transactionId);
}
@Get(':transactionId')
fetchTransaction(
@Param('transactionId') transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.transactionsService.fetchTransaction(transactionId);
}
@Post('charge_authorization')
chargeTransaction(
@Body() payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.transactionsService.chargeTransaction(payload);
}
@Post('charge_authorization')
chargeTransaction(
@Body() payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.transactionsService.chargeTransaction(payload);
}
@Get('timeline/:idOrReference')
viewTransactionTimeline(
@Param('idOrReference') idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.transactionsService.viewTransactionTimeline(idOrReference);
}
@Get('timeline/:idOrReference')
viewTransactionTimeline(
@Param('idOrReference') idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.transactionsService.viewTransactionTimeline(idOrReference);
}
@Get()
transactionTotals(
@Query() queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.transactionsService.transactionTotals(queryParamsPayload);
}
@Get()
transactionTotals(
@Query() queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.transactionsService.transactionTotals(queryParamsPayload);
}
@Get()
exportTransaction(
@Query() queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.transactionsService.exportTransaction(queryParamsPayload);
}
@Get()
exportTransaction(
@Query() queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.transactionsService.exportTransaction(queryParamsPayload);
}
@Post('partial_debit')
partialDebit(
@Body() payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.transactionsService.partialDebit(payload);
}
@Post('partial_debit')
partialDebit(
@Body() payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.transactionsService.partialDebit(payload);
}
}

View file

@ -4,27 +4,27 @@ import { NsPaystackModule } from '@devtools-bp/ns-paystack';
import { ConfigService } from '@nestjs/config';
describe(TransactionsService.name, () => {
let service: TransactionsService;
let service: TransactionsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
],
providers: [TransactionsService]
}).compile();
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
],
providers: [TransactionsService]
}).compile();
service = module.get<TransactionsService>(TransactionsService);
});
service = module.get<TransactionsService>(TransactionsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View file

@ -1,83 +1,79 @@
import { Injectable } from '@nestjs/common';
import {
PsTransactionsService,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsVerifyTransactionResponseModel,
PsFetchTransactionResponseModel,
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsViewTransactionTimeLineResponseModel,
PsTransactionTotalsResponseModel,
PsTransactionTotalsRequestModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel
PsTransactionsService,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsVerifyTransactionResponseModel,
PsFetchTransactionResponseModel,
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsViewTransactionTimeLineResponseModel,
PsTransactionTotalsResponseModel,
PsTransactionTotalsRequestModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel
} from '@devtools-bp/ns-paystack';
import { Observable } from 'rxjs';
@Injectable()
export class TransactionsService {
constructor(
private readonly psTransactionsService: PsTransactionsService
) {}
constructor(private readonly psTransactionsService: PsTransactionsService) {}
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.psTransactionsService.initializeTransaction(payload);
}
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.psTransactionsService.initializeTransaction(payload);
}
verifyTransaction(
reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.psTransactionsService.verifyTransaction(reference);
}
verifyTransaction(
reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.psTransactionsService.verifyTransaction(reference);
}
listTransactions(
queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.psTransactionsService.listTransactions(queryParamsPayload);
}
listTransactions(
queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.psTransactionsService.listTransactions(queryParamsPayload);
}
fetchTransaction(
transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.psTransactionsService.fetchTransaction(transactionId);
}
fetchTransaction(
transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.psTransactionsService.fetchTransaction(transactionId);
}
chargeTransaction(
payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.psTransactionsService.chargeTransaction(payload);
}
chargeTransaction(
payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.psTransactionsService.chargeTransaction(payload);
}
viewTransactionTimeline(
idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.psTransactionsService.viewTransactionTimeline(
idOrReference
);
}
viewTransactionTimeline(
idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.psTransactionsService.viewTransactionTimeline(idOrReference);
}
transactionTotals(
queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.psTransactionsService.transactionTotals(queryParamsPayload);
}
transactionTotals(
queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.psTransactionsService.transactionTotals(queryParamsPayload);
}
exportTransaction(
queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.psTransactionsService.exportTransaction(queryParamsPayload);
}
exportTransaction(
queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.psTransactionsService.exportTransaction(queryParamsPayload);
}
partialDebit(
payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.psTransactionsService.partialDebit(payload);
}
partialDebit(
payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.psTransactionsService.partialDebit(payload);
}
}

View file

@ -9,14 +9,14 @@ import { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
}
bootstrap();

View file

@ -1,12 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2015"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2015"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}

View file

@ -1,16 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}

View file

@ -1,14 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

View file

@ -2,7 +2,7 @@ const { composePlugins, withNx } = require('@nx/webpack');
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Update the webpack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`
return config;
// Update the webpack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`
return config;
});

View file

@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes']
extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes']
};

View file

@ -1,5 +1,5 @@
import { getJestProjects } from '@nx/jest';
export default {
projects: getJestProjects()
projects: getJestProjects()
};

View file

@ -1,18 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View file

@ -28,11 +28,11 @@ import { TransactionsService } from './transactions/services/transactions.servic
import { TransactionController } from './transactions/controllers/transaction.controller';
@Module({
imports: [
NsPaystackModule.register({
secretKey: 'PAYSTACK_SECRET_KEY'
})
]
imports: [
NsPaystackModule.register({
secretKey: 'PAYSTACK_SECRET_KEY'
})
]
})
export class AppModule {}
```
@ -46,16 +46,16 @@ import { NsPaystackModule } from '@devtools-bp/ns-paystack';
import { ConfigService } from '@nestjs/config';
@Module({
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
]
imports: [
NsPaystackModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
secretKey: configService.get('PAYSTACK_SECRET_KEY')
};
},
inject: [ConfigService]
})
]
})
export class AppModule {}
```
@ -67,22 +67,20 @@ export class AppModule {}
```typescript
import { Injectable } from '@nestjs/common';
import {
PsTransactionsService,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel
PsTransactionsService,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel
} from '@devtools-bp/ns-paystack';
@Injectable()
export class TransactionsService {
constructor(
private readonly psTransactionsService: PsTransactionsService
) {}
constructor(private readonly psTransactionsService: PsTransactionsService) {}
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Promise<PsInitializeTransactionResponseModel> {
return this.psTransactionsService.initializeTransaction(payload);
}
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Promise<PsInitializeTransactionResponseModel> {
return this.psTransactionsService.initializeTransaction(payload);
}
}
```
@ -91,65 +89,65 @@ export class TransactionsService {
```typescript
import { Body, Controller, Post } from '@nestjs/common';
import {
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel
} from '@devtools-bp/ns-paystack';
import { TransactionsService } from '../services/transactions.service';
@Controller('transaction')
export class TransactionController {
constructor(private readonly transactionsService: TransactionsService) {}
constructor(private readonly transactionsService: TransactionsService) {}
@Post('initialize')
initialize(
@Body() payload: PsInitializeTransactionRequestModel
): Promise<PsInitializeTransactionResponseModel> {
return this.transactionsService.initializeTransaction(payload);
}
@Post('initialize')
initialize(
@Body() payload: PsInitializeTransactionRequestModel
): Promise<PsInitializeTransactionResponseModel> {
return this.transactionsService.initializeTransaction(payload);
}
}
```
### API ENDPOINTS
- [x] **Transactions** <span style="color:green;">&#x2714;</span>
- [x] Initialize Transaction <span style="color:green;">&#x2714;</span>
- [x] Verify Transaction <span style="color:green;">&#x2714;</span>
- [x] List Transaction <span style="color:green;">&#x2714;</span>
- [x] Fetch Transaction <span style="color:green;">&#x2714;</span>
- [x] Charge Transaction <span style="color:green;">&#x2714;</span>
- [x] View Transaction Timeline <span style="color:green;">&#x2714;</span>
- [x] Transaction Totals <span style="color:green;">&#x2714;</span>
- [x] Export Transaction <span style="color:green;">&#x2714;</span>
- [x] Partial Debit <span style="color:green;">&#x2714;</span>
- [ ] **Transaction Splits** &#x23F3;
- [ ] Create Split &#x23F3;
- [ ] List Split &#x23F3;
- [ ] Fetch Split &#x23F3;
- [ ] Update Split &#x23F3;
- [ ] Add/Update Subaccount Split &#x23F3;
- [ ] Remove Subaccount from Split &#x23F3;
- [ ] **Terminal**
- [ ] **Customers**
- [ ] **Dedicated Virtual Accounts**
- [ ] **Apple Pay**
- [ ] **Subaccounts**
- [ ] **Plans**
- [ ] **Subscriptions**
- [ ] **Products**
- [ ] **Payment Pages**
- [ ] **Payment Requests**
- [ ] **Settlements**
- [ ] **Transaction Recipients**
- [ ] **Transfers**
- [ ] **Transfers Control**
- [ ] **Bulk Charges**
- [ ] **Integration**
- [ ] **Charge**
- [ ] **Disputes**
- [ ] **Refunds**
- [ ] **Verification**
- [ ] **Miscellaneous**
- [x] **Transactions** <span style="color:green;">&#x2714;</span>
- [x] Initialize Transaction <span style="color:green;">&#x2714;</span>
- [x] Verify Transaction <span style="color:green;">&#x2714;</span>
- [x] List Transaction <span style="color:green;">&#x2714;</span>
- [x] Fetch Transaction <span style="color:green;">&#x2714;</span>
- [x] Charge Transaction <span style="color:green;">&#x2714;</span>
- [x] View Transaction Timeline <span style="color:green;">&#x2714;</span>
- [x] Transaction Totals <span style="color:green;">&#x2714;</span>
- [x] Export Transaction <span style="color:green;">&#x2714;</span>
- [x] Partial Debit <span style="color:green;">&#x2714;</span>
- [ ] **Transaction Splits** &#x23F3;
- [ ] Create Split &#x23F3;
- [ ] List Split &#x23F3;
- [ ] Fetch Split &#x23F3;
- [ ] Update Split &#x23F3;
- [ ] Add/Update Subaccount Split &#x23F3;
- [ ] Remove Subaccount from Split &#x23F3;
- [ ] **Terminal**
- [ ] **Customers**
- [ ] **Dedicated Virtual Accounts**
- [ ] **Apple Pay**
- [ ] **Subaccounts**
- [ ] **Plans**
- [ ] **Subscriptions**
- [ ] **Products**
- [ ] **Payment Pages**
- [ ] **Payment Requests**
- [ ] **Settlements**
- [ ] **Transaction Recipients**
- [ ] **Transfers**
- [ ] **Transfers Control**
- [ ] **Bulk Charges**
- [ ] **Integration**
- [ ] **Charge**
- [ ] **Disputes**
- [ ] **Refunds**
- [ ] **Verification**
- [ ] **Miscellaneous**
## Contributing
@ -164,4 +162,4 @@ terms and conditions when using the libraries and tools provided in this reposit
## Authors
- [Brian Pooe](https://github.com/brianpooe)
- [Brian Pooe](https://github.com/brianpooe)

View file

@ -1,14 +1,11 @@
/* eslint-disable */
export default {
displayName: 'ns-paystack',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{ tsconfig: '<rootDir>/tsconfig.spec.json' }
]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/ns-paystack'
displayName: 'ns-paystack',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/ns-paystack'
};

View file

@ -1,47 +1,47 @@
{
"name": "@devtools-bp/ns-paystack",
"description": "Powerful library that provides seamless integration with the Paystack payment gateway for your NestJS applications. You can easily handle payment transactions with minimal effort.",
"version": "0.0.0-semantic-release",
"scripts": {
"test": "echo \"Error:no test specified\" && exit 1"
},
"author": {
"name": "Brian Pooe",
"email": "brian.method@gmail.com"
},
"type": "commonjs",
"repository": {
"type": "git",
"url": "https://github.com/brianpooe/devtools-bp.git",
"directory": "libs/ns-paystack"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/brianpooe/devtools-bp/issues",
"email": "brian.method@gmail.com"
},
"homepage": "https://github.com/brianpooe/devtools-bp/tree/main/libs/ns-paystack#readme",
"keywords": [
"nestjs",
"paystack",
"ns-paystack",
"library",
"wrapper",
"payment",
"integration",
"API",
"devtools-bp"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"tag": "latest"
},
"peerDependencies": {
"@nestjs/common": "^9.1.1",
"@nestjs/core": "^9.1.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"@nestjs/config": "^2.3.2"
}
"name": "@devtools-bp/ns-paystack",
"description": "Powerful library that provides seamless integration with the Paystack payment gateway for your NestJS applications. You can easily handle payment transactions with minimal effort.",
"version": "0.0.0-semantic-release",
"scripts": {
"test": "echo \"Error:no test specified\" && exit 1"
},
"author": {
"name": "Brian Pooe",
"email": "brian.method@gmail.com"
},
"type": "commonjs",
"repository": {
"type": "git",
"url": "https://github.com/brianpooe/devtools-bp.git",
"directory": "libs/ns-paystack"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/brianpooe/devtools-bp/issues",
"email": "brian.method@gmail.com"
},
"homepage": "https://github.com/brianpooe/devtools-bp/tree/main/libs/ns-paystack#readme",
"keywords": [
"nestjs",
"paystack",
"ns-paystack",
"library",
"wrapper",
"payment",
"integration",
"API",
"devtools-bp"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"tag": "latest"
},
"peerDependencies": {
"@nestjs/common": "^9.1.1",
"@nestjs/core": "^9.1.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"@nestjs/config": "^2.3.2"
}
}

View file

@ -1,56 +1,56 @@
{
"name": "ns-paystack",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/ns-paystack/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/ns-paystack",
"tsConfig": "libs/ns-paystack/tsconfig.lib.json",
"packageJson": "libs/ns-paystack/package.json",
"main": "libs/ns-paystack/src/index.ts",
"assets": ["libs/ns-paystack/*.md"]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs ns-paystack {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/ns-paystack/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ns-paystack/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"release": {
"executor": "nx:run-commands",
"outputs": [],
"options": {
"commands": [
{
"command": "npx semantic-release-plus --debug --extends ./libs/ns-paystack/release.config.js"
}
]
}
}
"name": "ns-paystack",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/ns-paystack/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/ns-paystack",
"tsConfig": "libs/ns-paystack/tsconfig.lib.json",
"packageJson": "libs/ns-paystack/package.json",
"main": "libs/ns-paystack/src/index.ts",
"assets": ["libs/ns-paystack/*.md"]
}
},
"tags": []
"publish": {
"command": "node tools/scripts/publish.mjs ns-paystack {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/ns-paystack/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ns-paystack/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"release": {
"executor": "nx:run-commands",
"outputs": [],
"options": {
"commands": [
{
"command": "npx semantic-release-plus --debug --extends ./libs/ns-paystack/release.config.js"
}
]
}
}
},
"tags": []
}

View file

@ -3,28 +3,28 @@ const appPath = `libs/${appName}`;
const artifactName = appName;
module.exports = {
name: appName,
pkgRoot: `dist/${appPath}`,
tagFormat: artifactName + '-v${version}',
commitPaths: ['force-release.md', `${appPath}/*`],
assets: [`${appPath}/README.md`, `${appPath}/CHANGELOG.md`],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: `${appPath}/CHANGELOG.md`
}
],
'@semantic-release/npm',
[
'@semantic-release/git',
{
message:
`chore(release): ${artifactName}` +
'-v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
]
name: appName,
pkgRoot: `dist/${appPath}`,
tagFormat: artifactName + '-v${version}',
commitPaths: ['force-release.md', `${appPath}/*`],
assets: [`${appPath}/README.md`, `${appPath}/CHANGELOG.md`],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: `${appPath}/CHANGELOG.md`
}
],
'@semantic-release/npm',
[
'@semantic-release/git',
{
message:
`chore(release): ${artifactName}` +
'-v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
]
]
};

View file

@ -2,4 +2,4 @@ import { ConfigurableModuleBuilder } from '@nestjs/common';
import { PsConfigModel } from '../../models';
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } =
new ConfigurableModuleBuilder<PsConfigModel>().build();
new ConfigurableModuleBuilder<PsConfigModel>().build();

View file

@ -1,5 +1,5 @@
import { handleResponseAndError } from './handle-response-and-error.util';
describe(handleResponseAndError.name, () => {
test.todo('should handle response and error');
test.todo('should handle response and error');
});

View file

@ -1,61 +1,49 @@
import { AxiosError, AxiosResponse } from 'axios';
import {
catchError,
map,
Observable,
OperatorFunction,
throwError
catchError,
map,
Observable,
OperatorFunction,
throwError
} from 'rxjs';
import { HttpException, HttpStatus } from '@nestjs/common';
export const handleResponseAndError = <
T extends AxiosResponse,
R
T extends AxiosResponse,
R
>(): OperatorFunction<T, R> => {
return (source: Observable<T>): Observable<R> => {
return source.pipe(
map(({ data }) => data),
catchError((error: AxiosError<HttpException>) => {
console.error(error);
const errorMessage = error.response?.data || {
status: false,
message: 'Something went wrong. Please try again later.'
};
switch (error.response?.status) {
case HttpStatus.BAD_REQUEST:
return throwError(
() =>
new HttpException(
errorMessage,
HttpStatus.BAD_REQUEST
)
);
case HttpStatus.UNAUTHORIZED:
return throwError(
() =>
new HttpException(
errorMessage,
HttpStatus.UNAUTHORIZED
)
);
case HttpStatus.NOT_FOUND:
return throwError(
() =>
new HttpException(
errorMessage,
HttpStatus.NOT_FOUND
)
);
default:
return throwError(
() =>
new HttpException(
errorMessage,
HttpStatus.INTERNAL_SERVER_ERROR
)
);
}
})
);
};
return (source: Observable<T>): Observable<R> => {
return source.pipe(
map(({ data }) => data),
catchError((error: AxiosError<HttpException>) => {
console.error(error);
const errorMessage = error.response?.data || {
status: false,
message: 'Something went wrong. Please try again later.'
};
switch (error.response?.status) {
case HttpStatus.BAD_REQUEST:
return throwError(
() => new HttpException(errorMessage, HttpStatus.BAD_REQUEST)
);
case HttpStatus.UNAUTHORIZED:
return throwError(
() => new HttpException(errorMessage, HttpStatus.UNAUTHORIZED)
);
case HttpStatus.NOT_FOUND:
return throwError(
() => new HttpException(errorMessage, HttpStatus.NOT_FOUND)
);
default:
return throwError(
() =>
new HttpException(
errorMessage,
HttpStatus.INTERNAL_SERVER_ERROR
)
);
}
})
);
};
};

View file

@ -0,0 +1,28 @@
import { catchError, EMPTY, finalize, Observable, take, timeout } from 'rxjs';
interface ObservableTestingModel<T> {
actualObservable: Observable<T>;
done: (resp?: unknown) => void;
}
export const expectObservable = <T>(
model: ObservableTestingModel<T>,
matcher?: (result: T) => void,
finalized?: () => void
): void => {
model.actualObservable
.pipe(
timeout(60000),
take(1),
catchError((e: Error) => {
model.done(e);
return EMPTY;
}),
finalize(() => finalized?.())
)
.subscribe((result: T) => {
matcher?.(result);
model.done();
});
};

View file

@ -1,17 +1,17 @@
import { PsChannelsModel } from './ps-channels.model';
export interface PsAuthorizationModel {
authorization_code?: string | null;
bin?: string | null;
last4?: string | null;
exp_month?: string | null;
exp_year?: string | null;
channel?: PsChannelsModel;
card_type?: string | null;
bank?: string | null;
country_code?: string | null;
brand?: string | null;
reusable?: boolean;
signature?: string | null;
account_name?: string | null;
authorization_code?: string | null;
bin?: string | null;
last4?: string | null;
exp_month?: string | null;
exp_year?: string | null;
channel?: PsChannelsModel;
card_type?: string | null;
bank?: string | null;
country_code?: string | null;
brand?: string | null;
reusable?: boolean;
signature?: string | null;
account_name?: string | null;
}

View file

@ -1,7 +1,7 @@
export interface PsBaseMetaModel {
total: number;
skipped: number;
perPage: number;
page: number;
pageCount: number;
total: number;
skipped: number;
perPage: number;
page: number;
pageCount: number;
}

View file

@ -1,7 +1,7 @@
import { PsBaseMetaModel } from './ps-base-meta.model';
export interface PsBaseModel {
status: boolean;
message: string;
meta?: PsBaseMetaModel;
status: boolean;
message: string;
meta?: PsBaseMetaModel;
}

View file

@ -1,8 +1,8 @@
export type PsChannelsModel =
| 'card'
| 'bank'
| 'ussd'
| 'qr'
| 'mobile_money'
| 'bank_transfer'
| 'eft';
| 'card'
| 'bank'
| 'ussd'
| 'qr'
| 'mobile_money'
| 'bank_transfer'
| 'eft';

View file

@ -1,15 +1,15 @@
import { PsChannelsModel } from './ps-channels.model';
export interface PsChargeTransactionRequestModel {
amount: string;
email: string;
authorization_code: string;
reference?: string;
currency: string;
metadata?: string;
channels?: Array<PsChannelsModel>;
subaccount: string;
transaction_charge: number;
bearer: string;
queue: boolean;
amount: string;
email: string;
authorization_code: string;
reference?: string;
currency: string;
metadata?: string;
channels?: Array<PsChannelsModel>;
subaccount: string;
transaction_charge: number;
bearer: string;
queue: boolean;
}

View file

@ -1,25 +1,25 @@
import { PsAuthorizationModel, PsBaseModel, PsCustomerModel } from './';
export interface PsChargeTransactionResponseModel extends PsBaseModel {
data: PsChargeTransactionResponseDataModel;
data: PsChargeTransactionResponseDataModel;
}
export interface PsChargeTransactionResponseDataModel {
amount: number;
currency: string;
transaction_date: string;
status: string;
reference: string;
domain: string;
metadata: string;
gateway_response: string;
message?: null;
channel: string;
ip_address?: null;
log?: null;
fees: number;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan?: null;
id: number;
amount: number;
currency: string;
transaction_date: string;
status: string;
reference: string;
domain: string;
metadata: string;
gateway_response: string;
message?: null;
channel: string;
ip_address?: null;
log?: null;
fees: number;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan?: null;
id: number;
}

View file

@ -1,6 +1,6 @@
export interface PsConfigModel {
/**
* Your Paystack API key - secret key
*/
secretKey: string;
/**
* Your Paystack API key - secret key
*/
secretKey: string;
}

View file

@ -1,5 +1,5 @@
export interface PsCustomerFieldsEntityModel {
display_name: string;
variable_name: string;
value: string;
display_name: string;
variable_name: string;
value: string;
}

View file

@ -1,11 +1,11 @@
export interface PsCustomerModel {
first_name: string;
last_name: string;
email: string;
phone: string;
metadata?: unknown;
customer_code: string;
id?: number | null;
risk_action?: string | null;
international_format_phone: unknown;
first_name: string;
last_name: string;
email: string;
phone: string;
metadata?: unknown;
customer_code: string;
id?: number | null;
risk_action?: string | null;
international_format_phone: unknown;
}

View file

@ -1,13 +1,13 @@
export interface PsExportTransactionRequestModel {
perPage: number;
page: number;
from?: string;
to?: string;
customer?: number;
status?: string;
currency?: string;
amount?: number;
settled?: boolean;
settlement?: number;
payment_page?: number;
perPage: number;
page: number;
from?: string;
to?: string;
customer?: number;
status?: string;
currency?: string;
amount?: number;
settled?: boolean;
settlement?: number;
payment_page?: number;
}

View file

@ -1,8 +1,8 @@
export interface PsExportTransactionResponseModel {
data: PsExportTransactionResponseDataModel;
data: PsExportTransactionResponseDataModel;
}
export interface PsExportTransactionResponseDataModel {
path: string;
expiresAt: string;
path: string;
expiresAt: string;
}

View file

@ -1,38 +1,38 @@
import {
PsAuthorizationModel,
PsBaseModel,
PsCustomerModel,
PsLogModel,
PsMetadataModel
PsAuthorizationModel,
PsBaseModel,
PsCustomerModel,
PsLogModel,
PsMetadataModel
} from './';
export interface PsFetchTransactionResponseModel extends PsBaseModel {
data: PsFetchTransactionResponseDataModel;
data: PsFetchTransactionResponseDataModel;
}
export interface PsFetchTransactionResponseDataModel {
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message?: null;
gateway_response: string;
paid_at: string;
created_at: string;
channel: string;
currency: string;
ip_address: string;
metadata: PsMetadataModel;
log: PsLogModel;
fees: number;
fees_split?: null;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: unknown;
subaccount: unknown;
order_id?: null;
paidAt: string;
createdAt: string;
requested_amount: number;
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message?: null;
gateway_response: string;
paid_at: string;
created_at: string;
channel: string;
currency: string;
ip_address: string;
metadata: PsMetadataModel;
log: PsLogModel;
fees: number;
fees_split?: null;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: unknown;
subaccount: unknown;
order_id?: null;
paidAt: string;
createdAt: string;
requested_amount: number;
}

View file

@ -1,5 +1,5 @@
export interface PsHistoryModel {
type: string;
message: string;
time: number;
type: string;
message: string;
time: number;
}

View file

@ -1,13 +1,13 @@
import { PsChannelsModel } from './ps-channels.model';
export interface PsInitializeTransactionRequestModel {
amount: string;
email: string;
currency?: string;
reference?: string;
callback_url?: string;
plan?: string;
invoice_limit?: number;
metadata?: string;
channels?: Array<PsChannelsModel>;
amount: string;
email: string;
currency?: string;
reference?: string;
callback_url?: string;
plan?: string;
invoice_limit?: number;
metadata?: string;
channels?: Array<PsChannelsModel>;
}

View file

@ -1,11 +1,11 @@
import { PsBaseModel } from './ps-base.model';
export interface PsInitializeTransactionResponseModel extends PsBaseModel {
data: PsInitializeTransactionResponseDataModel;
data: PsInitializeTransactionResponseDataModel;
}
export interface PsInitializeTransactionResponseDataModel {
authorization_url: string;
access_code: string;
reference: string;
authorization_url: string;
access_code: string;
reference: string;
}

View file

@ -1,10 +1,10 @@
export interface PsListTransactionsQueryParamsModel {
perPage: number;
page: number;
customer?: number;
terminalid?: string;
status?: string;
from?: string;
to?: string;
amount?: number;
perPage: number;
page: number;
customer?: number;
terminalid?: string;
status?: string;
from?: string;
to?: string;
amount?: number;
}

View file

@ -1,36 +1,36 @@
import {
PsBaseModel,
PsCustomerModel,
PsAuthorizationModel,
PsLogModel,
PsMetadataModel
PsBaseModel,
PsCustomerModel,
PsAuthorizationModel,
PsLogModel,
PsMetadataModel
} from './';
export interface PsListTransactionsResponseModel extends PsBaseModel {
data?: PsListTransactionsResponseDataModel[] | null;
data?: PsListTransactionsResponseDataModel[] | null;
}
export interface PsListTransactionsResponseDataModel {
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message?: null;
gateway_response: string;
paid_at?: null;
created_at: string;
channel: string;
currency: string;
ip_address?: null;
metadata?: PsMetadataModel | null;
timeline?: null;
customer: PsCustomerModel;
authorization: PsAuthorizationModel;
plan?: unknown | null;
requested_amount: number;
log?: PsLogModel;
fees?: null;
paidAt?: string | null;
createdAt?: string | null;
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message?: null;
gateway_response: string;
paid_at?: null;
created_at: string;
channel: string;
currency: string;
ip_address?: null;
metadata?: PsMetadataModel | null;
timeline?: null;
customer: PsCustomerModel;
authorization: PsAuthorizationModel;
plan?: unknown | null;
requested_amount: number;
log?: PsLogModel;
fees?: null;
paidAt?: string | null;
createdAt?: string | null;
}

View file

@ -1,12 +1,12 @@
import { PsHistoryModel } from './ps-history.model';
export interface PsLogModel {
start_time: number;
time_spent: number;
attempts: number;
errors: number;
success: boolean;
mobile: boolean;
input?: null[] | null;
history?: PsHistoryModel[] | null;
start_time: number;
time_spent: number;
attempts: number;
errors: number;
success: boolean;
mobile: boolean;
input?: null[] | null;
history?: PsHistoryModel[] | null;
}

View file

@ -1,6 +1,6 @@
import { PsCustomerFieldsEntityModel } from './ps-customer-fields-entity.model';
export interface PsMetadataModel {
custom_fields?: PsCustomerFieldsEntityModel[] | null;
referrer?: string;
custom_fields?: PsCustomerFieldsEntityModel[] | null;
referrer?: string;
}

View file

@ -1,8 +1,8 @@
export interface PsPartialDebitRequestModel {
authorization_code: string;
currency: string;
amount: string;
email: string;
reference?: string;
at_least?: string;
authorization_code: string;
currency: string;
amount: string;
email: string;
reference?: string;
at_least?: string;
}

View file

@ -1,26 +1,26 @@
import { PsAuthorizationModel, PsCustomerModel } from './';
export interface PsPartialDebitResponseModel {
data: PsPartialDebitResponseDataModel;
data: PsPartialDebitResponseDataModel;
}
export interface PsPartialDebitResponseDataModel {
amount: number;
currency: string;
transaction_date: string;
status: string;
reference: string;
domain: string;
metadata: string;
gateway_response: string;
message?: null;
channel: string;
ip_address?: null;
log?: null;
fees: number;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: number;
requested_amount: number;
id: number;
amount: number;
currency: string;
transaction_date: string;
status: string;
reference: string;
domain: string;
metadata: string;
gateway_response: string;
message?: null;
channel: string;
ip_address?: null;
log?: null;
fees: number;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: number;
requested_amount: number;
id: number;
}

View file

@ -1,6 +1,6 @@
export interface PsTransactionTotalsRequestModel {
perPage: number;
page: number;
from?: string;
to?: string;
perPage: number;
page: number;
from?: string;
to?: string;
}

View file

@ -1,21 +1,21 @@
export interface PsTransactionTotalsResponseModel {
data: PsTransactionTotalsResponseDataModel;
data: PsTransactionTotalsResponseDataModel;
}
export interface PsTransactionTotalsResponseDataModel {
total_transactions: number;
unique_customers: number;
total_volume: number;
total_volume_by_currency?:
| PsTotalVolumeByCurrencyOrPendingTransfersByCurrencyModel[]
| null;
pending_transfers: number;
pending_transfers_by_currency?:
| PsTotalVolumeByCurrencyOrPendingTransfersByCurrencyModel[]
| null;
total_transactions: number;
unique_customers: number;
total_volume: number;
total_volume_by_currency?:
| PsTotalVolumeByCurrencyOrPendingTransfersByCurrencyModel[]
| null;
pending_transfers: number;
pending_transfers_by_currency?:
| PsTotalVolumeByCurrencyOrPendingTransfersByCurrencyModel[]
| null;
}
export interface PsTotalVolumeByCurrencyOrPendingTransfersByCurrencyModel {
currency: string;
amount: number;
currency: string;
amount: number;
}

View file

@ -1,43 +1,43 @@
import {
PsBaseModel,
PsAuthorizationModel,
PsCustomerModel,
PsLogModel
PsBaseModel,
PsAuthorizationModel,
PsCustomerModel,
PsLogModel
} from './';
export interface PsVerifyTransactionResponseModel extends PsBaseModel {
data: PsVerifyTransactionResponseDataModel;
data: PsVerifyTransactionResponseDataModel;
}
export interface PsVerifyTransactionResponseDataModel {
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message: unknown;
gateway_response: string;
paid_at: string;
created_at: string;
channel: string;
currency: string;
ip_address: string;
metadata: string;
log: PsLogModel;
fees: number;
fees_split: unknown;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: unknown;
split: unknown;
order_id: unknown;
paidAt: string;
createdAt: string;
requested_amount: number;
pos_transaction_data: unknown;
source: unknown;
fees_breakdown: unknown;
transaction_date: string;
plan_object: unknown;
subaccount: unknown;
id: number;
domain: string;
status: string;
reference: string;
amount: number;
message: unknown;
gateway_response: string;
paid_at: string;
created_at: string;
channel: string;
currency: string;
ip_address: string;
metadata: string;
log: PsLogModel;
fees: number;
fees_split: unknown;
authorization: PsAuthorizationModel;
customer: PsCustomerModel;
plan: unknown;
split: unknown;
order_id: unknown;
paidAt: string;
createdAt: string;
requested_amount: number;
pos_transaction_data: unknown;
source: unknown;
fees_breakdown: unknown;
transaction_date: string;
plan_object: unknown;
subaccount: unknown;
}

View file

@ -1,17 +1,17 @@
import { PsBaseModel, PsHistoryModel } from './';
export interface PsViewTransactionTimeLineResponseModel extends PsBaseModel {
data: PsViewTransactionTimeLineResponseDataModel;
data: PsViewTransactionTimeLineResponseDataModel;
}
export interface PsViewTransactionTimeLineResponseDataModel {
time_spent: number;
attempts: number;
authentication?: null;
errors: number;
success: boolean;
mobile: boolean;
input?: null[] | null;
channel: string;
history?: PsHistoryModel[];
time_spent: number;
attempts: number;
authentication?: null;
errors: number;
success: boolean;
mobile: boolean;
input?: null[] | null;
channel: string;
history?: PsHistoryModel[];
}

View file

@ -5,17 +5,17 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
import { ConfigurableModuleClass } from './helpers';
@Module({
imports: [
HttpModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
timeout: configService.get('HTTP_TIMEOUT'),
baseURL: configService.get('BASE_URL')
}),
inject: [ConfigService]
})
],
providers: [PsTransactionsService, ConfigService],
exports: [PsTransactionsService]
imports: [
HttpModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
timeout: configService.get('HTTP_TIMEOUT'),
baseURL: configService.get('BASE_URL')
}),
inject: [ConfigService]
})
],
providers: [PsTransactionsService, ConfigService],
exports: [PsTransactionsService]
})
export class NsPaystackModule extends ConfigurableModuleClass {}

View file

@ -1,27 +1,61 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PsTransactionsService } from './ps-transactions.service';
import { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } from '../../helpers';
import { HttpModule } from '@nestjs/axios';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse } from 'axios';
import {
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel
} from '../../models';
import { fromExact, fromPartial } from '@total-typescript/shoehorn';
import { of } from 'rxjs';
import { expectObservable } from '../../helpers/unit-test/unit-test.util';
import { TestBed } from '@automock/jest';
import DoneCallback = jest.DoneCallback;
describe(PsTransactionsService.name, () => {
let service: PsTransactionsService;
let service: PsTransactionsService;
let httpService: jest.Mocked<HttpService>;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [HttpModule],
providers: [
PsTransactionsService,
{
provide: MODULE_OPTIONS_TOKEN,
useClass: ConfigurableModuleClass
}
]
}).compile();
beforeAll(() => {
const { unit, unitRef } = TestBed.create(PsTransactionsService)
.mock(HttpService)
.using({
post: jest.fn(),
get: jest.fn()
})
.compile();
service = module.get<PsTransactionsService>(PsTransactionsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
service = unit;
httpService = unitRef.get(HttpService);
});
describe('initializeTransaction', () => {
it('should return initialize transaction response', (done: DoneCallback) => {
const input: PsInitializeTransactionRequestModel = {
amount: '20',
email: 'test@gmail.com'
};
const response: AxiosResponse<PsInitializeTransactionResponseModel> =
fromPartial({
data: fromPartial({
data: fromExact({
authorization_url: 'https://checkout.paystack.com/0peioxfhpn',
access_code: '0peioxfhpn',
reference: '7PVGX8MEk85tgeEpVDtD'
})
})
});
httpService.post.mockReturnValueOnce(of(response));
expectObservable(
{
actualObservable: service.initializeTransaction(input),
done
},
(resp) => {
expect(resp).toEqual(response.data);
}
);
});
});
});

View file

@ -1,21 +1,21 @@
import { Inject, Injectable } from '@nestjs/common';
import {
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsConfigModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel,
PsTransactionTotalsRequestModel,
PsTransactionTotalsResponseModel,
PsVerifyTransactionResponseModel,
PsViewTransactionTimeLineResponseModel
PsChargeTransactionRequestModel,
PsChargeTransactionResponseModel,
PsConfigModel,
PsExportTransactionRequestModel,
PsExportTransactionResponseModel,
PsFetchTransactionResponseModel,
PsInitializeTransactionRequestModel,
PsInitializeTransactionResponseModel,
PsListTransactionsQueryParamsModel,
PsListTransactionsResponseModel,
PsPartialDebitRequestModel,
PsPartialDebitResponseModel,
PsTransactionTotalsRequestModel,
PsTransactionTotalsResponseModel,
PsVerifyTransactionResponseModel,
PsViewTransactionTimeLineResponseModel
} from '../../models';
import { HttpService } from '@nestjs/axios';
import { Observable } from 'rxjs';
@ -24,154 +24,154 @@ import { handleResponseAndError, MODULE_OPTIONS_TOKEN } from '../../helpers';
@Injectable()
export class PsTransactionsService {
axiosRequestConfig: AxiosRequestConfig = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.appConfig.secretKey}`
}
};
constructor(
@Inject(MODULE_OPTIONS_TOKEN)
private readonly appConfig: PsConfigModel,
private readonly httpService: HttpService
) {}
/**
* Initialize a transaction
* @param payload
*/
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/initialize',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
axiosRequestConfig: AxiosRequestConfig = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.appConfig.secretKey}`
}
};
/**
* Confirm the status of a transaction
* @param reference - The transaction reference used to initiate the transaction
*/
verifyTransaction(
reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.httpService
.get<PsVerifyTransactionResponseModel>(
`transaction/verify/${reference}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
constructor(
@Inject(MODULE_OPTIONS_TOKEN)
private readonly appConfig: PsConfigModel,
private readonly httpService: HttpService
) {}
/**
* List transactions carried out on your integration
* @param queryParamsPayload - query parameters
*/
listTransactions(
queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.httpService
.get<PsListTransactionsResponseModel>('transaction', {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* Initialize a transaction
* @param payload
*/
initializeTransaction(
payload: PsInitializeTransactionRequestModel
): Observable<PsInitializeTransactionResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/initialize',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Get details of a transaction carried out on your integration
* @param transactionId - An ID for the transaction to fetch
*/
fetchTransaction(
transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.httpService
.get<PsFetchTransactionResponseModel>(
`transaction/${transactionId}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Confirm the status of a transaction
* @param reference - The transaction reference used to initiate the transaction
*/
verifyTransaction(
reference: string
): Observable<PsVerifyTransactionResponseModel> {
return this.httpService
.get<PsVerifyTransactionResponseModel>(
`transaction/verify/${reference}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* All authorizations marked as reusable can be charged with this endpoint whenever you need to receive payments
* @param payload
*/
chargeTransaction(
payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/charge_authorization',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* List transactions carried out on your integration
* @param queryParamsPayload - query parameters
*/
listTransactions(
queryParamsPayload: PsListTransactionsQueryParamsModel
): Observable<PsListTransactionsResponseModel> {
return this.httpService
.get<PsListTransactionsResponseModel>('transaction', {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* View the timeline of a transaction
* @param idOrReference - The ID or the reference of the transaction
*/
viewTransactionTimeline(
idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.httpService
.get<PsViewTransactionTimeLineResponseModel>(
`transaction/timeline/${idOrReference}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Get details of a transaction carried out on your integration
* @param transactionId - An ID for the transaction to fetch
*/
fetchTransaction(
transactionId: number
): Observable<PsFetchTransactionResponseModel> {
return this.httpService
.get<PsFetchTransactionResponseModel>(
`transaction/${transactionId}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Total amount received on your account
* @param queryParamsPayload
*/
transactionTotals(
queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.httpService
.get<PsTransactionTotalsResponseModel>(`transaction/totals`, {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* All authorizations marked as reusable can be charged with this endpoint whenever you need to receive payments
* @param payload
*/
chargeTransaction(
payload: PsChargeTransactionRequestModel
): Observable<PsChargeTransactionResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/charge_authorization',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Export a list of transactions carried out on your integration
* @param queryParamsPayload
*/
exportTransaction(
queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.httpService
.get<PsTransactionTotalsResponseModel>(`transaction/export`, {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* View the timeline of a transaction
* @param idOrReference - The ID or the reference of the transaction
*/
viewTransactionTimeline(
idOrReference: string
): Observable<PsViewTransactionTimeLineResponseModel> {
return this.httpService
.get<PsViewTransactionTimeLineResponseModel>(
`transaction/timeline/${idOrReference}`,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Retrieve part of a payment from a customer
* @param payload
*/
partialDebit(
payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/partial_debit',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
/**
* Total amount received on your account
* @param queryParamsPayload
*/
transactionTotals(
queryParamsPayload: PsTransactionTotalsRequestModel
): Observable<PsTransactionTotalsResponseModel> {
return this.httpService
.get<PsTransactionTotalsResponseModel>(`transaction/totals`, {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* Export a list of transactions carried out on your integration
* @param queryParamsPayload
*/
exportTransaction(
queryParamsPayload: PsExportTransactionRequestModel
): Observable<PsExportTransactionResponseModel> {
return this.httpService
.get<PsTransactionTotalsResponseModel>(`transaction/export`, {
...this.axiosRequestConfig,
params: queryParamsPayload
})
.pipe(handleResponseAndError());
}
/**
* Retrieve part of a payment from a customer
* @param payload
*/
partialDebit(
payload: PsPartialDebitRequestModel
): Observable<PsPartialDebitResponseModel> {
return this.httpService
.post<PsInitializeTransactionResponseModel>(
'transaction/partial_debit',
payload,
this.axiosRequestConfig
)
.pipe(handleResponseAndError());
}
}

View file

@ -1,22 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
{
"path": "./tsconfig.spec.json"
}
]
}

View file

@ -1,16 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"],
"target": "es2020",
"strictNullChecks": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"],
"target": "es2020",
"strictNullChecks": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}

View file

@ -1,14 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

View file

@ -1,7 +1,7 @@
module.exports = {
'{libs,tools,.github}/**/*.{ts,js,json,md,html,css,scss,yml,yaml}': [
'nx affected --target lint --uncommitted --fix true',
'nx affected --target test --uncommitted',
'nx format:write --uncommitted --libs-and-apps'
]
'{libs,tools,.github}/**/*.{ts,js,json,md,html,css,scss,yml,yaml}': [
'nx affected --target lint --uncommitted --fix true',
'nx affected --target test --uncommitted',
'nx format:write --uncommitted --libs-and-apps'
]
};

76
nx.json
View file

@ -1,43 +1,39 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test"],
"accessToken": "MTVhM2EwZGYtMTk3MC00MDU0LTg0MTMtNWRhNWNmMGIwYzdhfHJlYWQtd3JpdGU="
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
},
"lint": {
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
],
"sharedGlobals": []
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test"],
"accessToken": "MTVhM2EwZGYtMTk3MC00MDU0LTg0MTMtNWRhNWNmMGIwYzdhfHJlYWQtd3JpdGU="
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
},
"lint": {
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
],
"sharedGlobals": []
}
}

49043
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,61 +1,64 @@
{
"name": "@devtools-bp/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start:api:demo": "nx serve ns-paystack-demo",
"prepare": "husky install"
},
"dependencies": {
"@nestjs/axios": "^2.0.0",
"@nestjs/common": "^9.1.1",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.1.1",
"axios": "^1.4.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@commitlint/config-nx-scopes": "^17.6.4",
"@commitlint/cz-commitlint": "^17.5.0",
"@nestjs/platform-express": "^9.1.1",
"@nestjs/schematics": "^9.1.0",
"@nestjs/testing": "^9.1.1",
"@nx/eslint-plugin": "16.2.1",
"@nx/jest": "16.2.1",
"@nx/js": "16.2.1",
"@nx/linter": "16.2.1",
"@nx/nest": "16.2.1",
"@nx/node": "16.2.1",
"@nx/webpack": "16.2.1",
"@nx/workspace": "16.2.1",
"@types/jest": "^29.4.0",
"@types/node": "~18.7.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"husky": "^8.0.0",
"jest": "^29.4.1",
"jest-environment-node": "^29.4.1",
"lint-staged": "^13.2.2",
"nx": "16.2.1",
"nx-cloud": "latest",
"prettier": "^2.6.2",
"semantic-release-npm-github-publish": "^1.5.4",
"semantic-release-plus": "^20.0.0",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "~5.0.2"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
"name": "@devtools-bp/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start:api:demo": "nx serve ns-paystack-demo",
"prepare": "husky install"
},
"dependencies": {
"@nestjs/axios": "^2.0.0",
"@nestjs/common": "^9.1.1",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.1.1",
"axios": "^1.4.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@automock/jest": "^1.2.0",
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@commitlint/config-nx-scopes": "^17.6.4",
"@commitlint/cz-commitlint": "^17.5.0",
"@golevelup/ts-jest": "^0.3.7",
"@nestjs/platform-express": "^9.1.1",
"@nestjs/schematics": "^9.1.0",
"@nestjs/testing": "^9.1.1",
"@nx/eslint-plugin": "16.2.1",
"@nx/jest": "16.2.1",
"@nx/js": "16.2.1",
"@nx/linter": "16.2.1",
"@nx/nest": "16.2.1",
"@nx/node": "16.2.1",
"@nx/webpack": "16.2.1",
"@nx/workspace": "16.2.1",
"@total-typescript/shoehorn": "^0.1.0",
"@types/jest": "^29.4.0",
"@types/node": "~18.7.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"husky": "^8.0.0",
"jest": "^29.4.1",
"jest-environment-node": "^29.4.1",
"lint-staged": "^13.2.2",
"nx": "16.2.1",
"nx-cloud": "latest",
"prettier": "^2.6.2",
"semantic-release-npm-github-publish": "^1.5.4",
"semantic-release-plus": "^20.0.0",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "~5.0.2"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}

View file

@ -15,10 +15,10 @@ import devkit from '@nx/devkit';
const { readCachedProjectGraph } = devkit;
function invariant(condition, message) {
if (!condition) {
console.error(chalk.bold.red(message));
process.exit(1);
}
if (!condition) {
console.error(chalk.bold.red(message));
process.exit(1);
}
}
// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
@ -28,37 +28,35 @@ const [, , name, version, tag = 'next'] = process.argv;
// A simple SemVer validation to validate the version
const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/;
invariant(
version && validVersion.test(version),
`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.`
version && validVersion.test(version),
`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.`
);
const graph = readCachedProjectGraph();
const project = graph.nodes[name];
invariant(
project,
`Could not find project "${name}" in the workspace. Is the project.json configured correctly?`
project,
`Could not find project "${name}" in the workspace. Is the project.json configured correctly?`
);
const outputPath = project.data?.targets?.build?.options?.outputPath;
invariant(
outputPath,
`Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`
outputPath,
`Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`
);
process.chdir(outputPath);
// Updating the version in "package.json" before publishing
try {
const json = JSON.parse(readFileSync(`package.json`).toString());
json.version = version;
writeFileSync(`package.json`, JSON.stringify(json, null, 2));
const json = JSON.parse(readFileSync(`package.json`).toString());
json.version = version;
writeFileSync(`package.json`, JSON.stringify(json, null, 2));
} catch (e) {
console.error(
chalk.bold.red(
`Error reading package.json file from library build output.`
)
);
console.error(
chalk.bold.red(`Error reading package.json file from library build output.`)
);
}
// Execute "npm publish" to publish

View file

@ -1,12 +1,12 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/out-tsc/tools",
"rootDir": ".",
"module": "commonjs",
"target": "es5",
"types": ["node"],
"importHelpers": false
},
"include": ["**/*.ts"]
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/out-tsc/tools",
"rootDir": ".",
"module": "commonjs",
"target": "es5",
"types": ["node"],
"importHelpers": false
},
"include": ["**/*.ts"]
}