How to use the dynamoose.AWS function in dynamoose

To help you get started, we’ve selected a few dynamoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github belongco / nextjs-serverless-setup / server.js View on Github external
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');
}
github ctindel / reader / social-auth-example / backend / dynamoose.js View on Github external
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})+$/
github novemberde / serverless-todo-demo / serverless-api / routes / todo.js View on Github external
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,
});
github belongco / nextjs-serverless-setup / server.js View on Github external
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();
github lucianopf / bitwages / lib / db.js View on Github external
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
  },

dynamoose

Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)

Unlicense
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis