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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM denoland/deno:2.3.5
FROM denoland/deno:2.4.0

# Install tools
RUN apt-get update && \
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup Deno v2.3.5
uses: denoland/setup-deno@v1
- name: Setup Deno v2.4.0
uses: denoland/setup-deno@v2
with:
deno-version: v2.3.5
deno-version: v2.4.0

- name: Setup LCOV
run: sudo apt install -y lcov
Expand All @@ -38,7 +38,6 @@ jobs:
- name: SonarCloud Scan
uses: sonarsource/sonarqube-scan-action@v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

docker:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/re-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.inputs.tag }}

- name: Setup Deno v2.3.5
uses: denoland/setup-deno@v1
- name: Setup Deno v2.4.0
uses: denoland/setup-deno@v2
with:
deno-version: v2.3.5
deno-version: v2.4.0

- name: Verify formatting
run: deno task fmt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup Deno v2.3.5
uses: denoland/setup-deno@v1
- name: Setup Deno v2.4.0
uses: denoland/setup-deno@v2
with:
deno-version: v2.3.5
deno-version: v2.4.0

- name: Verify formatting
run: deno task fmt
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
coverage
dist
.scannerwork
.env.prod
.env.prod
.env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM denoland/deno:alpine-2.3.5
FROM denoland/deno:alpine-2.4.0

ENV APP_HOME=/home/app
WORKDIR $APP_HOME
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@switcherapi/switcher-management-feature",
"version": "1.1.0",
"version": "1.1.1",
"description": "Feature Flag Service for Switcher Management",
"tasks": {
"run": "deno run --allow-net --allow-env --allow-read --allow-write src/index.ts",
Expand Down
77 changes: 71 additions & 6 deletions deno.lock

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

2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=switcherapi_switcher-management-feature
sonar.projectName=switcher-management-feature
sonar.organization=switcherapi
sonar.projectVersion=1.1.0
sonar.projectVersion=1.1.1

sonar.javascript.lcov.reportPaths=coverage/report.lcov

Expand Down
2 changes: 1 addition & 1 deletion src/api-docs/swagger-info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
title: 'Switcher Management Feature',
version: 'v1.1.0',
version: 'v1.1.1',
description: 'Feature Flag Service for Switcher Management.',
contact: {
name: 'Roger Floriano (petruki)',
Expand Down
4 changes: 2 additions & 2 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { Application, Context, type Middleware, type Next, Router } from 'jsr:@oak/oak@17.1.4';
export { Client } from 'jsr:@switcherapi/switcher-client-deno@2.1.0';
export { Application, Context, type Middleware, type Next, Router } from 'jsr:@oak/oak@17.1.5';
export { Client } from 'jsr:@switcherapi/switcher-client-deno@2.3.0';
export { ValidatorFn, ValidatorMiddleware } from 'jsr:@trackerforce/validator4oak@1.2.0';
export { load } from 'jsr:@std/dotenv@0.225.5';
export { bold, cyan, green } from 'jsr:@std/fmt@1.0.8/colors';
6 changes: 1 addition & 5 deletions src/external/switcher-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class SwitcherClient {
Client.scheduleSnapshotAutoUpdate(Number(updateInterval), {
success: (updated) => {
if (updated) {
logger('INFO', 'SwitcherClient', `Snapshot updated: ${Client.snapshot?.data.domain.version}`);
logger('INFO', 'SwitcherClient', `Snapshot updated: ${Client.snapshotVersion}`);
}
},
reject: (err) => {
Expand All @@ -60,8 +60,4 @@ export default class SwitcherClient {

return true;
}

static terminateSnapshotAutoUpdate(): void {
Client.terminateSnapshotAutoUpdate();
}
}
7 changes: 5 additions & 2 deletions src/routes/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ router.post(
async (context: Context) => {
try {
const request = toFeatureRequestDto(context);
const status = await getService().isFeatureEnabled(request);
const service = getService();
const status = await service.isFeatureEnabled(request);

responseSuccess(context, toFeatureResponseDto(status));
} catch (error) {
Expand All @@ -48,7 +49,9 @@ router.post(
async (context: Context) => {
try {
const request = toFeaturesRequestDto(context);
const statuses = await getService().isFeaturesEnabled(request);
const service = getService();
const statuses = await service.isFeaturesEnabled(request);

responseSuccess(context, toFeaturesResponseDto(statuses));
} catch (error) {
responseError(context, error as Error, 500, true);
Expand Down
6 changes: 1 addition & 5 deletions src/services/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ class FeatureService {

return {
feature: featureReq.feature,
result: (await switcher.isItOn(featureReq.feature)) as boolean,
result: await switcher.isItOnBool(featureReq.feature, true),
};
}));

return featuresRes;
}

terminateSnapshotAutoUpdate() {
SwitcherClient.terminateSnapshotAutoUpdate();
}
}

export default FeatureService;
4 changes: 2 additions & 2 deletions tests/deps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { type Middleware, testing } from 'jsr:@oak/oak@17.1.4';
export { Client, StrategiesType } from 'jsr:@switcherapi/switcher-client-deno@2.1.0';
export { type Middleware, testing } from 'jsr:@oak/oak@17.1.5';
export { Client, StrategiesType } from 'jsr:@switcherapi/switcher-client-deno@2.3.0';
export { superoak } from 'https://deno.land/x/superoak@5.0.0/mod.ts';
export { assert, assertEquals, assertFalse, assertObjectMatch } from 'jsr:@std/assert@1.0.13';
4 changes: 2 additions & 2 deletions tests/services/feature.integrated.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import FeatureService from '../../src/services/feature.ts';
import { assert } from '../deps.ts';
import { assert, Client } from '../deps.ts';

const featureService = new FeatureService();

const teardown = () => {
Deno.env.set('SWITCHER_SNAPSHOT_UPDATE_INTERVAL', '');
featureService.terminateSnapshotAutoUpdate();
Client.terminateSnapshotAutoUpdate();
};

const setupDenoEnv = async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/services/feature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Deno.test({

//assert
assertFalse(response);
featureService.terminateSnapshotAutoUpdate();
Client.terminateSnapshotAutoUpdate();
}),
});

Expand All @@ -47,6 +47,6 @@ Deno.test({

//assert
assert(response);
featureService.terminateSnapshotAutoUpdate();
Client.terminateSnapshotAutoUpdate();
}),
});