mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
79
node_modules/mongo-express/app.js
generated
vendored
Normal file → Executable file
79
node_modules/mongo-express/app.js
generated
vendored
Normal file → Executable file
@@ -1,15 +1,82 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var express = require('express');
|
||||
var config = require('./config');
|
||||
var fs = require('fs');
|
||||
var https = require('https');
|
||||
var middleware = require('./middleware');
|
||||
var commander = require('commander');
|
||||
var clc = require('cli-color');
|
||||
var app = express();
|
||||
var defaultPort = 80;
|
||||
var server = app;
|
||||
var config;
|
||||
var sslOptions;
|
||||
|
||||
var app = express();
|
||||
try {
|
||||
config = require('./config');
|
||||
} catch (e) {
|
||||
config = require('./config.default');
|
||||
}
|
||||
|
||||
app.use('/', middleware(config));
|
||||
commander
|
||||
.version(require('./package').version)
|
||||
.option('-u, --username <username>', 'username for authentication')
|
||||
.option('-p, --password <password>', 'password for authentication')
|
||||
.option('-a, --admin', 'enable authentication as admin')
|
||||
.option('-d, --database <database>', 'authenticate to database')
|
||||
.option('--port <port>', 'listen on specified port')
|
||||
.parse(process.argv);
|
||||
|
||||
if (commander.username && commander.password) {
|
||||
config.mongodb.admin = !!commander.admin;
|
||||
if (commander.admin) {
|
||||
config.mongodb.adminUsername = commander.username;
|
||||
config.mongodb.adminPassword = commander.password;
|
||||
} else {
|
||||
var user = {
|
||||
database: commander.database,
|
||||
username: commander.username,
|
||||
password: commander.password,
|
||||
};
|
||||
for (var key in user) {
|
||||
if (!user[key]) {
|
||||
commander.help();
|
||||
}
|
||||
}
|
||||
|
||||
config.mongodb.auth[0] = user;
|
||||
}
|
||||
|
||||
config.useBasicAuth = false;
|
||||
}
|
||||
|
||||
config.site.port = commander.port || config.site.port;
|
||||
|
||||
if (!config.site.baseUrl) {
|
||||
console.error('Please specify a baseUrl in your config. Using "/" for now.');
|
||||
config.site.baseUrl = '/';
|
||||
}
|
||||
|
||||
if (config.basicAuth.username === 'admin' && config.basicAuth.password === 'pass') {
|
||||
console.error(clc.red.underline('basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!'));
|
||||
}
|
||||
|
||||
app.use(config.site.baseUrl, middleware(config));
|
||||
app.set('read_only', config.options.readOnly || false);
|
||||
app.listen(config.site.port, config.site.host, function() {
|
||||
|
||||
if (config.site.sslEnabled) {
|
||||
defaultPort = 443;
|
||||
sslOptions = {
|
||||
key: fs.readFileSync(config.site.sslKey),
|
||||
cert: fs.readFileSync(config.site.sslCert),
|
||||
};
|
||||
server = https.createServer(sslOptions, app);
|
||||
}
|
||||
|
||||
server.listen(config.site.port, config.site.host, function() {
|
||||
console.log('Mongo Express server listening',
|
||||
'on port ' + (config.site.port || 80),
|
||||
'at ' + (config.site.host || '0.0.0.0'));
|
||||
'on port ' + (config.site.port || defaultPort),
|
||||
'at ' + (config.site.host || '0.0.0.0'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user