reformat with prettier
This commit is contained in:
parent
b14a49803e
commit
655085cb6d
3 changed files with 16 additions and 18 deletions
|
@ -35,7 +35,6 @@ export default function Layout({ children }: Props) {
|
||||||
[license]
|
[license]
|
||||||
</a>
|
</a>
|
||||||
·
|
·
|
||||||
|
|
||||||
{/* eslint-disable @next/next/no-img-element */}
|
{/* eslint-disable @next/next/no-img-element */}
|
||||||
<a href="https://github.com/iptq/wisesplit/stargazers">
|
<a href="https://github.com/iptq/wisesplit/stargazers">
|
||||||
<img
|
<img
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { Db, MongoClient } from 'mongodb';
|
import { Db, MongoClient } from "mongodb";
|
||||||
|
|
||||||
const USERNAME = process.env.MONGO_USERNAME
|
const USERNAME = process.env.MONGO_USERNAME;
|
||||||
const PASSWORD = process.env.MONGO_PASSWORD
|
const PASSWORD = process.env.MONGO_PASSWORD;
|
||||||
const HOSTNAME = process.env.MONGO_HOSTNAME
|
const HOSTNAME = process.env.MONGO_HOSTNAME;
|
||||||
const DATABASE_NAME = process.env.MONGO_DATABASE_NAME
|
const DATABASE_NAME = process.env.MONGO_DATABASE_NAME;
|
||||||
const DATABASE_PORT = process.env.MONGO_DATABASE_PORT
|
const DATABASE_PORT = process.env.MONGO_DATABASE_PORT;
|
||||||
|
|
||||||
const URI =
|
|
||||||
`mongodb://${USERNAME}:${PASSWORD}@${HOSTNAME ?? 'localhost'}:${DATABASE_PORT}`;
|
|
||||||
|
|
||||||
|
const URI = `mongodb://${USERNAME}:${PASSWORD}@${
|
||||||
|
HOSTNAME ?? "localhost"
|
||||||
|
}:${DATABASE_PORT}`;
|
||||||
|
|
||||||
let db: Db | null = null;
|
let db: Db | null = null;
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ export const getMongoDBClient = async () => {
|
||||||
|
|
||||||
await client.connect();
|
await client.connect();
|
||||||
db = client.db(DATABASE_NAME);
|
db = client.db(DATABASE_NAME);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
};
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
import { getMongoDBClient } from '../../lib/getMongoDBClient';
|
import { getMongoDBClient } from "../../lib/getMongoDBClient";
|
||||||
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
res: NextApiResponse<Record<string, string>[] | Record<string, string>>
|
res: NextApiResponse<Record<string, string>[] | Record<string, string>>
|
||||||
) {
|
) {
|
||||||
if (req.method !== 'POST') {
|
if (req.method !== "POST") {
|
||||||
return res.status(405).json({message: 'Only POST method allowed'});
|
return res.status(405).json({ message: "Only POST method allowed" });
|
||||||
}
|
}
|
||||||
const receipt = req.body;
|
const receipt = req.body;
|
||||||
const client = await getMongoDBClient();
|
const client = await getMongoDBClient();
|
||||||
|
@ -16,6 +15,6 @@ export default async function handler(
|
||||||
// TODO implement this
|
// TODO implement this
|
||||||
res.status(200).json(receipt);
|
res.status(200).json(receipt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.status(500).json({message: (e as Error).message});
|
res.status(500).json({ message: (e as Error).message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue