diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
| commit | a7cf03c192470cbab13edeb1aec99e0c66dede10 (patch) | |
| tree | 581b4430d1de958dcb666bae80a7678332134602 /src/lib/config | |
| parent | 010f307346e525ac2e4239a0549d2c1a4d6d102b (diff) | |
Update / use typescript
Diffstat (limited to 'src/lib/config')
| -rw-r--r-- | src/lib/config/__mocks__/config.ts | 15 | ||||
| -rw-r--r-- | src/lib/config/apollo.ts | 14 | ||||
| -rw-r--r-- | src/lib/config/config.ts | 17 | ||||
| -rw-r--r-- | src/lib/config/env.dist | 1 |
4 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/config/__mocks__/config.ts b/src/lib/config/__mocks__/config.ts new file mode 100644 index 0000000..448e1db --- /dev/null +++ b/src/lib/config/__mocks__/config.ts @@ -0,0 +1,15 @@ +export const apollo = { + uri: 'http://127.0.0.1:1234/graphql', + name: 'COOL_APP', + version: '9.9.9', + defaultOptions: { + watchQuery: { + fetchPolicy: 'no-cache' + }, + query: { + fetchPolicy: 'no-cache' + } + } +}; + +export const version = '9.9.9'; diff --git a/src/lib/config/apollo.ts b/src/lib/config/apollo.ts new file mode 100644 index 0000000..a3820ed --- /dev/null +++ b/src/lib/config/apollo.ts @@ -0,0 +1,14 @@ +import fetch from 'cross-fetch'; +import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core'; +import { apollo as apolloConfig } from './config'; + +const cache = new InMemoryCache(); + +export const client = new ApolloClient({ + cache, + link: new HttpLink({ + uri: apolloConfig.uri, + fetch + }), + ...apolloConfig +}); diff --git a/src/lib/config/config.ts b/src/lib/config/config.ts new file mode 100644 index 0000000..1ec5ab2 --- /dev/null +++ b/src/lib/config/config.ts @@ -0,0 +1,17 @@ +const internals = { + version: '1.0.0' +}; + +/* + * The main configuration object for the Forum frontend. These values + * are calculated during compile time and need to be set in a .env + * file, otherwise it won't work. + */ + +export const apollo = { + uri: import.meta.env.VITE_APOLLO_SERVER, + name: 'forum', + version: internals.version +}; + +export const version = internals.version; diff --git a/src/lib/config/env.dist b/src/lib/config/env.dist new file mode 100644 index 0000000..1f3ff0c --- /dev/null +++ b/src/lib/config/env.dist @@ -0,0 +1 @@ +VITE_APOLLO_SERVER=http://location_of_apollo_server |