Skip to content

Commit

Permalink
added uci-dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
dorongrinstein committed Nov 6, 2024
1 parent c39bec3 commit 4e22181
Show file tree
Hide file tree
Showing 4 changed files with 1,290 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/uci-dynamo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16.6.2-bullseye-slim


WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install
RUN npm ci --only=production

COPY . .

EXPOSE 8080
CMD [ "node", "index.js" ]
20 changes: 20 additions & 0 deletions examples/uci-dynamo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const express = require('express');
const app = express();
var AWS = require("aws-sdk");
const REGION = process.env.REGION || "us-west-2";
AWS.config.update({ region: `${REGION}` });
const dynamoDB = new AWS.DynamoDB.DocumentClient()
app.get('/:item', readFromDynamoDB);
app.get('/', (req, res) => res.send('Hi bob, specify an item like /cats'));

app.listen(8080);
console.log("listening on port 8080, Dynamo Region", REGION);

function readFromDynamoDB(req, res) {
console.log(`reading ${req.params.item} from DynamoDB`);
dynamoDB.scan({
TableName: req.params.item,
}).promise().then(data => res.send(data.Items)).catch(err => res.send(err));
}


Loading

0 comments on commit 4e22181

Please sign in to comment.