Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ Thumbs.db

.nx/cache
.nx/workspace-data

test-output
61 changes: 61 additions & 0 deletions e2e/ory-integration-e2e/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
services:
kratos:
image: ghcr.io/getlarge/nestjs-ory-integration/kratos:latest
ports:
- '44330:4433'
- '44340:4434'
networks:
- ory
environment:
- OAUTH2_PROVIDER_URL=http://hydra:4445
restart: unless-stopped

kratos-selfservice-ui-node:
image: oryd/kratos-selfservice-ui-node:v1.1.0
ports:
- '44550:4455'
environment:
- PORT=4455
- KRATOS_PUBLIC_URL=http://kratos:4433
- KRATOS_BROWSER_URL=http://127.0.0.1:44330
- COOKIE_SECRET=changeme
- CSRF_COOKIE_NAME=cookie_name
- CSRF_COOKIE_SECRET=changeme
- DANGEROUSLY_DISABLE_SECURE_CSRF_COOKIES=true
networks:
- ory
restart: on-failure

hydra:
image: ghcr.io/getlarge/nestjs-ory-integration/hydra:latest
ports:
- '44440:4444'
- '44450:4445'
networks:
- ory
restart: unless-stopped

keto:
image: ghcr.io/getlarge/nestjs-ory-integration/keto:latest
ports:
- '44660:4466'
- '44670:4467'
restart: on-failure

api:
image: ghcr.io/getlarge/nestjs-ory-integration/ory-integration:${DOCKER_API_TAG:-dev}
pull_policy: never
ports:
- 3000:3000
depends_on:
- kratos
- hydra
- keto
environment:
PORT: 3000
ORY_KETO_ADMIN_URL: http://keto:4467
ORY_KETO_PUBLIC_URL: http://keto:4466
ORY_KRATOS_ADMIN_URL: http://kratos:4434
ORY_KRATOS_PUBLIC_URL: http://kratos:4433
ORY_HYDRA_ADMIN_URL: http://hydra:4445
ORY_HYDRA_PUBLIC_URL: http://hydra:4444
44 changes: 44 additions & 0 deletions e2e/ory-integration-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const baseConfig = require('../../eslint.config.js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

module.exports = [
...baseConfig,
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
buildTargets: ['build'],
checkMissingDependencies: true,
checkObsoleteDependencies: true,
checkVersionMismatches: true,
includeTransitiveDependencies: true,
ignoredDependencies: ['@getlarge/base-client-wrapper'],
},
],
},
languageOptions: { parser: require('jsonc-eslint-parser') },
},
];
18 changes: 18 additions & 0 deletions e2e/ory-integration-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
displayName: 'ory-integration-e2e',
preset: '../../jest.preset.js',
globalSetup: '<rootDir>/src/support/global-setup.ts',
globalTeardown: '<rootDir>/src/support/global-teardown.ts',
setupFiles: ['<rootDir>/src/support/test-setup.ts'],
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/ory-integration-e2e',
};
27 changes: 27 additions & 0 deletions e2e/ory-integration-e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ory-integration-e2e",
"version": "0.0.1",
"private": true,
"nx": {
"name": "ory-integration-e2e",
"projectType": "application",
"implicitDependencies": [
"ory-integration"
],
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{e2eProjectRoot}"
],
"options": {
"jestConfig": "e2e/ory-integration-e2e/jest.config.ts",
"passWithNoTests": true
},
"dependsOn": [
"ory-integration:build"
]
}
}
}
}
1 change: 1 addition & 0 deletions e2e/ory-integration-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -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' });
});
});
20 changes: 20 additions & 0 deletions e2e/ory-integration-e2e/src/support/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { execSync } from 'node:child_process';

/* eslint-disable */
var __TEARDOWN_MESSAGE__: string;

module.exports = async function () {
console.log('\nSetting up...\n');
// publish and link all packages
execSync('node tools/scripts/publish-all-locally.mjs');
// build API and Ory images
if (!process.env.CI) {
execSync('npx nx run-many -t docker-push');
}
// start Ory services and API
execSync(
'docker-compose -f e2e/ory-integration/docker-compose.yml up -d --wait',
);

globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
};
9 changes: 9 additions & 0 deletions e2e/ory-integration-e2e/src/support/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */

import { execSync } from 'node:child_process';

module.exports = async function () {
execSync('docker-compose -f e2e/ory-integration/docker-compose.yml down');

console.log(globalThis.__TEARDOWN_MESSAGE__);
};
9 changes: 9 additions & 0 deletions e2e/ory-integration-e2e/src/support/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
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}`;
};
11 changes: 11 additions & 0 deletions e2e/ory-integration-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/ory-integration-e2e",
"esModuleInterop": true,
"noUnusedLocals": false,
"noImplicitAny": false
},
"include": ["jest.config.ts", "src/**/*.ts"],
"references": []
}
25 changes: 25 additions & 0 deletions e2e/ory-integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG NODE_VERSION=22

FROM node:$NODE_VERSION AS deps

WORKDIR /e2e/ory-integration

COPY ./e2e/ory-integration/package*.json ./

RUN npm install --omit=dev -f --loglevel=error --include=optional

RUN curl -sf https://gobinaries.com/tj/node-prune | sh
RUN node-prune

FROM node:$NODE_VERSION

USER node

ENV NODE_ENV=development

WORKDIR /e2e/ory-integration

COPY --from=deps --chown=node:node /e2e/ory-integration ./
COPY --chown=node:node ./dist/e2e/ory-integration ./

CMD ["node", "main.js"]
44 changes: 44 additions & 0 deletions e2e/ory-integration/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const baseConfig = require('../../eslint.config.js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

module.exports = [
...baseConfig,
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
},
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
buildTargets: ['build'],
checkMissingDependencies: true,
checkObsoleteDependencies: true,
checkVersionMismatches: true,
includeTransitiveDependencies: true,
ignoredDependencies: ['@getlarge/base-client-wrapper'],
},
],
},
languageOptions: { parser: require('jsonc-eslint-parser') },
},
];
Loading