Skip to content
Open
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
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM sprkldev/sprkl-node:0.0.43

RUN apk add git curl docker

RUN mkdir -p /root/.docker/cli-plugins && \
curl -SL https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64 -o /root/.docker/cli-plugins/docker-compose && \
chmod +x /root/.docker/cli-plugins/docker-compose

ENV DOCKER_HOST=unix:///var/run/docker-host.sock
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": { "VARIANT": "ubuntu-22.04" }
},
"customizations": {
"vscode": {
"extensions": ["sprkldev.sprkl-vscode"]
}
},
"mounts": ["source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"],
"runArgs": ["--network=host"]
}
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
install-sprkl-test:
runs-on: ubuntu-latest
name: Installing Sprkl Testing
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Sprkl Setup
uses: sprkl-dev/sprkl-action/setup@master
with:
npm_token: ${{ secrets.USE_SPRKL_CI_TOKEN }}
token: ${{ secrets.USE_SPRKL_CI_TOKEN }}
setenv: false

- run: yarn install
- run: yarn test:e2e:sprkl
env:
SPRKL_RECIPE: all

2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ services:
VITE_CATALOG_URL: http://catalog:3000
VITE_ORDERS_URL: http://orders:3000
VITE_PAYMENTS_URL: http://payments:3000
volumes:
- "./shop/src:/code/src"
ports:
- "80:5000"

15 changes: 15 additions & 0 deletions metrics/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ mongoose.connect(`mongodb://${process.env.MONGO_HOST}/mern`, {
useCreateIndex: true,
});

app.put('/updateMetrics', async (req, res) => {
try {
const metrics = await utils.retrieveMetrics();
if (new Date().getDay() == 7) {
metrics.saturdaysCounter++;
} else {
metrics.totalCounter++;
}
await utils.updateMetrics(metrics);
res.sendStatus(200);
} catch(ex) {
res.status(401).send({ message: 'Failed updating metrics' + ex});
}
});

app.get('/metrics', async (req, res) => {
const metrics = await utils.getMetrics();
res.send({
Expand Down
1 change: 1 addition & 0 deletions orders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fastify.post('/orders', async function (request, reply) {
order.state = 'landed'
ordersCollection.insertOne(order);
reply.send(order.state).code(200);
await axios.put('http://metrics:3000/updateMetrics')
})

fastify.get('/orders', async function (request, reply) {
Expand Down
Empty file added testfile
Empty file.
Empty file added testfile2
Empty file.
Empty file added testfile3
Empty file.
Empty file added testfile4
Empty file.
Empty file added testfile5
Empty file.
Empty file added testfile6
Empty file.
Empty file added testfile7
Empty file.
Empty file added testfile8
Empty file.