neutral-old/app.js

81 lines
2.0 KiB
JavaScript
Raw Normal View History

2023-02-02 13:36:36 +00:00
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
2023-02-21 11:02:37 +00:00
var favicon = require('serve-favicon');
2023-02-02 13:36:36 +00:00
var logger = require('morgan');
2023-02-18 21:09:04 +00:00
var fs = require("fs")
var uuid = require('uuid');
var CryptoJS = require("crypto-js")
2023-02-21 11:02:37 +00:00
var fileUpload = require('express-fileupload')
2023-02-23 13:47:21 +00:00
var ntr = require("./neutral-functions.js")
2023-02-18 21:09:04 +00:00
2023-02-02 13:36:36 +00:00
var indexRouter = require('./routes/index');
2023-02-18 21:09:04 +00:00
var loginRouter = require('./routes/login');
var signoutRouter = require('./routes/signout');
2023-02-21 11:02:37 +00:00
var getRouter = require('./routes/get');
var setRouter = require('./routes/set');
var uploadRouter = require('./routes/upload');
2023-02-22 12:57:27 +00:00
var userManagerRouter = require('./routes/usermanager');
2023-02-23 13:47:21 +00:00
var linkRouter = require('./routes/link');
2023-02-27 16:23:25 +00:00
var fileRouter = require("./routes/filemanager")
2023-02-18 21:09:04 +00:00
2023-02-02 13:36:36 +00:00
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
2023-02-18 21:09:04 +00:00
app.use(favicon(path.join(__dirname + '/public/' + 'favicon.ico')))
2023-02-21 11:02:37 +00:00
app.use(fileUpload({
debug: true,
}));
2023-02-02 13:36:36 +00:00
app.use('/', indexRouter);
2023-02-18 21:09:04 +00:00
app.use('/login', loginRouter);
app.use('/signout', signoutRouter);
2023-02-21 11:02:37 +00:00
app.use('/get', getRouter);
app.use('/set', setRouter)
app.use('/upload', uploadRouter)
2023-02-22 12:57:27 +00:00
app.use('/usermanager', userManagerRouter)
2023-02-23 13:47:21 +00:00
app.use('/link', linkRouter)
2023-02-27 16:23:25 +00:00
app.use("/filemanager", fileRouter)
2023-02-18 21:09:04 +00:00
2023-02-02 13:36:36 +00:00
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
2023-02-18 21:09:04 +00:00
2023-02-23 13:47:21 +00:00
ntr.checkUser()
2023-02-18 21:09:04 +00:00
2023-03-19 16:45:55 +00:00
if ("ENV" in process.env) {
if(process.env.ENV == "TEST") {
2023-03-19 16:46:34 +00:00
process.exit(0)
2023-03-19 16:45:55 +00:00
}
}
2023-02-18 21:09:04 +00:00
2023-02-02 13:36:36 +00:00
module.exports = app;