Socket
Socket
Sign inDemoInstall

@architect/data

Package Overview
Dependencies
200
Maintainers
7
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 3.0.0

db.js

19

index.js

@@ -1,10 +0,11 @@

var fs = require('fs')
var path = require('path')
var parse = require('@architect/parser')
var exists = fs.existsSync
var init = require('./src/_init')
let fs = require('fs')
let path = require('path')
let parse = require('@architect/parser')
let exists = fs.existsSync
let init = require('./src/_init')
// path to the .arc for hydration
var arcPath
/**
* NOTE: this code path will incur a bunch of sync lookups
*/
let arcPath
let arcDefault = path.join(process.cwd(), 'node_modules', '@architect', 'shared', '.arc')

@@ -32,4 +33,4 @@ let arcInCurrentDir = path.join(process.cwd(), '.arc')

// returns a client for the .arc
var arc = parse(fs.readFileSync(arcPath).toString())
let arc = parse(fs.readFileSync(arcPath).toString())
module.exports = init(arc)
{
"name": "@architect/data",
"version": "2.1.0",
"version": "3.0.0",
"description": "Dynamically generate a DynamoDB data access layer from an .arc file",

@@ -28,3 +28,4 @@ "homepage": "https://github.com/arc-repos/arc-data",

"dependencies": {
"@architect/parser": "^1.1.6",
"@architect/parser": "^1.1.7",
"@architect/sandbox": "^1.0.10",
"chalk": "^2.4.2",

@@ -34,8 +35,7 @@ "path-exists": "^3.0.0"

"devDependencies": {
"@architect/architect": "^5.5.10",
"aws-sdk": "^2.427.0",
"aws-sdk": "^2.480.0",
"eslint": "^5.16.0",
"run-parallel": "^1.1.9",
"tap-spec": "^5.0.0",
"tape": "^4.10.1"
"tape": "^4.10.2"
},

@@ -42,0 +42,0 @@ "prettier": {

@@ -80,3 +80,3 @@ ## [`@architect/data`](https://www.npmjs.com/package/@architect/data)

## Convienance with `@architect/data`
## Convenience with `@architect/data`

@@ -130,19 +130,13 @@ This library bundles the `db` and `doc` connection scripts above. However it does require hard coding `TableName` which might not be desirable. So this module exports a single function for generating a static data access layer client that automatically resolves `TableName` based on `NODE_ENV`.

// create a post
app.posts.put({
await app.posts.put({
accountID: 'fake-id',
postID: 'fake-post-id',
title: 'neato'
},
function _put(err, result) {
if (err) throw err
console.log(result)
})
})
// read it back
app.posts.get({
postID: 'fake-post-id'
}, console.log)
let post = await app.posts.get({postID: 'fake-post-id'})
// update the record
app.posts.update({
await app.posts.update({
Key: {

@@ -158,10 +152,10 @@ postID: 'fake-post-id'

}
}, console.log)
})
// destroy it
app.posts.destroy({
await app.posts.destroy({
postID: 'fake-post-id'
}, console.log)
})
```
Check the tests for a detailed example!

@@ -1,34 +0,17 @@

let toLogicalID = require('./_to-logical-id')
let env = process.env.NODE_ENV || 'testing'
// helper for getting a table name
// if we're testing just always use 'staging' tables
// otherwise falls back to the appname-tablename-env convention
// var _name = name=> `${app}-${testing? 'staging' : process.env.NODE_ENV}-${name}`
module.exports = function getTables(arc) {
if (!arc.tables || arc.tables && arc.tables.length === 0)
return []
if (process.env.ARC_CLOUDFORMATION) {
// lookup cloudformation generated table name
return arc.tables.map(function getCloudFormationName(table) {
// arc table name
let tableName = Object.keys(table)[0]
let envVarName = `ARC_TABLE_${toLogicalID(tableName).toUpperCase()}`
return process.env[envVarName]
})
}
else {
// traditional path
let testing = env === 'testing' || env === 'staging'
let app = arc.app[0]
// helper for getting a table name
// if we're testing just always use 'staging' tables
// otherwise falls back to the appname-tablename-env convention
let _name = name=> `${app}-${testing? 'staging' : process.env.NODE_ENV}-${name}`
let testing = env === 'testing' || env === 'staging'
let app = arc.app[0]
// list of all tables (if any) defined in .arc
return arc.tables.map(t=> _name(Object.keys(t)[0]))
}
// helper for getting a table name
// if we're testing just always use 'staging' tables
// otherwise falls back to the appname-tablename-env convention
let _name = name=> `${app}-${testing? 'staging' : process.env.NODE_ENV}-${name}`
// list of all tables (if any) defined in .arc
return arc.tables.map(t=> _name(Object.keys(t)[0]))
}

@@ -1,3 +0,3 @@

let _db = require('./db')
let _doc = require('./doc')
let _db = require('../db')
let _doc = require('../doc')
let tables = require('./_get-tables')

@@ -4,0 +4,0 @@ let pfy = require('./_promisify-object')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc