Mokshith commited on
Commit
aca44b5
·
1 Parent(s): 27647a0
Files changed (2) hide show
  1. src/api-app.js +7 -3
  2. src/server.js +1 -7
src/api-app.js CHANGED
@@ -1,6 +1,7 @@
1
  const express = require('express');
2
  const apiRouter = require('../routers/resume');
3
-
 
4
  const cors = require('cors');
5
  const app = express();
6
 
@@ -9,7 +10,10 @@ app.use(cors()); // Enable CORS for cross-origin requests
9
 
10
  app.use(express.json()); // Middleware to parse JSON requests
11
  app.use(express.urlencoded({ extended: true })); // Middleware to parse URL-encoded requests
12
-
 
 
 
13
  app.use(apiRouter); // Use the API router for handling resume routes
14
-
15
  module.exports = app;
 
1
  const express = require('express');
2
  const apiRouter = require('../routers/resume');
3
+ const viewRouter = require('../routers/views');
4
+ const path = require('path');
5
  const cors = require('cors');
6
  const app = express();
7
 
 
10
 
11
  app.use(express.json()); // Middleware to parse JSON requests
12
  app.use(express.urlencoded({ extended: true })); // Middleware to parse URL-encoded requests
13
+ // Middleware
14
+ app.set('view engine', 'ejs'); // Set the view engine to EJS
15
+ app.set('views', path.join('views')); // Set the directory for views
16
+ app.use(express.static('public')); // Middleware to serve static files from the 'public' directory
17
  app.use(apiRouter); // Use the API router for handling resume routes
18
+ app.use('/', viewRouter);
19
  module.exports = app;
src/server.js CHANGED
@@ -1,14 +1,8 @@
1
- const viewApp = require('./view-app');
2
  const apiApp = require('./api-app');
3
 
4
- const viewPort = 7860||process.env.VIEW_PORT; // Port for the view app
5
  const apiPort = 7860||process.env.API_PORT; // Port for the API app
6
 
7
- // Start the view app server
8
- viewApp.listen(viewPort, () => {
9
- console.log(`View app is running on port ${viewPort}`);
10
- });
11
-
12
  // Start the API app server
13
  apiApp.listen(apiPort, () => {
14
  console.log(`API app is running on port ${apiPort}`);
 
1
+
2
  const apiApp = require('./api-app');
3
 
 
4
  const apiPort = 7860||process.env.API_PORT; // Port for the API app
5
 
 
 
 
 
 
6
  // Start the API app server
7
  apiApp.listen(apiPort, () => {
8
  console.log(`API app is running on port ${apiPort}`);