
* Add vital integration * Tidy up client_user_id creation * Rename vital app to vitalother to follow name rules * Added env var * App vital reschedule * Fix on app structure and api calls * Implemented user identification from webhook * WIP fix api call and read me * Save vital settings via api * Now saving userVitalSettings and trigger reschedule on selected param * Added translations * Fix type for vitalSettings * Using api to get env vars required for url, fix display of vital settings * Fix hours placeholder, translation not working * Renames vital app * Update seed-app-store.ts * Update package.json * Update yarn.lock * Refactored env variables * Update README.md * Migrates to api_keys * Extracts AppConfiguration * vitalClient fixes * Update index.ts * Update metadata.ts * Update index.ts * Update metadata.ts * Added namespace vital for translations Co-authored-by: Maitham <maithamdib@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
29 lines
788 B
TypeScript
29 lines
788 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
import { JSONObject } from "superjson/dist/types";
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
if (req.method === "GET" && req.session && req.session.user.id) {
|
|
const userId = req.session.user.id;
|
|
try {
|
|
const user = await prisma?.user.findFirst({
|
|
select: {
|
|
metadata: true,
|
|
},
|
|
where: {
|
|
id: userId,
|
|
},
|
|
});
|
|
|
|
if (user && user.metadata && (user.metadata as JSONObject)?.vitalSettings) {
|
|
res.status(200).json((user.metadata as JSONObject).vitalSettings);
|
|
} else {
|
|
res.status(404);
|
|
}
|
|
} catch (error) {
|
|
res.status(500);
|
|
}
|
|
} else {
|
|
res.status(400);
|
|
}
|
|
res.end();
|
|
}
|