-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c39bec3
commit 4e22181
Showing
4 changed files
with
1,290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
|
Oops, something went wrong.