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 node server side #18

Draft
wants to merge 72 commits into
base: main
Choose a base branch
from
Draft

Feat node server side #18

wants to merge 72 commits into from

Conversation

Tim-53
Copy link
Collaborator

@Tim-53 Tim-53 commented May 31, 2023

Adds possibility to use abby on serverside within any NodeJS enviroment

  • cache flag values
  • ab testing middleware
  • feature flag middleware

@vercel
Copy link

vercel bot commented May 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
abby-opensource ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 13, 2023 6:06pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
abby-docs ⬜️ Ignored (Inspect) Visit Preview Jul 13, 2023 6:06pm

add requestContext, fix cookie parser add middleware
adding basic setup for tests including msw setup
@@ -1,5 +1,6 @@
import { ABBY_BASE_URL } from "./constants";
import type { AbbyEventType, AbbyEvent, AbbyDataResponse } from "./index";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@@ -48,6 +48,11 @@ interface PersistentStorage {
set: (key: string, value: string) => void;
}

type flagCacheConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done in another PR? maybe finish that one first? =)

@@ -121,8 +121,146 @@ describe("Abby", () => {

expect(abby.getFeatureFlag("flag1")).toBe(false);
});

it("refetches an expired flag", async () =>{
const date = new Date() //current date
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment says nothing, why dont we use ; in here? Oo

Suggested change
const date = new Date() //current date
const date = new Date();

@@ -7,5 +7,6 @@ export default defineConfig({
clean: true,
sourcemap: true,
treeshake: true,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

import { Request } from "express";
import { FastifyRequest } from "fastify";

// type RequestType<T> = T extends Request ? Request : FastifyRequest;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

next();
};

// const allFlagMiddleWare = <F extends keyof Flags>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

done: HookHandlerDoneFunction
) => {
const flagValue = abbyNodeInstance.getFeatureFlagValue(key as unknown as FlagName); //TODO fix type
if (flagValue) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flagValue or !flagValue?

if (flagValue) {
reply.status(403);
reply.send();
console.log("disbaled endpoint");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console


const setCookie = fastifyCookie;

console.log(setCookie);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console


fastify.addHook("onRequest", (request, reply, done) => {
ABTestHook(request, reply, done);
// featureFlagHook("lol", request, reply, done);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants