-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.js
35 lines (31 loc) · 944 Bytes
/
sign.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var AWS = require('aws-sdk')
AWS.config.update({
region: 'ap-northeast-2',
endpoint: "http://dynamodb.ap-northeast-2.amazonaws.com"
})
const docClient = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, context, callback) {
const operation = event.httpMethod;
switch (operation) {
case 'POST':
var params = {
TableName: "teacher",
Item: {
"id": event.id,
"name": event.name,
"password": event.password,
"email": event.email
}
};
docClient.put(params, function(err, data) {
if(err){
callback(err, null);
} else{
callback(null, data);
}
})
break;
default:
callback(new Error(`Operation Error`));
}
}