File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 11import express from "express" ;
2+ import path , { dirname } from "path" ;
23import morgan from "morgan" ;
34import cookieParser from "cookie-parser" ;
45import cors from "cors" ;
6+ import { fileURLToPath } from "url" ;
57import { logger } from "#util" ;
68import indexRouter from "#routes/index" ;
79import usersRouter from "#routes/users" ;
810import authRouter from "#routes/auth" ;
911
1012const app = express ( ) ;
13+ const currDirName = dirname ( fileURLToPath ( import . meta. url ) ) ;
1114
1215app . use ( morgan (
1316 ":remote-addr - :remote-user \":method :url HTTP/:http-version\" :status \":referrer\" \":user-agent\"" ,
@@ -18,9 +21,9 @@ app.use(cors());
1821app . use ( express . json ( ) ) ;
1922app . use ( express . urlencoded ( { extended : false } ) ) ;
2023app . use ( cookieParser ( ) ) ;
24+ app . use ( express . static ( path . join ( currDirName , "public" ) ) ) ;
2125
2226app . use ( "/" , indexRouter ) ;
23-
2427app . use ( "/users" , usersRouter ) ;
2528app . use ( "/auth" , authRouter ) ;
2629
Original file line number Diff line number Diff line change 11function home ( req , res ) {
2- res . render ( "index" , { title : "Express " } ) ;
2+ res . json ( { res : "Server Working " } ) ;
33}
44
55export default { home } ;
You can’t perform that action at this time.
0 commit comments