Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tm-authors-api

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tm-authors-api - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

config/default.json

@@ -8,5 +8,5 @@ {

"region": "eu-west-1",
"tableName": "Authors-vulcan"
"tableName": "AuthorsStateStore-vulcan"
},
"logging": true
}

@@ -10,3 +10,3 @@ {

"name": "presentation",
"image": "trinitymirror/authors-api:2.0.0",
"image": "trinitymirror/authors-api:2.0.1",
"essential": "true",

@@ -13,0 +13,0 @@ "memory": 1700,

{
"name": "tm-authors-api",
"version": "2.0.0",
"version": "2.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,9 +13,7 @@ "use strict";

"getByAuthorId": db => (req, res, next) => {
const id = `${req.params.source}.${req.params.journoId}`;
db.getStream({
"TableName": tableName,
"Key": {
"id": id
"Id": Number(req.params.journoId),
"Source": `${req.params.source}-author`
}

@@ -25,5 +23,5 @@ })

if (err) {
next(new restify.InternalServerError(err));
next(new restify.InternalServerError(err.stack));
} else if (R.isNil(result.Item)) {
next(new restify.NotFoundError(`Author ${id} does not exist`));
next(new restify.NotFoundError(`Author does not exist`));
} else {

@@ -39,3 +37,9 @@ res.send(result.Item);

.reject(R.isNil)
.map(R.objOf("id"))
.map(id => {
const split = id.split(".");
return {
Id: Number(split[1]),
"Source": `${split[0]}-author`
}
})
.collect()

@@ -48,3 +52,3 @@ .map(R.objOf("Keys"))

if (err) {
next(new restify.InternalServerError(err));
next(new restify.InternalServerError(err.stack));
} else {

@@ -51,0 +55,0 @@ res.send(result.Responses[tableName]);

@@ -15,3 +15,4 @@ "use strict";

const robbie = {
"id": "nationals.1235",
"Id": 1235,
"Source": "nationals-author",
"url": "www.mirror.co.uk/authors/robbie-s",

@@ -25,3 +26,4 @@ "name": "robbie-s",

const kimmy = {
"id": "nationals.1234",
"Id": 1234,
"Source": "nationals-author",
"url": "www.mirror.co.uk/authors/kimmy-k",

@@ -35,3 +37,4 @@ "name": "kimmy k",

const testAuthor = {
"id": "nationals.123",
"Id": 123,
"Source": "nationals-author",
"url": "www.mirror.co.uk/authors/author-jim",

@@ -47,9 +50,13 @@ "name": "Jim Author",

dynamo.deleteTable({
"TableName": "Authors-test"
"TableName": config.dynamodb.tableName
}, (err, res) => {
dynamo.createTable({
"TableName": "Authors-test",
"TableName": config.dynamodb.tableName,
"AttributeDefinitions": [
{
"AttributeName": "id",
"AttributeName": "Id",
"AttributeType": "N"
},
{
"AttributeName": "Source",
"AttributeType": "S"

@@ -60,4 +67,8 @@ }

{
"AttributeName": "id",
"AttributeName": "Id",
"KeyType": "HASH"
},
{
"AttributeName": "Source",
"KeyType": "RANGE"
}

@@ -75,14 +86,17 @@ ],

db.putStream({
"TableName": "Authors-test",
"TableName": config.dynamodb.tableName,
"Item": testAuthor
})
.flatMap(() => db.putStream({
"TableName": "Authors-test",
"TableName": config.dynamodb.tableName,
"Item": robbie
}))
.flatMap(() => db.putStream({
"TableName": "Authors-test",
"TableName": config.dynamodb.tableName,
"Item": kimmy
}))
.toCallback(done);
.toCallback((err, res) => {
console.log(err, res);
done();
});
});

@@ -106,3 +120,3 @@

assert.equal(res.body.code, "NotFoundError");
assert.equal(res.body.message, "Author nationals.1 does not exist");
assert.equal(res.body.message, "Author does not exist");
done();

@@ -109,0 +123,0 @@ })

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc