29. Juni 2024, 13:18
This commit is contained in:
1464
backend/package-lock.json
generated
Normal file
1464
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
backend/package.json
Normal file
13
backend/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@types/dotenv": "^8.2.0",
|
||||
"@types/express": "^4.17.21",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
}
|
||||
16
backend/src/config.ts
Normal file
16
backend/src/config.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// config.js
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
const localDirectoryPath = path.resolve(__dirname, 'local');
|
||||
if (!fs.existsSync(localDirectoryPath)) {
|
||||
fs.mkdirSync(localDirectoryPath, { recursive: true });
|
||||
console.log('Local directory created.');
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
localDirectoryPath,
|
||||
};
|
||||
}
|
||||
23
backend/src/index.ts
Normal file
23
backend/src/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import config from './config';
|
||||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
const app = express();
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV || 'dev';
|
||||
const Port = NODE_ENV === "production" ? parseInt(process.env.PORT || '') || 8800 : 8800;
|
||||
|
||||
// Middleware für JSON-Parsing
|
||||
app.use(express.json());
|
||||
|
||||
// API-Endpunkte
|
||||
app.get('/api/hello', (req, res) => {
|
||||
res.json({ message: 'Hello from the backend!' });
|
||||
});
|
||||
|
||||
// Weitere API-Endpunkte können hier hinzugefügt werden
|
||||
|
||||
app.listen(Port, () => {
|
||||
console.log(`Server läuft auf Port ${Port}`);
|
||||
});
|
||||
14
backend/tsconfig.json
Normal file
14
backend/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Reference in New Issue
Block a user