11import express from "express" ;
22import cookieParser from "cookie-parser" ;
3- import fs from "fs" ;
3+ import { readFileSync } from "fs" ;
44
55const app = express ( ) ;
66app . use ( express . urlencoded ( { extended : true } ) ) ;
@@ -10,14 +10,14 @@ import { PrismaClient } from "@prisma/client";
1010const client = new PrismaClient ( ) ;
1111
1212app . get ( "/" , ( request , response ) => {
13- const index = fs . readFileSync ( "index.html" , "utf-8" ) ;
13+ const index = readFileSync ( "index.html" , "utf-8" ) ;
1414 const html = index . replace ( "{warning}" , "" ) ;
1515 response . send ( html ) ;
1616} ) ;
1717
1818app . post ( "/login" , async ( request , response ) => {
19- const login = fs . readFileSync ( "login.html" , "utf-8" ) ;
20- const index = fs . readFileSync ( "index.html" , "utf-8" ) ;
19+ const login = readFileSync ( "login.html" , "utf-8" ) ;
20+ const index = readFileSync ( "index.html" , "utf-8" ) ;
2121 const user = await client . User . findUnique ( {
2222 where : {
2323 username : request . body . username ,
@@ -48,7 +48,7 @@ app.post("/login", async (request, response) => {
4848} ) ;
4949
5050app . get ( "/profile" , async ( request , response ) => {
51- const profile = fs . readFileSync ( "profile.html" , "utf-8" ) ;
51+ const profile = readFileSync ( "profile.html" , "utf-8" ) ;
5252 const prof = await client . Profile . findUnique ( {
5353 where : { id : request . cookies . session } ,
5454 } ) ;
@@ -60,14 +60,14 @@ app.get("/profile", async (request, response) => {
6060} ) ;
6161
6262app . get ( "/register" , ( request , response ) => {
63- const register = fs . readFileSync ( "register.html" , "utf-8" ) ;
63+ const register = readFileSync ( "register.html" , "utf-8" ) ;
6464 const html = register . replace ( "{warning}" , "" ) ;
6565 response . send ( html ) ;
6666} ) ;
6767
6868app . post ( "/registered" , async ( request , response ) => {
69- const index = fs . readFileSync ( "index.html" , "utf-8" ) ;
70- const register = fs . readFileSync ( "register.html" , "utf-8" ) ;
69+ const index = readFileSync ( "index.html" , "utf-8" ) ;
70+ const register = readFileSync ( "register.html" , "utf-8" ) ;
7171 const user = await client . User . findUnique ( {
7272 where : {
7373 username : request . body . username ,
0 commit comments