Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const express = require('express');
const next = require('next');
const path = require('path');
const dynamoose = require('dynamoose');
if (process.env.NODE_ENV === 'development') {
require('dotenv').config({ path: path.resolve(__dirname, `./env/${process.env.ENV_FILE}`) });
}
// Configure Dynamoose
// The accessKeyId & secretAccessKey can be made avaialble via the IAMRole
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 CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
const AWS = require('aws-sdk');
const request = require('request');
const jwkToPem = require('jwk-to-pem');
const jwt = require('jsonwebtoken');
// The amazon-cognito-identity-js uses fetch, which isn't in node.js core
global.fetch = require('node-fetch');
const poolData = {
UserPoolId: config.cognito.userPoolId,
ClientId : config.cognito.appClientId
};
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
dynamoose.AWS.config.update({
accessKeyId: config.aws.accessKeyId,
secretAccessKey: config.aws.secretAccessKey,
region: config.aws.region
});
// dynamoose.local("http://localhost:8000") // This will set the server to "http://localhost:1234"
module.exports = function () {
var UserSchema = new Schema({
email: {
type: String,
hashKey: true,
required: true,
trim: true,
lowercase: true,
match: /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
const router = require("express").Router();
const dynamoose = require('dynamoose');
const _ = require('lodash');
dynamoose.AWS.config.region = process.env.AWS_REGION;
const Todo = dynamoose.model('Todo', {
userId: {
type: String,
hashKey: true
},
createdAt: {
type: String,
rangeKey: true
},
updatedAt: String,
title: String,
content: String
}, {
create: false, // Create a table if not exist,
});
require('dotenv').config({ path: path.resolve(__dirname, `./env/${process.env.ENV_FILE}`) });
}
// Configure Dynamoose
// The accessKeyId & secretAccessKey can be made avaialble via the IAMRole
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();
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
},