Skip to content
Permalink
Browse files

All Network Messages Endpoints

  • Loading branch information...
Liam-Griffiths committed Aug 13, 2019
1 parent a0f1f3e commit 6a376bbc6140da2cd14fed5977a3a44b651b42b5
Showing with 53 additions and 0 deletions.
  1. +9 −0 api/dataFetch/fetchMetrolink.js
  2. +35 −0 api/publicData/getNetworkMsgs.js
  3. +9 −0 serverless.yml
@@ -127,6 +127,15 @@ module.exports.fetchMetrolink = (event, context, callback) => {
}
putToTable(updateNames);

var updateNames = {
TableName: "Tramstops",
Item: {
"name": "MSG_LIST",
"data": JSON.stringify(msgArr),
}
}
putToTable(updateNames);

var returnObj = { stopData: dbArr, msgData: msgArr };

callback(null, { statusCode: 200, body: JSON.stringify(returnObj) });
@@ -0,0 +1,35 @@
var AWS = require("aws-sdk");
AWS.config.setPromisesDependency(require('bluebird'));
var docClient = new AWS.DynamoDB.DocumentClient();

module.exports.getNetworkMsgs = (event, context, callback) => {

(async () => {
try {

var params = {
TableName: "Tramstops",
Key: {
"name": "MSG_LIST"
}
};

docClient.get(params, function (err, data) {
if (err) {
callback(null, { statusCode: 500, body: JSON.stringify({ status: "error", message: "something went wrong", data: err }) });
} else {
data.Item.data = JSON.parse(data.Item.data);
callback(null, {
statusCode: 200,
headers: { "Access-Control-Allow-Origin": "*" },
body: JSON.stringify({ status: "success", message: "", data: data.Item })
});
}
});
} catch (error) {

callback(null, { statusCode: 500, body: JSON.stringify(error) });

}
})();
}
@@ -61,6 +61,15 @@ functions:
method: get
cors: true

GetNetworkMsgs:
handler: api/publicData/getNetworkMsgs.getNetworkMsgs
memorySize: 128
description: Get NetworkMsgs
events:
- http:
path: '/networkMsgs'
method: get
cors: true

GetStopData:
handler: api/publicData/getStopData.getStopData

0 comments on commit 6a376bb

Please sign in to comment.
You can’t perform that action at this time.