-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (46 loc) · 1.73 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// const fs = require('fs');
// const path = require('path');
const config = require('config');
const express = require('express');
const home = require('./routes/home');
const products = require('./routes/products');
const categories = require('./routes/categories');
const reviews = require('./routes/reviews');
const features = require('./routes/features');
const users = require('./routes/users');
const auth = require('./routes/auth');
const helmet = require('helmet');
const morgan = require('morgan');
if(!config.get('cctvKey')){console.log(config.util.getEnv()); process.exit(1)}
const app = express();
app.use(express.json());
app.use(express.static(`${__dirname}/public/views`));
app.use('/js', express.static(__dirname + '/public/js'));
app.use('/css', express.static(__dirname + '/public/css'));
app.use('/images', express.static(__dirname + '/public/images'));
app.use(helmet());
app.use(morgan('dev'));
// // create a write stream (in append mode)
// var accessLogStream = fs.createWriteStream(path.join(__dirname, '\\logs\\access.log'), { flags: 'a' })
// // setup the logger
// app.use(morgan('combined', { stream: accessLogStream }))
//app.use('/',home);
app.get('/login',(req,res)=>{
res.sendFile(`${__dirname}/public/views/login.html`)}
);
app.get('/about',(req,res)=>{
res.sendFile(`${__dirname}/public/views/about.html`)}
);
app.get('/products',(req,res)=>{
res.sendFile(`${__dirname}/public/views/products.html`)}
);
app.use('/api/products',products);
app.use('/api/categories',categories);
app.use('/api/reviews',reviews);
app.use('/api/features',features);
app.use('/api/users',users);
app.use('/api/auth',auth);
app.listen(3000,() => {
// console.log(__dirname+'\\logs\\access.log');
console.log('listening to 3000');
})