in source/services/api/admin/lib/admin.js [335:373]
async createAuthorization(apiKeyValue, applicationId, apiKeyName, apiKeyDescription, apiKeyId) {
try {
const docClient = new AWS.DynamoDB.DocumentClient(this.config);
const updated_at = moment().utc().format();
const created_at = moment().utc().format();
const params = {
TableName: process.env.AUTHORIZATIONS_TABLE,
Item: {
api_key_id: apiKeyId,
application_id: applicationId,
api_key_name: apiKeyName,
api_key_value: apiKeyValue,
api_key_description: apiKeyDescription,
updated_at: updated_at,
created_at: created_at,
enabled: true
}
};
await docClient.put(params).promise();
const response = {
ApiKeyId: params.Item.api_key_id,
ApiKeyValue: params.Item.api_key_value,
ApiKeyName: apiKeyName,
ApplicationId: applicationId,
ApiKeyDescription: apiKeyDescription,
CreatedAt: created_at,
UpdatedAt: updated_at,
Enabled: true
};
return Promise.resolve(response);
} catch (err) {
console.log(JSON.stringify(err));
return Promise.reject({
code: 500,
error: 'InternalFailure',
message: `Error creating authorization`
});
}
}