Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
const Alexa = require('ask-sdk-core');
const WordConstants = require('./words.js');
const GameOn = require('./gameOn.js');
const {DynamoDbPersistenceAdapter} = require('ask-sdk-dynamodb-persistence-adapter');
const persistenceAdapter = new DynamoDbPersistenceAdapter({
tableName: 'WordWordLitePersistence',
createTable: true
});
const PlayGameRequestHandler = {
canHandle(handlerInput) {
this.handlerInput = handlerInput;
return this.requestType === 'IntentRequest' && this.intentName === 'PLAY_GAME_INTENT';
},
async handle(handlerInput) {
this.handlerInput = handlerInput;
const attributes = this.getSessionAttributesManager;
const player = await this.getPersistentAttributesManager;
// Update score from count of user utterances.
const matchWord = attributes.currentWord.toLowerCase();
module.exports = (actions) => {
// TODO: we don't need it for session attributes
// turn on once we will have persistent attributes
const region = process.env.AWS_REGION || 'us-west-1';
debug('set AWS region', region);
const dynamoDbPersistenceAdapter = new DynamoDbPersistenceAdapter({
createTable: true,
dynamoDBClient: new AWS.DynamoDB({ apiVersion: 'latest', region }),
tableName: process.env.DYNAMO_DB_SESSION_TABLE || 'InternetArchiveSessions',
});
const handlers = handlersBuilder(actions);
debug(`We can handle intents: ${handlers.map(({ intent }) => `"${intent}"`).join(', ')}`);
let lambda = Alexa.SkillBuilders.custom()
.addRequestHandlers(...handlers)
.addErrorHandlers(ErrorHandler)
.addRequestInterceptors(
() => pipeline.stage(pipeline.PROCESS_REQUEST)
)
.addRequestInterceptors(LogInterceptor)
.addResponseInterceptors(
it('should be able to add DynamoDbPersistenceAdapter with customization', () => {
const skillConfig = StandardSkillFactory.init()
.withTableName('testTable')
.withAutoCreateTable(false)
.withDynamoDbClient(new DynamoDB({apiVersion : 'latest'}))
.withPartitionKeyGenerator(PartitionKeyGenerators.userId)
.getSkillConfiguration();
expect(skillConfig.persistenceAdapter).instanceOf(DynamoDbPersistenceAdapter);
});
});