refactor: update environment variables and dependencies

This commit is contained in:
2025-02-23 14:42:06 +01:00
parent 23a145b37e
commit 69f254c791
12 changed files with 116 additions and 143 deletions

View File

@@ -25,13 +25,18 @@ jobs:
run: | run: |
cat > .env <<EOF cat > .env <<EOF
NEXT_PUBLIC_BASE_URL=${{ vars.NEXT_PUBLIC_BASE_URL }} NEXT_PUBLIC_BASE_URL=${{ vars.NEXT_PUBLIC_BASE_URL }}
NEXT_PUBLIC_GHOST_API_URL=${{ vars.NEXT_PUBLIC_GHOST_API_URL }} GHOST_API_URL=${{ vars.GHOST_API_URL }}
NEXT_PUBLIC_GHOST_API_KEY=${{ secrets.NEXT_PUBLIC_GHOST_API_KEY }} GHOST_API_KEY=${{ secrets.GHOST_API_KEY }}
NEXT_PUBLIC_MY_EMAIL=${{ vars.NEXT_PUBLIC_MY_EMAIL }} MY_EMAIL=${{ vars.MY_EMAIL }}
NEXT_PUBLIC_MY_PASSWORD=${{ secrets.NEXT_PUBLIC_MY_PASSWORD }} MY_PASSWORD=${{ secrets.MY_PASSWORD }}
EOF EOF
echo "Created .env file:" && cat .env echo "Created .env file:" && cat .env
- name: Install dependencies
run: npm install
- name: Build & Push Docker Image - name: Build & Push Docker Image
run: | run: |
# Nutzt den Branch-Namen aus dem auslösenden Workflow # Nutzt den Branch-Namen aus dem auslösenden Workflow

View File

@@ -46,7 +46,7 @@ jobs:
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22.14.0
cache: 'npm' cache: 'npm'
- name: Install Dependencies - name: Install Dependencies

View File

@@ -46,7 +46,7 @@ jobs:
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22.14.0
cache: 'npm' cache: 'npm'
- name: Install Dependencies - name: Install Dependencies
@@ -56,10 +56,10 @@ jobs:
run: | run: |
cat > .env <<EOF cat > .env <<EOF
NEXT_PUBLIC_BASE_URL=${{ vars.NEXT_PUBLIC_BASE_URL }} NEXT_PUBLIC_BASE_URL=${{ vars.NEXT_PUBLIC_BASE_URL }}
NEXT_PUBLIC_GHOST_API_URL=${{ vars.NEXT_PUBLIC_GHOST_API_URL }} GHOST_API_URL=${{ vars.GHOST_API_URL }}
NEXT_PUBLIC_GHOST_API_KEY=${{ secrets.NEXT_PUBLIC_GHOST_API_KEY }} GHOST_API_KEY=${{ secrets.GHOST_API_KEY }}
NEXT_PUBLIC_MY_EMAIL=${{ vars.NEXT_PUBLIC_MY_EMAIL }} MY_EMAIL=${{ vars.MY_EMAIL }}
NEXT_PUBLIC_MY_PASSWORD=${{ secrets.NEXT_PUBLIC_MY_PASSWORD }} MY_PASSWORD=${{ secrets.MY_PASSWORD }}
EOF EOF
echo ".env file created:" && cat .env echo ".env file created:" && cat .env

View File

@@ -18,8 +18,8 @@ afterAll(() => {
beforeEach(() => { beforeEach(() => {
nodemailermock.mock.reset(); nodemailermock.mock.reset();
process.env.NEXT_PUBLIC_MY_EMAIL = 'test@dki.one'; process.env.MY_EMAIL = 'test@dki.one';
process.env.NEXT_PUBLIC_MY_PASSWORD = 'test-password'; process.env.MY_PASSWORD = 'test-password';
}); });
describe('POST /api/email', () => { describe('POST /api/email', () => {
@@ -43,8 +43,8 @@ describe('POST /api/email', () => {
}); });
it('should return an error if EMAIL or PASSWORD is missing', async () => { it('should return an error if EMAIL or PASSWORD is missing', async () => {
delete process.env.NEXT_PUBLIC_MY_EMAIL; delete process.env.MY_EMAIL;
delete process.env.NEXT_PUBLIC_MY_PASSWORD; delete process.env.MY_PASSWORD;
const mockRequest = { const mockRequest = {
json: jest.fn().mockResolvedValue({ json: jest.fn().mockResolvedValue({

View File

@@ -1,6 +1,43 @@
import { GET } from '@/app/api/fetchAllProjects/route'; import { GET } from '@/app/api/fetchAllProjects/route';
import { NextResponse } from 'next/server'; import { NextResponse } from 'next/server';
import { mockFetch } from '@/app/__tests__/__mocks__/mock-fetch';
// Wir mocken node-fetch direkt
jest.mock('node-fetch', () => {
return jest.fn(() =>
Promise.resolve({
json: () =>
Promise.resolve({
posts: [
{
id: '67ac8dfa709c60000117d312',
title: 'Just Doing Some Testing',
meta_description: 'Hello bla bla bla bla',
slug: 'just-doing-some-testing',
updated_at: '2025-02-13T14:25:38.000+00:00',
},
{
id: '67aaffc3709c60000117d2d9',
title: 'Blockchain Based Voting System',
meta_description:
'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.',
slug: 'blockchain-based-voting-system',
updated_at: '2025-02-13T16:54:42.000+00:00',
},
],
meta: {
pagination: {
limit: 'all',
next: null,
page: 1,
pages: 1,
prev: null,
total: 2,
},
},
}),
})
);
});
jest.mock('next/server', () => ({ jest.mock('next/server', () => ({
NextResponse: { NextResponse: {
@@ -10,48 +47,27 @@ jest.mock('next/server', () => ({
describe('GET /api/fetchAllProjects', () => { describe('GET /api/fetchAllProjects', () => {
beforeAll(() => { beforeAll(() => {
process.env.NEXT_PUBLIC_GHOST_API_URL = 'http://localhost:2368'; process.env.GHOST_API_URL = 'http://localhost:2368';
process.env.NEXT_PUBLIC_GHOST_API_KEY = 'some-key'; process.env.GHOST_API_KEY = 'some-key';
global.fetch = mockFetch({
posts: [
{
id: '67ac8dfa709c60000117d312',
title: 'Just Doing Some Testing',
meta_description: 'Hello bla bla bla bla',
slug: 'just-doing-some-testing',
updated_at: '2025-02-13T14:25:38.000+00:00',
},
{
id: '67aaffc3709c60000117d2d9',
title: 'Blockchain Based Voting System',
meta_description: 'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.',
slug: 'blockchain-based-voting-system',
updated_at: '2025-02-13T16:54:42.000+00:00',
},
],
});
}); });
it('should return a list of projects', async () => { it('should return a list of projects (partial match)', async () => {
await GET(); await GET();
expect(NextResponse.json).toHaveBeenCalledWith({ // Den tatsächlichen Argumentwert extrahieren
posts: [ const responseArg = (NextResponse.json as jest.Mock).mock.calls[0][0];
{
expect(responseArg).toMatchObject({
posts: expect.arrayContaining([
expect.objectContaining({
id: '67ac8dfa709c60000117d312', id: '67ac8dfa709c60000117d312',
title: 'Just Doing Some Testing', title: 'Just Doing Some Testing',
meta_description: 'Hello bla bla bla bla', }),
slug: 'just-doing-some-testing', expect.objectContaining({
updated_at: '2025-02-13T14:25:38.000+00:00',
},
{
id: '67aaffc3709c60000117d2d9', id: '67aaffc3709c60000117d2d9',
title: 'Blockchain Based Voting System', title: 'Blockchain Based Voting System',
meta_description: 'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.', }),
slug: 'blockchain-based-voting-system', ]),
updated_at: '2025-02-13T16:54:42.000+00:00',
},
],
}); });
}); });
}); });

View File

@@ -10,8 +10,8 @@ jest.mock('next/server', () => ({
describe('GET /api/fetchProject', () => { describe('GET /api/fetchProject', () => {
beforeAll(() => { beforeAll(() => {
process.env.NEXT_PUBLIC_GHOST_API_URL = 'http://localhost:2368'; process.env.GHOST_API_URL = 'http://localhost:2368';
process.env.NEXT_PUBLIC_GHOST_API_KEY = 'some-key'; process.env.GHOST_API_KEY = 'some-key';
global.fetch = mockFetch({ global.fetch = mockFetch({
posts: [ posts: [

View File

@@ -7,8 +7,8 @@ jest.mock('next/server', () => ({
describe('GET /api/sitemap', () => { describe('GET /api/sitemap', () => {
beforeAll(() => { beforeAll(() => {
process.env.NEXT_PUBLIC_GHOST_API_URL = 'http://localhost:2368'; process.env.GHOST_API_URL = 'http://localhost:2368';
process.env.NEXT_PUBLIC_GHOST_API_KEY = 'test-api-key'; process.env.GHOST_API_KEY = 'test-api-key';
process.env.NEXT_PUBLIC_BASE_URL = 'https://dki.one'; process.env.NEXT_PUBLIC_BASE_URL = 'https://dki.one';
global.fetch = mockFetch({ global.fetch = mockFetch({
posts: [ posts: [

View File

@@ -6,8 +6,8 @@ import { mockFetch } from '@/app/__tests__/__mocks__/mock-fetch';
describe('Projects', () => { describe('Projects', () => {
beforeAll(() => { beforeAll(() => {
process.env.NEXT_PUBLIC_GHOST_API_URL = 'http://localhost:2368'; process.env.GHOST_API_URL = 'http://localhost:2368';
process.env.NEXT_PUBLIC_GHOST_API_KEY = 'some-key'; process.env.GHOST_API_KEY = 'some-key';
global.fetch = mockFetch({ global.fetch = mockFetch({
posts: [ posts: [
{ {

View File

@@ -13,8 +13,8 @@ jest.mock('next/navigation', () => ({
describe('ProjectDetails', () => { describe('ProjectDetails', () => {
beforeAll(() => { beforeAll(() => {
process.env.NEXT_PUBLIC_GHOST_API_URL = 'http://localhost:2368'; process.env.GHOST_API_URL = 'http://localhost:2368';
process.env.NEXT_PUBLIC_GHOST_API_KEY = 'some-key'; process.env.GHOST_API_KEY = 'some-key';
global.fetch = mockFetch({ global.fetch = mockFetch({
posts: [ posts: [
{ {

View File

@@ -12,8 +12,8 @@ interface ProjectsData {
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
export const runtime = "nodejs"; // Force Node runtime export const runtime = "nodejs"; // Force Node runtime
const GHOST_API_URL = process.env.NEXT_PUBLIC_GHOST_API_URL; const GHOST_API_URL = process.env.GHOST_API_URL;
const GHOST_API_KEY = process.env.NEXT_PUBLIC_GHOST_API_KEY; const GHOST_API_KEY = process.env.GHOST_API_KEY;
// Funktion, um die XML für die Sitemap zu generieren // Funktion, um die XML für die Sitemap zu generieren
function generateXml(sitemapRoutes: { url: string; lastModified: string }[]) { function generateXml(sitemapRoutes: { url: string; lastModified: string }[]) {

118
package-lock.json generated
View File

@@ -16,7 +16,7 @@
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"next": "15.1.7", "next": "15.1.7",
"node-cache": "^5.1.2", "node-cache": "^5.1.2",
"node-fetch": "^3.3.2", "node-fetch": "^2.7.0",
"nodemailer": "^6.10.0", "nodemailer": "^6.10.0",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
@@ -3904,15 +3904,6 @@
"dev": true, "dev": true,
"license": "BSD-2-Clause" "license": "BSD-2-Clause"
}, },
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
},
"node_modules/data-urls": { "node_modules/data-urls": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz",
@@ -5108,29 +5099,6 @@
"bser": "2.1.1" "bser": "2.1.1"
} }
}, },
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/fflate": { "node_modules/fflate": {
"version": "0.7.4", "version": "0.7.4",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.4.tgz", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.4.tgz",
@@ -5315,18 +5283,6 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"license": "MIT",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/fs.realpath": { "node_modules/fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -8061,41 +8017,46 @@
"node": ">= 8.0.0" "node": ">= 8.0.0"
} }
}, },
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": { "node_modules/node-fetch": {
"version": "3.3.2", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"data-uri-to-buffer": "^4.0.0", "whatwg-url": "^5.0.0"
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
}, },
"engines": { "engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" "node": "4.x || >=6.0.0"
}, },
"funding": { "peerDependencies": {
"type": "opencollective", "encoding": "^0.1.0"
"url": "https://opencollective.com/node-fetch" },
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-fetch/node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/node-fetch/node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/node-fetch/node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
} }
}, },
"node_modules/node-int64": { "node_modules/node-int64": {
@@ -10701,15 +10662,6 @@
"makeerror": "1.0.12" "makeerror": "1.0.12"
} }
}, },
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
"license": "MIT",
"engines": {
"node": ">= 8"
}
},
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",

View File

@@ -19,7 +19,7 @@
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"next": "15.1.7", "next": "15.1.7",
"node-cache": "^5.1.2", "node-cache": "^5.1.2",
"node-fetch": "^3.3.2", "node-fetch": "^2.7.0",
"nodemailer": "^6.10.0", "nodemailer": "^6.10.0",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",