Skip to content

Commit

Permalink
feat: add liveness endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Vijayan committed Jul 1, 2021
1 parent 546156b commit 63146ed
Show file tree
Hide file tree
Showing 13 changed files with 11,154 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.DS_Store
.env
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:14-alpine as base
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci
COPY src src
COPY swagger swagger
COPY index.js index.js
ENV PORT=8080

# test step
FROM base as test
COPY test test

# production step
FROM base as production
WORKDIR /usr/src/app
COPY --from=base usr/src/app .

EXPOSE 8080
CMD ["node", "."]
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
# Price Drop Alerter

An API that determines if a price drop alert needs to be triggered for a product.

## Setup

### For development
```
git clone [email protected]:nkhil/price-drop-alerter.git
cd price-drop-alerter
npm install
npm run develop
```

## Technology

- Express
- Swagger
- openapi-express-validator
- Docker / docker-compose
## Tests

### Run tests in Docker
You can run all automated tests (unit & integration) using the following command

```
npm run test:docker
```

### Unit tests

```
npm run test:unit
```

19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.4"

services:
app:
build:
context: .
target: production
ports:
- 8080:8080
command: node --use_strict index.js
test:
build:
context: .
target: test
depends_on:
- app
command: npm test
volumes:
- ./:/app
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const logger = require('pino')();
const init = require('./src');

const { name, port } = require('./src/config');

(async () => {
const app = await init();
app.listen(port, () => {
logger.info({ msg: `${name} is listening on port ${port}` });
});
})();
Loading

0 comments on commit 63146ed

Please sign in to comment.