Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fahad19 committed Sep 20, 2023
0 parents commit 1dd4a88
Show file tree
Hide file tree
Showing 11 changed files with 11,427 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# featurevisor-example-nuxt

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

For Featurevisor documentation, visit [https://featurevisor.com](https://featurevisor.com).

## Setup

Make sure to install the dependencies:

```
$ npm install
```

## Development Server

Start the development server on `http://localhost:3000`:

```
$ npm run dev
```

## Production

Build the application for production:

```
$ npm run build
```

Locally preview production build:

```
$ npm run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
28 changes: 28 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
import { getInstance } from "./featurevisor";
const f = await getInstance();
const featureKey = "my_feature";
const context = {};
const isEnabled = f.isEnabled(featureKey, context);
</script>

<template>
<div class="container">
<h2>Featurevisor and Nuxt integration example</h2>

<p v-if="isEnabled">Feature is enabled!</p>
<p v-else>Feature is disabled :(</p>

<p>Learn more at <a href="https://featurevisor.com">https://featurevisor.com</a></p>
</div>
</template>

<style>
.container {
font-family: sans-serif;
text-align: center;
}
</style>
20 changes: 20 additions & 0 deletions featurevisor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createInstance, FeaturevisorInstance } from "@featurevisor/sdk";

const DATAFILE_URL =
"https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json";

let instance: FeaturevisorInstance;

export async function getInstance() {
if (instance) {
return instance;
}

const f = createInstance({
datafileUrl: DATAFILE_URL,
});

instance = await f.onReady();

return instance;
}
4 changes: 4 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true }
})
Loading

0 comments on commit 1dd4a88

Please sign in to comment.