-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (29 loc) · 1.13 KB
/
server.js
File metadata and controls
40 lines (29 loc) · 1.13 KB
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
32
33
34
35
36
37
38
39
40
import apiRouter from './api';
import config, { nodeEnv, jtLog } from './config';
import express from 'express';
import sassMiddleware from 'node-sass-middleware';
import path from 'path';
//Going to create a server with express.
const server = express();
server.set('view engine', 'ejs'); //Pure Magic. Allows for ejs independent responsibility.
server.use(sassMiddleware({
src: path.join(__dirname, 'sass'),
dest: path.join(__dirname, 'public')
}));
//Express get requests
//This is the default. if something crashes with webpack.
server.get('/', (req, res) => {
res.render('index', {
content: "James Tam's Resume Stack initial development!"
}); //Make sure you pass the name of the template. (ejs)
});
// this puts the middleware into express stack.
server.use('/api', apiRouter); // use anything the apiRouter chooses. Real magical bullshit.
//Please put all assets in the public folder.
server.use(express.static('public'));
//Express listening on configuration ports.
server.listen(config.port, () => {
console.info('Express is listening on:', config.port);
});
console.log(config, nodeEnv);
jtLog('Function');