-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
187 additions
and
3,321 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
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
[ ![appsample](https://travis-ci.org/ffaerber/appsample.svg?branch=master)](https://travis-ci.org/ffaerber/appsample) | ||
|
||
# appsample | ||
this is a koa.js application for testing modern node based microservices. | ||
|
||
this is a example api application for testing and learning. | ||
|
||
- docker arm https://www.youtube.com/watch?v=nrBYUw1Pz5I | ||
- docker CI https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/ | ||
- testing https://www.valentinog.com/blog/testing-api-koa-jest/ | ||
- test api | | ||
- create `curl -X POST -H 'Content-Type: application/json' -d '{"id":"123","title":"test","body":"my Article"}' http://localhost:3000/api/v1/articles` | ||
- update `curl -X PUT -H 'Content-Type: application/json' -d '{"id":"123","title":"test","body":"my New Article"}' http://localhost:3000/api/v1/articles/123` | ||
- show `curl http://localhost:3000/api/v1/articles/123` | ||
- delete `curl -X "DELETE" http://localhost:3000/api/v1/articles/123` |
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 |
---|---|---|
@@ -1,33 +1,30 @@ | ||
version: '3.3' | ||
version: "3.3" | ||
|
||
volumes: | ||
node_modules: | ||
driver: local | ||
|
||
|
||
services: | ||
|
||
# dev-app: | ||
# image: ffaerber/appsample | ||
# # build: | ||
# # context: . | ||
# # image: ffaerber/appsample | ||
# build: | ||
# context: . | ||
# ports: | ||
# - "3000:3000" | ||
# environment: | ||
# - REDIS_HOST=redis://redis-db | ||
# REDIS_HOST: redis://redis-db | ||
# volumes: | ||
# - node_modules:/usr/src/app/node_modules | ||
|
||
|
||
test-app: | ||
build: | ||
context: . | ||
command: npm test | ||
environment: | ||
MONGO_HOST: mongodb://mongo-db/test | ||
REDIS_HOST: redis://redis-db | ||
volumes: | ||
- node_modules:/usr/src/app/node_modules | ||
- ./:/usr/src/app | ||
|
||
mongo-db: | ||
image: mongo | ||
redis-db: | ||
image: redis |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
const Redis = require('ioredis') | ||
|
||
module.exports = new Redis(process.env.REDIS_HOST) |
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,7 @@ | ||
const redis = require('../libs/redis') | ||
|
||
module.exports = () => async (ctx, next) => { | ||
ctx.redis = redis | ||
console.log('Redis created') | ||
await next() | ||
} |
Oops, something went wrong.