forked from coding-boot-camp/miniature-eureka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (24 loc) · 782 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const express = require("express");
//routes to html file and api file
//making a change
const apiRoutes = require("./routes/apiRoutes");
const htmlRoutes = require("./routes/htmlRoutes");
//launch localhost webpage via express
const app = express();
const PORT = process.env.PORT || 3001;
//are these required for my usecase?
// const path = require('path');
// const fs = require('fs');
//use npm start
//to start the express server
//parse incoming JSON data
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(express.static("public"));
//app usage of links to routes
app.use("/api", apiRoutes);
app.use("/", htmlRoutes);
//app telling users the server is running
app.listen(PORT, () => {
console.log(`API server now on port ${PORT}`);
})