From 2337a4b7fbd82092e019eed20a965b442ffa5aa5 Mon Sep 17 00:00:00 2001 From: itschip Date: Thu, 19 Dec 2024 19:45:51 +0100 Subject: [PATCH] chore: remove api app --- apps/api/package.json | 26 -------------------- apps/api/src/contacts/contact-service.ts | 30 ------------------------ apps/api/src/database/data-source.ts | 1 - apps/api/src/index.ts | 26 -------------------- apps/api/tsconfig.json | 21 ----------------- 5 files changed, 104 deletions(-) delete mode 100644 apps/api/package.json delete mode 100644 apps/api/src/contacts/contact-service.ts delete mode 100644 apps/api/src/database/data-source.ts delete mode 100644 apps/api/src/index.ts delete mode 100644 apps/api/tsconfig.json diff --git a/apps/api/package.json b/apps/api/package.json deleted file mode 100644 index 3ef6b9448..000000000 --- a/apps/api/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@npwd/api", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "scripts": { - "dev1": "cross-env IS_BROWSER_DEV=1 nodemon src/index.ts" - }, - "devDependencies": { - "@types/body-parser": "^1.19.2", - "@types/cors": "^2.8.13", - "@types/express": "^4.17.17", - "@types/node": "^18.13.0", - "cross-env": "^7.0.3", - "nodemon": "^2.0.20", - "ts-node": "^10.9.1", - "typescript": "^4.9.5" - }, - "dependencies": { - "@npwd/database": "workspace:^1.0.0", - "body-parser": "^1.20.1", - "cors": "^2.8.5", - "express": "^4.18.2", - "mysql2": "^3.1.2" - } -} diff --git a/apps/api/src/contacts/contact-service.ts b/apps/api/src/contacts/contact-service.ts deleted file mode 100644 index bb87bfc90..000000000 --- a/apps/api/src/contacts/contact-service.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ContactsDB, _ContactsDB } from '@npwd/database'; -import { Contact } from '@typings/contact'; -import { PLAYER_IDENITIFER } from '../database/data-source'; - -export class ContactService { - private readonly _contactDB: _ContactsDB; - - constructor() { - this._contactDB = ContactsDB; - } - - async getContacts(): Promise { - const contacts = await this._contactDB.fetchAllContacts(PLAYER_IDENITIFER); - if (!contacts || contacts.length == 0) return null; - - return contacts; - } - - async addContact(contact: Contact): Promise { - console.log('CONTACT', contact); - - try { - const newContact = await this._contactDB.addContact(PLAYER_IDENITIFER, contact); - return newContact; - } catch (e) { - console.error(e); - return null; - } - } -} diff --git a/apps/api/src/database/data-source.ts b/apps/api/src/database/data-source.ts deleted file mode 100644 index 9adfcdafd..000000000 --- a/apps/api/src/database/data-source.ts +++ /dev/null @@ -1 +0,0 @@ -export const PLAYER_IDENITIFER = '1234'; diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts deleted file mode 100644 index fb3468933..000000000 --- a/apps/api/src/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import './database/data-source'; -import express from 'express'; -import { ContactService } from './contacts/contact-service'; -import cors from 'cors'; -import bodyParser from 'body-parser'; - -const app = express(); - -app.use(cors()); -app.use(bodyParser.json()); - -const contactService = new ContactService(); - -app.post('/npwd-contact-getAll', async (req, res) => { - const contacts = await contactService.getContacts(); - res.send({ status: 'ok', data: contacts }); -}); - -app.post('/npwd-contact-add', async (req, res) => { - const contact = req.body; - const newContact = await contactService.addContact(contact); - - res.json({ status: 'ok', data: newContact }); -}); - -app.listen(6001, () => console.log('Server is running')); diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json deleted file mode 100644 index 47b82277e..000000000 --- a/apps/api/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "paths": { - "@typings/*": ["../../typings/*"], - "@game/*": ["../../apps/game/*"] - }, - "outDir": "./", - "noImplicitAny": true, - "module": "commonjs", - "target": "ES2020", - "allowJs": false, - "lib": ["es2020"], - "types": ["@types/node"], - "moduleResolution": "node", - "sourceMap": true, - "resolveJsonModule": true, - "esModuleInterop": true - }, - "include": ["./**/*"], - "exclude": ["**/node_modules"] -}