Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import dynamoose from 'dynamoose';
/* istanbul ignore next */
if (process.env.IS_OFFLINE) {
process.env.AWS_REGION = 'localhost';
dynamoose.local();
}
/* istanbul ignore next */
if (process.env.NODE_ENV === 'test') {
process.env.AWS_REGION = 'localhost';
process.env.DYNAMODB_TABLE = `test-table-${process.env.JEST_WORKER_ID}`;
dynamoose.local();
}
export default dynamoose;
const dynamoose = require('dynamoose')
const dynamoURL = process.env.dynamoURL || 'defaultDynamoDbUrl'
dynamoose.AWS.config.update({
accessKeyId: process.env.accessKeyId || 'defaultKey',
secretAccessKey: process.env.secretAccessKey || 'defaultKey',
region: process.env.region || 'defaultKey'
})
dynamoose.local(dynamoURL)
const Api = dynamoose.model('api', {
id: {
type: Number,
hashKey: true,
index: true
},
timestamp: {
type: Date,
index: true
},
PricesSummary: Array,
percentageOverBitwage: Array,
USDBRL: Array,
USDBRLACTIVEACTION: Array,
USDBRLPASSIVEACTION: Array,
dynamoose.AWS.config.update({
region: process.env.SERVICE_AWS_REGION,
});
if (process.env.NODE_ENV === 'development') {
/*
For development environment, atleast with dynamoose library,
you need to pass mock access key & secret.
*/
dynamoose.AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_ACCESS_SECRET,
region: process.env.SERVICE_AWS_REGION,
});
dynamoose.local('http://localhost:8000');
}
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
const Dog = require('./models/Dog');
function createServer() {
const server = express();
server.get('/api/dog/:breed', async (req, res) => {
const { breed } = req.params;
try {
const dogData = await Dog.query('breed').eq(breed).exec();