-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 4 commits
60d759b
5664ddb
d41540d
194a387
3837b07
049187d
74cb3f2
6409c41
2076128
da3c9f2
ab960ca
feeaa35
f001408
c6d6cd0
3e1462b
8308e08
cdc21b4
d46267e
14a6981
e91cdba
b9e4f20
2b50c45
78ed5c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Example Package | ||
|
||
Easily kickoff a package replicating this structure. |
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") | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"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:*", | ||
"typescript": "4.9.4", | ||
"vitest": "1.6.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const example = () => { | ||
// Implement | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@hyperhub/typescript-config/base.json", | ||
"exclude": ["dist", "node_modules", "__test__"], | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
} | ||
} |
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/*"], | ||
}, | ||
}), | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"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:*", | ||
"typescript": "5.4.5", | ||
"vitest": "1.6.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should only be a dep from test-config or iam wrong ? |
||
} | ||
} |
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "@hyperhub/typescript-config/base.json", | ||
"compilerOptions": { | ||
<<<<<<< HEAD | ||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "**/*.test.ts"] | ||
======= | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"declaration": true, | ||
"declarationMap": true | ||
} | ||
>>>>>>> feeaa35 (chore: add EOF) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Coingecko Package | ||
|
||
Adds coingecko API utilities. |
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); | ||
}) | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"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:*", | ||
"typescript": "4.9.4", | ||
"vitest": "1.6.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
} | ||
} |
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 }); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { AxiosInstance, CreateAxiosDefaults } from "axios"; | ||
import axios from "axios"; | ||
|
||
export default class CoingeckoService { | ||
private instance: AxiosInstance; | ||
private baseURL: string; | ||
private apiKey: string; | ||
|
||
constructor() { | ||
const baseURL = process.env.COINGECKO_API_URL; | ||
const apiKey = process.env.COINGECKO_API_KEY; | ||
|
||
if (!baseURL) { | ||
throw new Error("Missing Coingecko baseUrl"); | ||
} | ||
|
||
if (!apiKey) { | ||
throw new Error("Missing coingecko api key"); | ||
} | ||
|
||
this.apiKey = apiKey; | ||
this.baseURL = baseURL; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets use the approach we have talked offline |
||
const config: CreateAxiosDefaults = { | ||
baseURL: this.baseURL, | ||
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@hyperhub/typescript-config/base.json", | ||
"exclude": ["dist", "node_modules", "__test__"], | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
} | ||
} |
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/*"], | ||
}, | ||
}), | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COINGECKO_API_URL="" | ||
COINGECKO_API_KEY="" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Serverless Package | ||
|
||
|
||
Adds serverless utils to build lambda functions. |
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); | ||
}) | ||
}); |
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 }); | ||
} | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export { example } from './handlers/exampleHandler'; | ||
export const buildHandler = () => { | ||
console.log('@@//TODO'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
{ | ||
"extends": "@hyperhub/typescript-config/base.json", | ||
"include": ["."], | ||
<<<<<<< HEAD | ||
"exclude": ["dist", "node_modules", "__test__"], | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
======= | ||
"include": ["./src/**/*.ts"], | ||
"exclude": ["dist", "node_modules"], | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"outDir": "./dist" | ||
>>>>>>> 5d538ab (fix: deps (#10)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"globalDependencies": ["**/.env.*local"], | ||
"pipeline": { | ||
"build": { | ||
"dependsOn": ["^build"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should stay |
||
"dependsOn": [], | ||
"outputs": ["dist/**"] | ||
}, | ||
"test": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shoould be a global dependency of the monorepo