Phase 1+2: Nx workspace with apps, libs, and module boundaries

This commit is contained in:
Maurycy
2026-05-06 21:15:49 +01:00
commit b196624929
93 changed files with 19667 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import axios from 'axios';
describe('GET /api', () => {
it('should return a message', async () => {
const res = await axios.get(`/api`);
expect(res.status).toBe(200);
expect(res.data).toEqual({ message: 'Hello API' });
});
});

View File

@@ -0,0 +1,16 @@
import { waitForPortOpen } from '@nx/node/utils';
/* eslint-disable */
var __TEARDOWN_MESSAGE__: string;
module.exports = async function () {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log('\nSetting up...\n');
const host = process.env.HOST ?? 'localhost';
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
await waitForPortOpen(port, { host });
// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
};

View File

@@ -0,0 +1,10 @@
import { killPort } from '@nx/node/utils';
module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
await killPort(port);
console.log(globalThis.__TEARDOWN_MESSAGE__);
};

View File

@@ -0,0 +1,9 @@
import axios from 'axios';
module.exports = async function () {
// Configure axios for tests to use.
const host = process.env.HOST ?? 'localhost';
const port = process.env.PORT ?? '3000';
axios.defaults.baseURL = `http://${host}:${port}`;
};