Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scaffold pricing module lib #28

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libs/pricing/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./pricing.module";
export * from "./services/coingecko.service";
9 changes: 9 additions & 0 deletions libs/pricing/src/pricing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from "@nestjs/common";

import { CoingeckoService } from "./services";

@Module({
providers: [CoingeckoService],
exports: [CoingeckoService],
})
export class PricingModule {}
27 changes: 27 additions & 0 deletions libs/pricing/src/services/coingecko.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Test, TestingModule } from "@nestjs/testing";

import { CoingeckoService } from "./coingecko.service";

describe("CoingeckoService", () => {
let service: CoingeckoService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
{
provide: CoingeckoService,
useFactory: () => {
const apiKey = "COINGECKO_API_KEY";
return new CoingeckoService(apiKey);
},
},
],
}).compile();

service = module.get<CoingeckoService>(CoingeckoService);
});

it("should be defined", () => {
expect(service).toBeDefined();
});
});
7 changes: 7 additions & 0 deletions libs/pricing/src/services/coingecko.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Injectable } from "@nestjs/common";

@Injectable()
export class CoingeckoService {
private readonly API_BASE_URL = "https://api.coingecko.com/api/v3/";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt if we remove this hardcoded value and ask for 2 parameters baseUrl and apiKey instead???

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okayy sound good to me

constructor(private readonly apiKey: string) {}
}
1 change: 1 addition & 0 deletions libs/pricing/src/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./coingecko.service";
9 changes: 9 additions & 0 deletions libs/pricing/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"outDir": "../../dist/libs/pricing"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
9 changes: 9 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
"compilerOptions": {
"tsConfigPath": "libs/dtos/tsconfig.lib.json"
}
},
"pricing": {
"type": "library",
"root": "libs/pricing",
"entryFile": "index",
"sourceRoot": "libs/pricing/src",
"compilerOptions": {
"tsConfigPath": "libs/pricing/tsconfig.lib.json"
}
}
}
}
199 changes: 100 additions & 99 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,103 @@
{
"name": "zkchainHub",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"{apps,libs}/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/apps/api/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./apps/api/test/jest-e2e.json",
"prepare": "husky",
"preinstall": "npx only-allow pnpm"
},
"dependencies": {
"@nestjs/common": "10.0.0",
"@nestjs/core": "10.0.0",
"@nestjs/platform-express": "10.0.0",
"@nestjs/swagger": "7.4.0",
"abitype": "1.0.5",
"reflect-metadata": "0.1.13",
"rxjs": "7.8.1",
"viem": "2.17.5"
},
"devDependencies": {
"@commitlint/config-conventional": "19.2.2",
"@golevelup/ts-jest": "0.5.0",
"@ianvs/prettier-plugin-sort-imports": "4.3.0",
"@nestjs/cli": "10.0.0",
"@nestjs/schematics": "10.0.0",
"@nestjs/testing": "10.0.0",
"@total-typescript/tsconfig": "1.0.4",
"@types/express": "4.17.17",
"@types/jest": "29.5.2",
"@types/node": "20.3.1",
"@types/supertest": "6.0.0",
"@typescript-eslint/eslint-plugin": "7.0.0",
"@typescript-eslint/parser": "7.0.0",
"commitlint": "19.3.0",
"eslint": "8.42.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"husky": "9.0.11",
"jest": "29.5.0",
"lint-staged": "15.2.7",
"prettier": "3.0.0",
"source-map-support": "0.5.21",
"supertest": "7.0.0",
"ts-jest": "29.1.0",
"ts-loader": "9.4.3",
"ts-node": "10.9.1",
"tsconfig-paths": "4.2.0",
"typescript": "5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
".+\\.(t|j)s$": "ts-jest"
"name": "zkchainHub",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"{apps,libs}/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/apps/api/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./apps/api/test/jest-e2e.json",
"prepare": "husky",
"preinstall": "npx only-allow pnpm"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "./coverage",
"coveragePathIgnorePatterns": [
"/node_modules/",
".e2e-spec.ts",
".module.ts",
"main.ts"
],
"testEnvironment": "node",
"roots": [
"<rootDir>/apps/",
"<rootDir>/libs/"
],
"moduleNameMapper": {
"^@packages/providers(|/.*)$": "<rootDir>/libs/providers/src/$1",
"^@shared/dtos(|/.*)$": "<rootDir>/libs/dtos/src/$1"
"dependencies": {
"@nestjs/common": "10.0.0",
"@nestjs/core": "10.0.0",
"@nestjs/platform-express": "10.0.0",
"@nestjs/swagger": "7.4.0",
"abitype": "1.0.5",
"reflect-metadata": "0.1.13",
"rxjs": "7.8.1",
"viem": "2.17.5"
},
"devDependencies": {
"@commitlint/config-conventional": "19.2.2",
"@golevelup/ts-jest": "0.5.0",
"@ianvs/prettier-plugin-sort-imports": "4.3.0",
"@nestjs/cli": "10.0.0",
"@nestjs/schematics": "10.0.0",
"@nestjs/testing": "10.0.0",
"@total-typescript/tsconfig": "1.0.4",
"@types/express": "4.17.17",
"@types/jest": "29.5.2",
"@types/node": "20.3.1",
"@types/supertest": "6.0.0",
"@typescript-eslint/eslint-plugin": "7.0.0",
"@typescript-eslint/parser": "7.0.0",
"commitlint": "19.3.0",
"eslint": "8.42.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"husky": "9.0.11",
"jest": "29.5.0",
"lint-staged": "15.2.7",
"prettier": "3.0.0",
"source-map-support": "0.5.21",
"supertest": "7.0.0",
"ts-jest": "29.1.0",
"ts-loader": "9.4.3",
"ts-node": "10.9.1",
"tsconfig-paths": "4.2.0",
"typescript": "5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
".+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "./coverage",
"coveragePathIgnorePatterns": [
"/node_modules/",
".e2e-spec.ts",
".module.ts",
"main.ts"
],
"testEnvironment": "node",
"roots": [
"<rootDir>/apps/",
"<rootDir>/libs/"
],
"moduleNameMapper": {
"^@packages/providers(|/.*)$": "<rootDir>/libs/providers/src/$1",
"^@shared/dtos(|/.*)$": "<rootDir>/libs/dtos/src/$1",
"^@packages/pricing(|/.*)$": "<rootDir>/libs/pricing/src/$1"
}
},
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d",
"lint-staged": {
"(apps|libs)/**/*.(ts|js)": [
"pnpm lint",
"pnpm format"
]
}
},
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d",
"lint-staged": {
"(apps|libs)/**/*.(ts|js)": [
"pnpm lint",
"pnpm format"
]
}
}
}
66 changes: 30 additions & 36 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
{
"extends": "@total-typescript/tsconfig/tsc/no-dom/app",
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@packages/providers": [
"libs/providers/src"
],
"@packages/providers/*": [
"libs/providers/src/*"
],
"@shared/dtos": [
"libs/dtos/src"
],
"@shared/dtos/*": [
"libs/dtos/src/*"
]
},
"verbatimModuleSyntax": false
}
}
"extends": "@total-typescript/tsconfig/tsc/no-dom/app",
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@packages/providers": ["libs/providers/src"],
"@packages/providers/*": ["libs/providers/src/*"],
"@shared/dtos": ["libs/dtos/src"],
"@shared/dtos/*": ["libs/dtos/src/*"],
"@packages/pricing": ["libs/pricing/src"],
"@packages/pricing/*": ["libs/pricing/src/*"]
},
"verbatimModuleSyntax": false
}
}