-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
1 lines (1 loc) · 1.94 KB
/
app.js
1
"use strict";var env=process.env.NODE_ENV||"production",fss=require("fs"),express=require("express"),favicon=require("serve-favicon"),fpath=require("path"),httpsecurity=require("https"),socket_io=require("socket.io"),cookieParser=require("cookie-parser"),bodyParser=require("body-parser"),passport=require("passport"),session=require("express-session"),sessionOptions={secret:"keyboard cat cat",resave:!0,saveUninitialized:!0,cookie:{secure:!0,httpOnly:!0}},key=fss.readFileSync("hacksparrow-key.pem"),cert=fss.readFileSync("hacksparrow-cert.pem"),options={key:key,cert:cert},passport=require("passport"),mongo=require("mongojs"),db=mongo("mongodb://antoniadis:[email protected]:61069/car_brand",["users"]),app=express(),index=require("./routes"),authen=require("./routes/auth"),tasks=require("./routes/tasks");app.use(favicon(__dirname+"/public/favicon.ico")),app.set("views",express.static(fpath.join(__dirname+"/public/views"))),app.set("view engine","ejs"),app.engine("html",require("ejs").renderFile),app.use(express.static(fpath.join(__dirname+"/public"))),app.use(cookieParser()),app.use(bodyParser.json({limit:"2mb"})),app.use(bodyParser.urlencoded({limit:"2mb",extended:!1}));var cookieSession=require("cookie-session");app.use(cookieSession({keys:["keyboard cat cat1","keyboard cat cat2"]})),app.use(session(sessionOptions)),app.use(passport.initialize()),app.use(passport.session()),app.use("/",index),app.use("/auth",authen),app.use("/api",tasks),app.all("*",function(req,res,next){res.sendFile(fpath.join(__dirname+"/public/index.html"))}),"development"===app.get("env")&&app.use(function(err,req,res,next){res.status(err.status||500),res.render("error",{message:err.message,error:err})}),app.use(function(err,req,res,next){res.status(err.status||500),res.render("error",{message:err.message,error:{}})});var attach=function(server){var appio=socket_io.listen(server);require("./ServerJavascript/socket.io")("").attach(appio)};app.io={attach:attach},module.exports=app;