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 package #13

Merged
merged 11 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
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');
};
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
"outputs": []
},
"test": {
"dependsOn": [],
Expand Down
30 changes: 30 additions & 0 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
Loading