title: auto

des: auto
note:auto
This commit is contained in:
2023-10-03 09:32:00 +08:00
parent 6ac6720c66
commit bde21823de
10 changed files with 37 additions and 9 deletions

2
.env
View File

@@ -5,4 +5,4 @@
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="postgresql://bip:Production_123@localhost:5433/hipmi?schema=public" DATABASE_URL="postgresql://bip:Production_123@localhost:5433/hipmi?schema=public"
PWD="QWERTYUIOPLKJHGFDSAZXCVBNMQAZWSXEDCRFVTGBYHNUJMIKOLPPOIUYTREWQLKJHGFDSAMNBVCXZ" PWD="QWERTYUIOPLKJHGFDSAZXCVBNMQAZWSXEDCRFVTGBYHNUJMIKOLPPOIUYTREWQLKJHGFDSAMNBVCXZlghvftyguhijknhbgvcfytguu8okjnhbgvfty7u8oilkjnhgvtygu7u8ojilnkhbgvhujnkhghvjhukjnhb"

3
.gitignore vendored
View File

@@ -21,7 +21,8 @@
# debug # debug
npm-debug.log* npm-debug.log*
yarn-debug.log*
rn-debug.log*
yarn-error.log* yarn-error.log*
# local env files # local env files

2
config.yaml Normal file
View File

@@ -0,0 +1,2 @@
server:
password: QWERTYUIOPLKJHGFDSAZXCVBNMQAZWSXEDCRFVTGBYHNUJMIKOLPPOIUYTREWQLKJHGFDSAMNBVCXZlghvftyguhijknhbgvcfytguu8okjnhbgvfty7u8oilkjnhgvtygu7u8ojilnkhbgvhujnkhghvjhukjnhb

View File

@@ -1,4 +1,8 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = {} const nextConfig = {
experimental: {
serverActions: true
}
}
module.exports = nextConfig module.exports = nextConfig

View File

@@ -32,6 +32,7 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-simple-toasts": "^5.10.0", "react-simple-toasts": "^5.10.0",
"tailwindcss": "3.3.3", "tailwindcss": "3.3.3",
"typescript": "5.1.6" "typescript": "5.1.6",
"yaml": "^2.3.2"
} }
} }

View File

@@ -4,8 +4,10 @@ import prisma from "@/app/lib/prisma";
import { data } from "autoprefixer"; import { data } from "autoprefixer";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { getConfig } from "@/bin/config";
export async function POST(req: Request) { export async function POST(req: Request) {
if (req.method === "POST") { if (req.method === "POST") {
const body = await req.json(); const body = await req.json();
// MyConsole(body); // MyConsole(body);
@@ -35,7 +37,7 @@ export async function POST(req: Request) {
username: data.username, username: data.username,
}), }),
{ {
password: process.env.PWD as string, password: (await getConfig()).server.password,
} }
); );
@@ -45,8 +47,7 @@ export async function POST(req: Request) {
maxAge: 60 * 60 * 24 * 7, maxAge: 60 * 60 * 24 * 7,
}); });
return NextResponse.json({ status: 201 });
return NextResponse.json({ status: 201});
} }
return NextResponse.json({ success: true }); return NextResponse.json({ success: true });

View File

@@ -3,6 +3,7 @@ import prisma from "@/app/lib/prisma";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { sealData, unsealData } from "iron-session"; import { sealData, unsealData } from "iron-session";
import {getConfig} from "@/bin/config";
export async function POST(req: Request) { export async function POST(req: Request) {
if (req.method === "POST") { if (req.method === "POST") {
@@ -30,7 +31,7 @@ export async function POST(req: Request) {
username: data.username, username: data.username,
}), }),
{ {
password: process.env.PWD as string, password: (await getConfig()).server.password,
} }
); );

View File

@@ -1,5 +1,7 @@
import { Validasi } from "@/app_modules/auth"; import { Validasi } from "@/app_modules/auth";
export default function Page() { export default function Page() {
return <Validasi />;
return <Validasi />;
} }

11
src/bin/config/index.ts Normal file
View File

@@ -0,0 +1,11 @@
"use server";
import yaml from "yaml";
import fs from "fs";
import path from "path";
const config: { server: { password: string } } = yaml.parse(
fs.readFileSync(path.join(__dirname, "./../../../config.yaml")).toString()
);
export async function getConfig() {
return config;
}

View File

@@ -3608,6 +3608,11 @@ yaml@^2.1.1:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b" resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b"
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ== integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
yaml@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.2.tgz#f522db4313c671a0ca963a75670f1c12ea909144"
integrity sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==
yocto-queue@^0.1.0: yocto-queue@^0.1.0:
version "0.1.0" version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"