Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 24 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ on:
- main

jobs:
lint:
runs-on: ubuntu-latest

name: Lint

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: |
npm install

- name: Run lint
run: |
npm run lint

test:
runs-on: ubuntu-latest

Expand All @@ -26,7 +49,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: |
Expand Down
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"recommendations": [
// JS Language plugins (~required)
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"biomejs.biome",

// Highly recommended
"EditorConfig.editorconfig"
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
36 changes: 36 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": { "enabled": true },
"formatter": {
"enabled": true,
"formatWithErrors": false,
"lineEnding": "lf",
"indentWidth": 2,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"quoteProperties": "asNeeded",
"quoteStyle": "single",
"semicolons": "asNeeded",
"trailingCommas": "es5"
}
},
"overrides": [
{
"include": ["*.json"],
"formatter": {
"indentWidth": 2
}
}
]
}
156 changes: 156 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
"build": "tsup src/index.ts --format esm,cjs --dts",
"dev": "npm run build -- --watch",
"test": "jest",
"format": "prettier \"src/**/*.{js,ts}\" --write",
"lint": "biome lint --error-on-warnings ./src",
"format": "biome format --write ./src",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"jest": "^29.7.0",
Expand Down
19 changes: 11 additions & 8 deletions src/agency.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Blutui } from './blutui'

import { Brand, Domains } from './resources/agency'

import type { Blutui } from './blutui'
import type { GetOptions, PostOptions } from './types'

export class Agency {
Expand All @@ -12,11 +12,11 @@ export class Agency {
private readonly blutui: Blutui
) {}

async get<Result = any>(path: string, options: GetOptions = {}) {
async get<Result>(path: string, options: GetOptions = {}) {
return this.blutui.get<Result>(this.getAgencyPath(path), options)
}

async post<Result = any, Entity = any>(
async post<Result, Entity>(
path: string,
entity: Entity,
options: PostOptions = {}
Expand All @@ -28,7 +28,7 @@ export class Agency {
)
}

async patch<Result = any, Entity = any>(
async patch<Result, Entity>(
path: string,
entity: Entity,
options: PostOptions = {}
Expand All @@ -40,13 +40,16 @@ export class Agency {
)
}

async delete<Result = any>(path: string, options: PostOptions = {}) {
async delete<Result>(path: string, options: PostOptions = {}) {
return this.blutui.delete<Result>(this.getAgencyPath(path), options)
}

/**
* Get the path for the current agency.
*/
private getAgencyPath(path: string): string {
path = path.startsWith('/') ? path.replace('/', '') : path
const newPath = path.startsWith('/') ? path.replace('/', '') : path

return `/agencies/${this.username}/${path}`
return `/agencies/${this.username}/${newPath}`
}
}
4 changes: 2 additions & 2 deletions src/blutui.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'jest-fetch-mock'
import fs from 'fs/promises'
import fs from 'node:fs/promises'

import { Agency } from './agency'
import { Blutui } from './blutui'
Expand All @@ -16,7 +16,7 @@ describe('Blutui', () => {
beforeEach(() => {
jest.resetModules()
process.env = { ...OLD_ENV }
delete process.env.NODE_ENV
process.env.NODE_ENV = undefined
})

afterEach(() => {
Expand Down
Loading