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: biome #118

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc.json

This file was deleted.

8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"[typescript][typescriptreact][typescriptangular]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "biomejs.biome"
},
"eslint.workingDirectories": ["apps", "packages"],
"prettier.enable": true
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
}
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
This turborepo has some additional tools already setup for you:

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
- [Biome]

## Useful Links

Expand Down
20 changes: 10 additions & 10 deletions apps/angular-example/abby.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { defineConfig } from "@tryabby/angular";
import { environment } from "src/environments/environment";
import { defineConfig } from '@tryabby/angular';
import { environment } from 'src/environments/environment';

export default defineConfig(
{
projectId: environment.ABBY_PROJECT_ID,
currentEnvironment: "test",
apiUrl: "http://localhost:3000/",
currentEnvironment: 'test',
apiUrl: 'http://localhost:3000/',
debug: true,
},
{
environments: ["test", "prod"],
environments: ['test', 'prod'],
tests: {
AngularTest: {
variants: ["A", "B", "C", "D"],
variants: ['A', 'B', 'C', 'D'],
},
NotExistingTest: {
variants: ["A", "B"],
variants: ['A', 'B'],
},
},
flags: ["AngularFlag", "AngularFlag2", "NotExistingFlag"],
flags: ['AngularFlag', 'AngularFlag2', 'NotExistingFlag'],
remoteConfig: {
angularRemoteConfig: "String",
angularRemoteConfig: 'String',
},
}
},
);
4 changes: 2 additions & 2 deletions apps/angular-example/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function app(): express.Express {
'html',
ngExpressEngine({
bootstrap: AppServerModule,
})
}),
);

server.set('view engine', 'html');
Expand All @@ -34,7 +34,7 @@ export function app(): express.Express {
'*.*',
express.static(distFolder, {
maxAge: '1y',
})
}),
);

// All regular routes use the Universal engine
Expand Down
8 changes: 4 additions & 4 deletions apps/angular-example/src/app/abby.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Injectable } from "@angular/core";
import { Injectable } from '@angular/core';
import {
AbbyService,
InferFlagNames,
InferRemoteConfig,
InferRemoteConfigName,
InferTestNames,
InferTests,
} from "abby";
import abby from "../../abby.config";
} from 'abby';
import abby from '../../abby.config';

@Injectable({
providedIn: "root",
providedIn: 'root',
useExisting: AbbyService,
})
export class Abby extends AbbyService<
Expand Down
8 changes: 5 additions & 3 deletions apps/angular-example/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { combineLatest } from 'rxjs';
exports: [RouterModule],
})
export class AppRoutingModule {
constructor(private abby: Abby, private router: Router) {
constructor(
private abby: Abby,
private router: Router,
) {
// we are using `combineLatest` here, as the devtools can dynamically
// change the state of our feature flags during runtime.
// In a live environment, where flags and variants are determined once,
Expand All @@ -30,8 +33,7 @@ export class AppRoutingModule {
this.router.resetConfig([
{
path: 'lazy',
loadChildren: () =>
import('./lazy/lazy.module').then((m) => m.LazyModule),
loadChildren: () => import('./lazy/lazy.module').then((m) => m.LazyModule),
outlet: 'lazy',
},
this.abby.getRouterVariant(angularTest, {
Expand Down
26 changes: 13 additions & 13 deletions apps/angular-example/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component } from "@angular/core";
import { FormControl } from "@angular/forms";
import { map } from "rxjs";
import { Abby } from "./abby";
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { map } from 'rxjs';
import { Abby } from './abby';

@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
angularTest$ = this.abby.getVariant("AngularTest");
angularFlag$ = this.abby.getFeatureFlagValue("AngularFlag");
angularTest$ = this.abby.getVariant('AngularTest');
angularFlag$ = this.abby.getFeatureFlagValue('AngularFlag');

variantWithLookup$ = this.abby.getVariant("AngularTest", {
variantWithLookup$ = this.abby.getVariant('AngularTest', {
A: 1,
B: 2,
C: 3,
Expand All @@ -21,7 +21,7 @@ export class AppComponent {

headerColor$ = this.angularTest$.pipe(
map((angularTest) => {
switch(angularTest) {
switch (angularTest) {
case 'A':
return 'blue';
case 'B':
Expand All @@ -33,14 +33,14 @@ export class AppComponent {
default:
return 'grey';
}
})
}),
);

dynamicFeatureFlag = new FormControl<string | null>(null);

constructor(public readonly abby: Abby) {}

public onAct(): void {
this.abby.onAct("AngularTest");
this.abby.onAct('AngularTest');
}
}
24 changes: 12 additions & 12 deletions apps/angular-example/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { APP_INITIALIZER, Injectable, NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import abbyConfig from "../../abby.config";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { AbbyModule, AbbyService } from "abby";
import { ATestComponent } from "./test_components/a.component";
import { BTestComponent } from "./test_components/b.component";
import { CTestComponent } from "./test_components/c.component";
import { DTestComponent } from "./test_components/d.component";
import { FlagComponent } from "./test_components/flag.component";
import { ReactiveFormsModule } from "@angular/forms";
import { APP_INITIALIZER, Injectable, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import abbyConfig from '../../abby.config';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AbbyModule, AbbyService } from 'abby';
import { ATestComponent } from './test_components/a.component';
import { BTestComponent } from './test_components/b.component';
import { CTestComponent } from './test_components/c.component';
import { DTestComponent } from './test_components/d.component';
import { FlagComponent } from './test_components/flag.component';
import { ReactiveFormsModule } from '@angular/forms';

@NgModule({
declarations: [
Expand Down
4 changes: 1 addition & 3 deletions apps/angular-example/src/app/lazy/lazy-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LazyComponent } from './lazy.component';

const routes: Routes = [
{ path: '', component: LazyComponent, pathMatch: 'full' },
];
const routes: Routes = [{ path: '', component: LazyComponent, pathMatch: 'full' }];

@NgModule({
imports: [RouterModule.forChild(routes)],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const environment = {
production: false,
ABBY_PROJECT_ID:
process.env['ABBY_PROJECT_ID'] ?? 'clftg3tzd0004l7085yktpsov',
ABBY_PROJECT_ID: process.env['ABBY_PROJECT_ID'] ?? 'clftg3tzd0004l7085yktpsov',
};
3 changes: 1 addition & 2 deletions apps/angular-example/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const environment = {
production: true,
ABBY_PROJECT_ID:
process.env['ABBY_PROJECT_ID'] ?? 'clftg3tzd0004l7085yktpsov',
ABBY_PROJECT_ID: process.env['ABBY_PROJECT_ID'] ?? 'clftg3tzd0004l7085yktpsov',
};
48 changes: 24 additions & 24 deletions apps/cdn/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import { Hono } from "hono";
import { ZoneCache } from "./lib/cache";
import { ABBY_WINDOW_KEY, AbbyDataResponse } from "@tryabby/core";
import { Hono } from 'hono';
import { ZoneCache } from './lib/cache';
import { ABBY_WINDOW_KEY, AbbyDataResponse } from '@tryabby/core';

import { cors } from "hono/cors";
import { timing } from "hono/timing";
import { logger } from "hono/logger";
import { ConfigService } from "./lib/config";
import { cors } from 'hono/cors';
import { timing } from 'hono/timing';
import { logger } from 'hono/logger';
import { ConfigService } from './lib/config';

const cache = new ZoneCache<{
config: AbbyDataResponse;
}>({
cloudflareApiKey: "",
domain: "cache.tryabby.com",
cloudflareApiKey: '',
domain: 'cache.tryabby.com',
fresh: 60 * 1000,
stale: 60 * 1000,
zoneId: "",
zoneId: '',
});

const configCache = new ConfigService(cache);

const app = new Hono()
.use(
"*",
'*',
cors({
origin: "*",
origin: '*',
maxAge: 60 * 60 * 24 * 30,
})
}),
)
.use("*", timing())
.use("*", logger())
.get("/:projectId/:environment", async (c) => {
const environment = c.req.param("environment");
const projectId = c.req.param("projectId");
.use('*', timing())
.use('*', logger())
.get('/:projectId/:environment', async (c) => {
const environment = c.req.param('environment');
const projectId = c.req.param('projectId');

const [data, , reason] = await configCache.retrieveConfig({
c,
environment,
projectId,
});

c.header("x-abby-cache", reason);
c.header('x-abby-cache', reason);
return c.json(data);
})
.get("/:projectId/:environment/script.js", async (c) => {
const environment = c.req.param("environment");
const projectId = c.req.param("projectId");
.get('/:projectId/:environment/script.js', async (c) => {
const environment = c.req.param('environment');
const projectId = c.req.param('projectId');

const [data, , reason] = await configCache.retrieveConfig({
c,
environment,
projectId,
});

c.header("x-abby-cache", reason);
c.header('x-abby-cache', reason);

const script = `window.${ABBY_WINDOW_KEY} = ${JSON.stringify(data)};`;

return c.text(script, {
headers: {
"Content-Type": "application/javascript",
'Content-Type': 'application/javascript',
},
});
});
Expand Down
Loading
Loading