feat: initial setup backend with default routes and db connection

This commit is contained in:
2024-12-30 01:36:41 +01:00
parent 478a53a0fb
commit 26e6cd0b7e
28 changed files with 3062 additions and 1 deletions

View File

@ -0,0 +1,34 @@
import { injectable } from "tsyringe";
import { Location } from "../models/location";
@injectable()
export class LocationRepository {
public async findAll() {
return await Location.findAll();
}
public async findById(id: string) {
return await Location.findByPk(id);
}
public async create(data: Partial<Location>) {
return await Location.create(data);
}
public async update(id: string, data: Partial<Location>) {
const location = await this.findById(id);
if (location) {
return await location.update(data);
}
return null;
}
public async delete(id: string) {
const location = await this.findById(id);
if (location) {
await location.destroy();
return true;
}
return false;
}
}

View File

@ -0,0 +1,34 @@
import { injectable } from "tsyringe";
import { LpTtnEndDeviceUplinks } from "../models/lpTtnEndDeviceUplinks";
@injectable()
export class LpTtnEndDeviceUplinksRepository {
public async findAll() {
return await LpTtnEndDeviceUplinks.findAll();
}
public async findById(id: string) {
return await LpTtnEndDeviceUplinks.findByPk(id);
}
public async create(data: Partial<LpTtnEndDeviceUplinks>) {
return await LpTtnEndDeviceUplinks.create(data);
}
public async update(id: string, data: Partial<LpTtnEndDeviceUplinks>) {
const uplink = await this.findById(id);
if (uplink) {
return await uplink.update(data);
}
return null;
}
public async delete(id: string) {
const uplink = await this.findById(id);
if (uplink) {
await uplink.destroy();
return true;
}
return false;
}
}

View File

@ -0,0 +1,34 @@
import { injectable } from "tsyringe";
import { TtnGatewayReception } from "../models/ttnGatewayReception";
@injectable()
export class TtnGatewayReceptionRepository {
public async findAll() {
return await TtnGatewayReception.findAll();
}
public async findById(id: string) {
return await TtnGatewayReception.findByPk(id);
}
public async create(data: Partial<TtnGatewayReception>) {
return await TtnGatewayReception.create(data);
}
public async update(id: string, data: Partial<TtnGatewayReception>) {
const gatewayReception = await this.findById(id);
if (gatewayReception) {
return await gatewayReception.update(data);
}
return null;
}
public async delete(id: string) {
const gatewayReception = await this.findById(id);
if (gatewayReception) {
await gatewayReception.destroy();
return true;
}
return false;
}
}

View File

@ -0,0 +1,34 @@
import { injectable } from "tsyringe";
import { WifiScan } from "../models/wifiScan";
@injectable()
export class WifiScanRepository {
public async findAll() {
return await WifiScan.findAll();
}
public async findById(id: string) {
return await WifiScan.findByPk(id);
}
public async create(data: Partial<WifiScan>) {
return await WifiScan.create(data);
}
public async update(id: string, data: Partial<WifiScan>) {
const wifiScan = await this.findById(id);
if (wifiScan) {
return await wifiScan.update(data);
}
return null;
}
public async delete(id: string) {
const wifiScan = await this.findById(id);
if (wifiScan) {
await wifiScan.destroy();
return true;
}
return false;
}
}