Skip to content

Commit

Permalink
Merge pull request #230 from byu-oit/opinions
Browse files Browse the repository at this point in the history
Use `jest` for testing, add some quality-of-life improvements
  • Loading branch information
GaryGSC authored Jun 15, 2021
2 parents b232bf5 + ff423c3 commit d3c36c7
Show file tree
Hide file tree
Showing 9 changed files with 3,243 additions and 294 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
node_version: "14.x"
tf_version: "0.14.7" # must match value in terraform-iac/*/app/main.tf
FORCE_COLOR: 3

jobs:
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
env:
node_version: "14.x"
tf_version: "0.14.7" # must match value in terraform-iac/*/app/main.tf
FORCE_COLOR: 3
concurrency: ${{ github.ref }}
jobs:
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ override.tf.json
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

coverage
node_modules
.DS_Store
.idea
4 changes: 2 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ WORKDIR /usr/app
COPY package*.json ./
RUN npm ci --production

COPY index.js .
COPY app.js server.js ./

ENV NODE_ENV='production'
USER node
EXPOSE 8080
CMD [ "node", "index.js" ]
CMD [ "node", "server.js" ]
5 changes: 2 additions & 3 deletions src/index.js → src/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict'
const express = require('express')
const { DynamoDBClient, ScanCommand } = require('@aws-sdk/client-dynamodb')
const { S3Client, ListObjectsV2Command } = require('@aws-sdk/client-s3')
Expand Down Expand Up @@ -35,6 +36,4 @@ app.get('/', async (req, res) => {
}
})

app.listen(8080, () => {
console.log('listening on port 8080')
})
module.exports = app
10 changes: 10 additions & 0 deletions src/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'
const request = require('supertest')
const app = require('./app')

describe('GET /health', () => {
test('should return 200', async () => {
const response = await request(app).get('/health')
expect(response.statusCode).toBe(200)
})
})
Loading

0 comments on commit d3c36c7

Please sign in to comment.