Initial Commit

This commit is contained in:
Constantin Simonis
2025-06-10 08:39:11 +02:00
commit b8fd37f3e0
48 changed files with 30268 additions and 0 deletions

29
backend/api/server.ts Normal file
View File

@ -0,0 +1,29 @@
import * as bodyParser from 'body-parser';
import * as express from 'express';
import * as cors from 'cors';
import 'reflect-metadata';
import { Connection, createConnection } from 'typeorm';
import router from './router';
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use((_req: express.Request, res: express.Response, next: express.NextFunction) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
next();
});
app.use('/api', router);
app.set('port', 2000);
createConnection().then(async (connection: Connection) => {
app.listen(app.get('port'), () => {
console.log(`Node API is running at http://localhost:${app.get('port')} in ${app.get('env')} mode`);
console.log(`Connected to your ${connection.options.type} database`);
console.log('Press CTRL-C to stop\n');
});
}).catch((error) => console.error(`TypeORM connection ${error}`));
export default app;