Skip to content

Commit

Permalink
revert dictionary file changes, omit optional config in basic files too
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Aug 29, 2024
1 parent 1ad14d5 commit 38e7040
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 23 deletions.
3 changes: 1 addition & 2 deletions examples/nodejs/cache/basic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk';
import {CacheClient, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk';

async function main() {
const momento = await CacheClient.create({
configuration: Configurations.Laptop.v1(),
defaultTtlSeconds: 60,
});

Expand Down
6 changes: 6 additions & 0 deletions examples/nodejs/cache/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import {
Configurations,
CreateCacheResponse,
DefaultMomentoLoggerFactory,
EnvMomentoTokenProvider,
MomentoLoggerFactory,
} from '@gomomento/sdk';

const cacheName = 'cache';
const dictionaryName = 'dictionary';

const credentialsProvider = new EnvMomentoTokenProvider({
environmentVariableName: 'MOMENTO_API_KEY',
});

const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory();

const defaultTtl = 60;
Expand All @@ -23,6 +28,7 @@ let momento: CacheClient;
const main = async () => {
momento = await CacheClient.create({
configuration: Configurations.Laptop.v1(loggerFactory),
credentialProvider: credentialsProvider,
defaultTtlSeconds: defaultTtl,
});

Expand Down
3 changes: 1 addition & 2 deletions examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {CacheClient, Configurations} from '@gomomento/sdk';
import {CacheClient} from '@gomomento/sdk';

async function main() {
const cacheClient = await CacheClient.create({
configuration: Configurations.Laptop.v1(),
defaultTtlSeconds: 60,
});
}
Expand Down
3 changes: 1 addition & 2 deletions examples/nodejs/cache/readme.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {CacheClient, CacheGetResponse, Configurations} from '@gomomento/sdk';
import {CacheClient, CacheGetResponse} from '@gomomento/sdk';

async function main() {
const cacheClient = await CacheClient.create({
configuration: Configurations.Laptop.v1(),
defaultTtlSeconds: 60,
});

Expand Down
6 changes: 1 addition & 5 deletions examples/nodejs/storage/basic.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import {

Check failure on line 1 in examples/nodejs/storage/basic.ts

View workflow job for this annotation

GitHub Actions / Test examples on node 16

Replace `⏎··CreateStoreResponse,⏎··PreviewStorageClient,⏎··StorageGetResponse,⏎··StoragePutResponse,⏎` with `CreateStoreResponse,·PreviewStorageClient,·StorageGetResponse,·StoragePutResponse`

Check failure on line 1 in examples/nodejs/storage/basic.ts

View workflow job for this annotation

GitHub Actions / Test examples on node 18

Replace `⏎··CreateStoreResponse,⏎··PreviewStorageClient,⏎··StorageGetResponse,⏎··StoragePutResponse,⏎` with `CreateStoreResponse,·PreviewStorageClient,·StorageGetResponse,·StoragePutResponse`

Check failure on line 1 in examples/nodejs/storage/basic.ts

View workflow job for this annotation

GitHub Actions / Test examples on node 20

Replace `⏎··CreateStoreResponse,⏎··PreviewStorageClient,⏎··StorageGetResponse,⏎··StoragePutResponse,⏎` with `CreateStoreResponse,·PreviewStorageClient,·StorageGetResponse,·StoragePutResponse`
CreateStoreResponse,
CredentialProvider,
PreviewStorageClient,
StorageConfigurations,
StorageGetResponse,
StoragePutResponse,
} from '@gomomento/sdk';

async function main() {
const storageClient = new PreviewStorageClient({
configuration: StorageConfigurations.Laptop.latest(),
});
const storageClient = new PreviewStorageClient({});

const storeName = 'my-store';
const createStoreResponse = await storageClient.createStore(storeName);
Expand Down
6 changes: 2 additions & 4 deletions examples/nodejs/topics/topic-publish.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TopicClient, CredentialProvider, TopicConfigurations, TopicPublishResponse} from '@gomomento/sdk';
import {TopicClient, TopicPublishResponse} from '@gomomento/sdk';

import {ensureCacheExists} from './utils/cache';

Expand All @@ -9,9 +9,7 @@ async function main() {
return;
}
const [cacheName, topicName, value] = clargs;
const momento = new TopicClient({
configuration: TopicConfigurations.Default.latest(),
});
const momento = new TopicClient({});

await ensureCacheExists(cacheName);

Expand Down
7 changes: 1 addition & 6 deletions examples/nodejs/topics/topic-subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {
TopicClient,
TopicItem,
TopicSubscribe,
CredentialProvider,
TopicConfigurations,
TopicSubscribeResponse,
TopicDiscontinuity,
TopicHeartbeat,
Expand All @@ -17,10 +15,7 @@ async function main() {
return;
}
const [cacheName, topicName] = clargs;
const momento = new TopicClient({
configuration: TopicConfigurations.Default.latest(),
credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'),
});
const momento = new TopicClient({});

await ensureCacheExists(cacheName);

Expand Down
3 changes: 1 addition & 2 deletions examples/web/cache/basic.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {CacheClient, Configurations, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk-web';
import {CacheClient, CreateCacheResponse, CacheSetResponse, CacheGetResponse} from '@gomomento/sdk-web';
import {initJSDom} from './utils/jsdom';

async function main() {
// Because the Momento Web SDK is intended for use in a browser, we use the JSDom library to set up an environment
// that will allow us to use it in a node.js program.
initJSDom();
const momento = new CacheClient({
configuration: Configurations.Laptop.v1(),
defaultTtlSeconds: 60,
});

Expand Down
6 changes: 6 additions & 0 deletions examples/web/cache/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ import {
Configurations,
CreateCacheResponse,
DefaultMomentoLoggerFactory,
EnvMomentoTokenProvider,
MomentoLoggerFactory,
} from '@gomomento/sdk-web';
import {initJSDom} from './utils/jsdom';

const cacheName = 'cache';
const dictionaryName = 'dictionary';

const credentialsProvider = new EnvMomentoTokenProvider({
environmentVariableName: 'MOMENTO_API_KEY',
});

const loggerFactory: MomentoLoggerFactory = new DefaultMomentoLoggerFactory();

const defaultTtl = 60;
const momento = new CacheClient({
configuration: Configurations.Laptop.v1(loggerFactory),
credentialProvider: credentialsProvider,
defaultTtlSeconds: defaultTtl,
});

Expand Down

0 comments on commit 38e7040

Please sign in to comment.