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: base pkg structure #8

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
60d759b
chore: add intermediate packages structure
0xjjojo May 23, 2024
5664ddb
chore: add intermediate structure for base packages and modularize pa…
0xjjojo May 23, 2024
d41540d
fix: update coingecko package.json
0xjjojo May 23, 2024
194a387
Add: coingecko readme
0xjjojo May 23, 2024
3837b07
add: example package to follow guidelines
0xjjojo May 23, 2024
049187d
add: base config files for example pkg
0xjjojo May 23, 2024
74cb3f2
wip: single package errors working from building individually
0xjjojo May 24, 2024
6409c41
chore: set correct dependencies, fix tsconfig.json for individual pkg…
0xjjojo May 24, 2024
2076128
chore: set .env.example over individual pkg
0xjjojo May 24, 2024
da3c9f2
remove: deprecated js output
0xjjojo May 24, 2024
ab960ca
misc: remove unnecesary path key from base tsconfig, and within test-…
0xjjojo May 24, 2024
feeaa35
chore: add EOF
0xjjojo May 24, 2024
f001408
add: declaration and declarationMap for error packages .d.ts output
0xjjojo May 24, 2024
c6d6cd0
Add: errors package to serverless
0xjjojo May 24, 2024
3e1462b
chore: fix lockfile
0xjjojo May 24, 2024
8308e08
Add: ^ to build pipeline
0xjjojo May 24, 2024
cdc21b4
refactor: cg constructor w dep inyection
0xjjojo May 24, 2024
d46267e
add: rebase last commits, add coingecko readme and packages, fix depr…
0xjjojo May 24, 2024
14a6981
fix: conflicts
0xjjojo May 24, 2024
e91cdba
fix: merge upstream conflcits
0xjjojo May 26, 2024
b9e4f20
add: declaration and declaration map to errors pkg
0xjjojo May 27, 2024
2b50c45
fix: yarn.lock
0xjjojo May 27, 2024
78ed5c2
chore: add EOF
0xjjojo May 27, 2024
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
],
"devDependencies": {
"@commitlint/config-conventional": "19.2.2",
"@hyperhub/test-config": "workspace:*",
"@hyperhub/typescript-config": "workspace:*",
"@types/node": "18.13.0",
"commitlint": "19.3.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/__example__/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Example Package

Easily kickoff a package replicating this structure.
5 changes: 5 additions & 0 deletions packages/__example__/__test__/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { describe, it } from 'vitest'

describe('examplePackage test', () => {
it.skip("Implement tests")
});
17 changes: 17 additions & 0 deletions packages/__example__/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@hyperhub/example",
"private": true,
"version": "0.0.0",
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx src",
"test": "vitest",
"coverage": "vitest run --coverage",
"tsc": "tsc --noEmit"
},
"devDependencies": {
"@hyperhub/errors": "workspace:*",
"@hyperhub/test-config": "workspace:*",
"@hyperhub/typescript-config": "workspace:*"
}
}
3 changes: 3 additions & 0 deletions packages/__example__/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const example = () => {
// Implement
};
9 changes: 9 additions & 0 deletions packages/__example__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@hyperhub/typescript-config/base.json",
"include": ["./src/**/*.ts"],
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
}
11 changes: 11 additions & 0 deletions packages/__example__/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { baseConfig } from "@hyperhub/test-config";
import { mergeConfig, defineConfig } from "vitest/config";

export default mergeConfig(
baseConfig,
defineConfig({
test: {
exclude: ["coverage/*"],
},
}),
);
17 changes: 17 additions & 0 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@hyperhub/errors",
"version": "0.0.0",
"private": true,
"license": "MIT",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@hyperhub/test-config": "workspace:*",
"@hyperhub/typescript-config": "workspace:*"
}
}
15 changes: 15 additions & 0 deletions packages/errors/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export abstract class BaseError extends Error {
readonly name: string;
readonly description: string;

constructor({ name, description }: { name: string; description: string }) {
super(description);
this.name = name;
this.description = description;
Object.setPrototypeOf(this, BaseError.prototype);
}

public getDescription(): string {
return this.description;
}
}
11 changes: 11 additions & 0 deletions packages/errors/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@hyperhub/typescript-config/base.json",
"include": ["./src/**/*.ts"],
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"declarationMap": true
}
}
11 changes: 11 additions & 0 deletions packages/errors/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { baseConfig } from "@hyperhub/test-config";
import { mergeConfig, defineConfig } from "vitest/config";

export default mergeConfig(
baseConfig,
defineConfig({
test: {
exclude: ["coverage/*"],
},
}),
);
3 changes: 3 additions & 0 deletions packages/lib/coingecko/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Coingecko Package

Adds coingecko API utilities.
7 changes: 7 additions & 0 deletions packages/lib/coingecko/__test__/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, test, expect } from 'vitest'

describe('exampleHandler', () => {
test('Sample coingecko test', () => {
expect(true).toBe(true);
})
});
17 changes: 17 additions & 0 deletions packages/lib/coingecko/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@hyperhub/coingecko",
"private": true,
"version": "0.0.0",
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx src",
"test": "vitest",
"coverage": "vitest run --coverage",
"tsc": "tsc --noEmit"
},
"devDependencies": {
"@hyperhub/errors": "workspace:*",
"@hyperhub/test-config": "workspace:*",
"@hyperhub/typescript-config": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions packages/lib/coingecko/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BaseError } from "@hyperhub/errors";

export class CoingeckoError extends BaseError {
constructor(description: string) {
super({ name: "CoingeckoError", description });
}
}
24 changes: 24 additions & 0 deletions packages/lib/coingecko/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { AxiosInstance, CreateAxiosDefaults } from "axios";
import axios from "axios";

export default class CoingeckoService {
private instance: AxiosInstance;

constructor(private url: string, private apiKey:string){
const config: CreateAxiosDefaults = {
baseURL: url,
headers: {
"x-cg-demo-api-key": this.apiKey,
},
};

this.instance = axios.create(config);
}

get(): AxiosInstance {
if (!this.instance) {
throw new Error("Client not initialized");
}
return this.instance;
}
}
9 changes: 9 additions & 0 deletions packages/lib/coingecko/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@hyperhub/typescript-config/base.json",
"include": ["./src/**/*.ts"],
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
}
11 changes: 11 additions & 0 deletions packages/lib/coingecko/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { baseConfig } from "@hyperhub/test-config";
import { mergeConfig, defineConfig } from "vitest/config";

export default mergeConfig(
baseConfig,
defineConfig({
test: {
exclude: ["coverage/*"],
},
}),
);
2 changes: 2 additions & 0 deletions packages/serverless/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
COINGECKO_API_URL=""
COINGECKO_API_KEY=""
4 changes: 4 additions & 0 deletions packages/serverless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Serverless Package


Adds serverless utils to build lambda functions.
7 changes: 7 additions & 0 deletions packages/serverless/__test__/handlers/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, test, expect } from 'vitest'

describe('exampleHandler', () => {
test('Sample exampleHandler test', () => {
expect(true).toBe(true);
})
});
1 change: 1 addition & 0 deletions packages/serverless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tsc": "tsc --noEmit"
},
"devDependencies": {
"@hyperhub/errors": "workspace:*",
"@hyperhub/typescript-config": "workspace:*",
"@serverless/typescript": "3.27.0",
"@types/aws-lambda": "8.10.71",
Expand Down
7 changes: 7 additions & 0 deletions packages/serverless/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BaseError } from "@hyperhub/errors";

export default class LambdaError extends BaseError {
constructor(description: string) {
super({ name: "LambdaError", description });
}
};
15 changes: 0 additions & 15 deletions packages/serverless/src/handlers/exampleHandler.ts

This file was deleted.

4 changes: 3 additions & 1 deletion packages/serverless/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { example } from './handlers/exampleHandler';
export const buildHandler = () => {
console.log('@@//TODO');
};
1 change: 0 additions & 1 deletion tooling/typescript-config/base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",

"compilerOptions": {
"lib": ["ESNext"],
"module": "commonjs",
Expand Down
3 changes: 1 addition & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"globalDependencies": ["**/.env.*local"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should stay

"outputs": ["dist/**"]
"dependsOn": ["^build"]
},
"test": {
"dependsOn": [],
Expand Down
43 changes: 36 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,40 @@ __metadata:
languageName: node
linkType: hard

"@hyperhub/coingecko@workspace:packages/lib/coingecko":
version: 0.0.0-use.local
resolution: "@hyperhub/coingecko@workspace:packages/lib/coingecko"
dependencies:
"@hyperhub/errors": "workspace:*"
"@hyperhub/test-config": "workspace:*"
"@hyperhub/typescript-config": "workspace:*"
languageName: unknown
linkType: soft

"@hyperhub/errors@workspace:*, @hyperhub/errors@workspace:packages/errors":
version: 0.0.0-use.local
resolution: "@hyperhub/errors@workspace:packages/errors"
dependencies:
"@hyperhub/test-config": "workspace:*"
"@hyperhub/typescript-config": "workspace:*"
languageName: unknown
linkType: soft

"@hyperhub/example@workspace:packages/__example__":
version: 0.0.0-use.local
resolution: "@hyperhub/example@workspace:packages/__example__"
dependencies:
"@hyperhub/errors": "workspace:*"
"@hyperhub/test-config": "workspace:*"
"@hyperhub/typescript-config": "workspace:*"
languageName: unknown
linkType: soft

"@hyperhub/serverless@workspace:packages/serverless":
version: 0.0.0-use.local
resolution: "@hyperhub/serverless@workspace:packages/serverless"
dependencies:
"@hyperhub/errors": "workspace:*"
"@hyperhub/typescript-config": "workspace:*"
"@serverless/typescript": "npm:3.27.0"
"@types/aws-lambda": "npm:8.10.71"
Expand Down Expand Up @@ -2700,14 +2730,14 @@ __metadata:
linkType: hard

"ajv@npm:^8.0.0, ajv@npm:^8.11.0, ajv@npm:^8.12.0":
version: 8.13.0
resolution: "ajv@npm:8.13.0"
version: 8.14.0
resolution: "ajv@npm:8.14.0"
dependencies:
fast-deep-equal: "npm:^3.1.3"
json-schema-traverse: "npm:^1.0.0"
require-from-string: "npm:^2.0.2"
uri-js: "npm:^4.4.1"
checksum: 10/4ada268c9a6e44be87fd295df0f0a91267a7bae8dbc8a67a2d5799c3cb459232839c99d18b035597bb6e3ffe88af6979f7daece854f590a81ebbbc2dfa80002c
checksum: 10/b6430527c2e1bf3d20dce4cca2979b5cc69db15751ac00105e269e04d7b09c2e20364070257cafacfa676171a8bf9c84c1cd9def97267a20cd15c64daa486151
languageName: node
linkType: hard

Expand Down Expand Up @@ -2967,8 +2997,8 @@ __metadata:
linkType: hard

"aws-sdk@npm:^2.1303.0":
version: 2.1627.0
resolution: "aws-sdk@npm:2.1627.0"
version: 2.1628.0
resolution: "aws-sdk@npm:2.1628.0"
dependencies:
buffer: "npm:4.9.2"
events: "npm:1.1.1"
Expand All @@ -2980,7 +3010,7 @@ __metadata:
util: "npm:^0.12.4"
uuid: "npm:8.0.0"
xml2js: "npm:0.6.2"
checksum: 10/85973c824b3216e8c648bf2e77308dd36e24aa7d5a45e747d1ca2ecadbcae196e172d82a368dd145fb9c6e8c2571f7ce7db0b112928c451757eed8d6d1126302
checksum: 10/783ae6374bca38971682d1ecfdba52c51d003b173f2f2dca92d433d6ee42c69f907afd26d15a2f70eff82d023c606d9dfe0514f50bdc26a939368f31f3d92d54
languageName: node
linkType: hard

Expand Down Expand Up @@ -5413,7 +5443,6 @@ __metadata:
resolution: "hyperhub@workspace:."
dependencies:
"@commitlint/config-conventional": "npm:19.2.2"
"@hyperhub/test-config": "workspace:*"
"@hyperhub/typescript-config": "workspace:*"
"@types/node": "npm:18.13.0"
commitlint: "npm:19.3.0"
Expand Down
Loading