Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use jest for testing, add some quality-of-life improvements #230

Merged
merged 7 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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