|
| 1 | +######################## |
| 2 | +# Setup |
| 3 | + |
| 4 | +setup-reference-implementation-install-dependencies: |
| 5 | + cd apps/api && npm i |
| 6 | + |
| 7 | +setup-reference-implementation-nitro-prepare: |
| 8 | + cd apps/api && npm run prepare |
| 9 | + |
| 10 | +setup-reference-implementation-db-generate: |
| 11 | + cd apps/api/server && npm run db:generate |
| 12 | + |
| 13 | +setup-reference-implementation: |
| 14 | + make setup-reference-implementation-install-dependencies |
| 15 | + echo -e '\n\033[0;32m INSTALLED DEPENDENCIES\033[0m\n' |
| 16 | + make setup-reference-implementation-nitro-prepare |
| 17 | + echo -e '\n\033[0;32m PREPARED NITRO\033[0m\n' |
| 18 | + make setup-reference-implementation-db-generate |
| 19 | + echo -e '\n\033[0;32m GENERATED PRISMA\033[0m\n' |
| 20 | + |
| 21 | +######################## |
| 22 | +# Run |
| 23 | + |
| 24 | +run-reference-implementation-for-postman: # WARNING clearly not production ready |
| 25 | + JWT_SECRET=dxLmhnE0pRY2+vUlu+i5Pxh8LTxLBTgBWdp82W74mMs= npm -C apps/api run dev |
| 26 | + |
| 27 | +######################## |
| 28 | +# Tests |
| 29 | + |
| 30 | +test-reference-implementation-with-postman-and-already-launched-server: |
| 31 | + DELAY_REQUEST=50 APIURL=http://localhost:3000/api api/run-api-tests.sh |
| 32 | + |
| 33 | +test-reference-implementation-with-postman: |
| 34 | + @set -e; \ |
| 35 | + JWT_SECRET=dxLmhnE0pRY2+vUlu+i5Pxh8LTxLBTgBWdp82W74mMs= npm -C apps/api run dev & \ |
| 36 | + SERVER_PID=$$!; \ |
| 37 | + trap "kill $$SERVER_PID 2>/dev/null || true" EXIT; \ |
| 38 | + sleep 0.3; \ |
| 39 | + kill -0 "$$SERVER_PID" 2>/dev/null || exit 4; \ |
| 40 | + make test-reference-implementation-with-postman-and-already-launched-server && ( \ |
| 41 | + make clean-running-processes; echo -e '\n\033[0;32m TESTS OK\033[0m\n' && exit 1 \ |
| 42 | + ) || ( \ |
| 43 | + make clean-running-processes; echo -e '\n\033[0;31m TESTS FAILED\033[0m\n' && exit 1 \ |
| 44 | + ) |
| 45 | + |
| 46 | +######################## |
| 47 | +# Cleaning |
| 48 | + |
| 49 | +clean-running-processes: # killing the parent is usually not enough, we should kill throught this helper |
| 50 | + ps a -A -o pid,cmd \ |
| 51 | + | grep "$$(pwd)/apps/api/node_modules/.bin/nitro dev" \ |
| 52 | + | cut -d" " -f1 \ |
| 53 | + | xargs -I {} kill -9 {} \ |
| 54 | + || true |
| 55 | + |
| 56 | +clean-all-non-default-files: |
| 57 | + rm -rf apps/api/node_modules # npm modules - includes some files generated by prisma -> node_modules/@prisma/client |
| 58 | + rm -f appd/api/prisma/dev.db # dev database |
0 commit comments