New login screen

- Basic user page
This commit is contained in:
2020-10-24 01:09:17 +02:00
parent edaff8a3ec
commit 8a4b0b1e13
24 changed files with 358 additions and 34 deletions

View File

@@ -1,13 +1,16 @@
import { Response } from "express";
import { logger } from "../app";
import { LivebeatRequest } from "../lib/request";
import { Beat } from "../models/beat/beat.model.";
import { Phone } from "../models/phone/phone.model";
export async function GetPhone(req: LivebeatRequest, res: Response) {
const phoneId: String = req.params['id'];
// If none id provided, return all.
if (phoneId === undefined) {
res.status(400).send();
const phone = await Phone.find({ user: req.user?._id });
res.status(200).send(phone);
return;
}
@@ -18,7 +21,10 @@ export async function GetPhone(req: LivebeatRequest, res: Response) {
return;
}
res.status(200).send(phone);
// Get last beat
const lastBeat = await Beat.findOne({ phone: phone?._id }).sort({ createdAt: -1 });
res.status(200).send({ phone, lastBeat });
}
export async function PostPhone(req: LivebeatRequest, res: Response) {