Skip to content

Commit

Permalink
feat: base package (#13)
Browse files Browse the repository at this point in the history
# 🤖 Linear

Re implements #8
without commit issues

## Description
  • Loading branch information
0xjjojo authored May 27, 2024
1 parent 5d538ab commit e2e8691
Show file tree
Hide file tree
Showing 23 changed files with 220 additions and 25 deletions.
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.
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/*"],
},
}),
);
1 change: 1 addition & 0 deletions packages/errors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Errors package
7 changes: 7 additions & 0 deletions packages/errors/__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 exampleHandler test', () => {
expect(true).toBe(true);
})
});
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
}
}
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.
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/*"],
},
}),
);
1 change: 1 addition & 0 deletions packages/serverless/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXAMPLE_VAR=""
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.
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');
};
48 changes: 39 additions & 9 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 @@ -7907,9 +7937,9 @@ __metadata:
linkType: hard

"sax@npm:>=0.6.0":
version: 1.3.0
resolution: "sax@npm:1.3.0"
checksum: 10/bb571b31d30ecb0353c2ff5f87b117a03e5fb9eb4c1519141854c1a8fbee0a77ddbe8045f413259e711833aa03da210887df8527d19cdc55f299822dbf4b34de
version: 1.4.0
resolution: "sax@npm:1.4.0"
checksum: 10/b69ca09c4131d86b61f8c0f3732b8f2e73f43a60ebe082911d4b960366d9a858458e4ab947a6c586fac8beccd45cc0feba5904309b132a37ee1bd23f76670052
languageName: node
linkType: hard

Expand Down

0 comments on commit e2e8691

Please sign in to comment.