Skip to content

Commit

Permalink
馃憰 Linting for typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
quantuminformation committed Jul 28, 2017
1 parent c449da0 commit a1d8d66
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
@@ -0,0 +1,17 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
36 changes: 18 additions & 18 deletions aws-node-typescript-rest-api-with-dynamodb/create.ts
@@ -1,17 +1,17 @@
'use strict';
'use strict'

import uuid from 'uuid'
import { DynamoDB } from 'aws-sdk'

const dynamoDb = new DynamoDB.DocumentClient();
const dynamoDb = new DynamoDB.DocumentClient()

module.exports.create = (event, context, callback) => {
const timestamp = new Date().getTime();
const data = JSON.parse(event.body);
const timestamp = new Date().getTime()
const data = JSON.parse(event.body)
if (typeof data.text !== 'string') {
console.error('Validation Failed');
callback(new Error('Couldn\'t create the todo item.'));
return;
console.error('Validation Failed')
callback(new Error('Couldn\'t create the todo item.'))
return
}

const params = {
Expand All @@ -21,24 +21,24 @@ module.exports.create = (event, context, callback) => {
text: data.text,
checked: false,
createdAt: timestamp,
updatedAt: timestamp,
},
};
updatedAt: timestamp
}
}

// write the todo to the database
dynamoDb.put(params, (error, result) => {
// handle potential errors
if (error) {
console.error(error);
callback(new Error('Couldn\'t create the todo item.'));
return;
console.error(error)
callback(new Error('Couldn\'t create the todo item.'))
return
}

// create a response
const response = {
statusCode: 200,
body: JSON.stringify(result.Item),
};
callback(null, response);
});
};
body: JSON.stringify(result.Item)
}
callback(null, response)
})
}
8 changes: 6 additions & 2 deletions aws-node-typescript-rest-api-with-dynamodb/package.json
Expand Up @@ -5,13 +5,17 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "tsc -w"
"watch": "tsc -w",
"lint": "tslint '*.ts'"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/aws-sdk": "0.0.42",
"@types/node": "^7.0.5"
"@types/node": "^7.0.5",
"tslint": "^5.5.0",
"tslint-config-standard": "^6.0.1",
"typescript": "^2.4.2"
}
}
3 changes: 1 addition & 2 deletions aws-node-typescript-rest-api-with-dynamodb/tsconfig.json
Expand Up @@ -6,9 +6,8 @@
"exclude": [
"node_modules"
],

"types": [
"node",
"aws-sdk"
]
}
}
3 changes: 3 additions & 0 deletions aws-node-typescript-rest-api-with-dynamodb/tslint.json
@@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}

0 comments on commit a1d8d66

Please sign in to comment.