Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
var express = require('express');
var request = require('request');
var Rubidium = require('../');
var app = express();
var rb = new Rubidium();
app.use(express.json());
// In this case, the body is the message and it includes a callback URL.
app.post('/add/:timestamp', function (req, res) {
rb.add(parseInt(req.params.timestamp, 10), req.body);
res.send(202);
});
// When the job is emitted, send it back to the callback URL.
rb.on('job', function (job) {
var req;
// Protect against 'Invalid Request' errors.
try {
req = request({ url: job.message.callbackUrl, method: 'POST', json: job.message });
} catch (err) {
console.error(err.stack || err.message);
// useFindAndModify: false,
// };
// mongoose.connect(MONGO_URL, options);
const server = express();
server.use(cors({ origin: URL_APP, credentials: true }));
server.use(helmet());
server.use(compression());
// 11
// stripeWebHooks({ server });
server.use(express.json());
// 6
// const MongoStore = mongoSessionStore(session);
// const sessionOptions = {
// name: SESSION_NAME,
// secret: SESSION_SECRET,
// store: new MongoStore({
// mongooseConnection: mongoose.connection,
// ttl: 14 * 24 * 60 * 60, // save session 14 days
// }),
// resave: false,
// saveUninitialized: false,
// cookie: {
// httpOnly: true,
// maxAge: 14 * 24 * 60 * 60 * 1000, // expires in 14 days
// domain: COOKIE_DOMAIN,
//= =--- CAPTURE ENVIRONMENT VARIABLES
//= =---------------------------------------------------= =//
const {
PORT = 7000,
MONGO_DNS_SRV,
MONGO_AUTH,
MONGO_CLUSTER,
MONGO_DB_NAME,
MONGO_OPTIONS
} = process.env
//= =---------------------------------------------------= =//
//= =---------------------------------------------------= =//
//= =--- Use Express json parser
//= =---------------------------------------------------= =//
app.use(express.json())
//= =---------------------------------------------------= =//
//= =---------------------------------------------------= =//
// ---== HANDLE Homepage
//= =---------------------------------------------------= =//
app.get('/favicon.ico', (req, res) => res.status(204))
app.get('/', (request, response) => {
response.send(`
Welcome To Ratebook !<br>
<a href="/users">Users</a><br>
<a href="/books">Books</a>
`)
})
//= =---------------------------------------------------= =//
//= =---------------------------------------------------= =//
const express = require('express')
const shell = require('shelljs')
const app = express()
app.use(express.json())
const port = 5709
// your-username ALL=NOPASSWD: /sbin/shutdown
app.post('/', (req, res) => {
if (!req.body.command) return res.status(406).json({ response: "Missing params 'command'" })
switch (req.body.command) {
case 'off': {
if (shell.exec('sudo shutdown -h +1 "Shutting down in 1 minute."').code !== 0) {
return res.status(500).json({ response: "Can't run shutdown" })
}
return res.status(200).json({ response: 'Success' })
}
case 'reboot': {
if (shell.exec('sudo shutdown -r +1 "Rebooting in 1 minute."').code !== 0) {
var indexRouter = require("./routes/index");
var usersRouter = require("./routes/users");
var testAPIRouter = require("./routes/testAPI");
var testDBRouter = require("./routes/testDB");
var submitRouter = require("./routes/submit");
var app = express();
// view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "jade");
app.use(cors());
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")));
app.use("/", indexRouter);
app.use("/users", usersRouter);
app.use("/testAPI", testAPIRouter);
app.use("/testDB", testDBRouter);
app.use("/submit", submitRouter);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var Sequelize = require('sequelize');
require('dotenv').config()
var app = express();
var cors = require('cors');
// view engine setup
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(cors());
require('./routes')(app);
// 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 : {};
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();
var accountStorage = require('./common/accountTableStorage');
var passport = require('passport');
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var WindowsLiveStrategy = require('passport-windowslive');
// all environments
app.set('port', process.env.PORT || 3000);
//app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.session({ secret: process.env.SESSION_SECRET }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
//http://prestonpham.com/posts/google-oauth2/
require('dotenv').config()
const express = require('express')
const mongoose = require('mongoose')
const cookieParser = require('cookie-parser')
const cors = require('cors')
const helmet = require('helmet')
const projects = require('./routes/projects')
const users = require('./routes/users')
mongoose.connect(process.env.MONGO_URI)
const app = express()
// Middleware
app.use(express.json())
app.use(cookieParser())
app.use(helmet())
// Конфигурация CORS
app.use(
cors({
origin: process.env.CLIENT_URI,
credentials: true
})
)
// Маршрутизация
app.use('/api/projects', projects)
app.use('/api/users', users)
// Старт сервера
app.use(
methodOverride("_method", {
methods: ["POST", "GET"]
})
);
app.use(layouts);
app.use(express.static("public"));
app.use(expressValidator());
app.use(
express.urlencoded({
extended: false
})
);
app.use(express.json());
app.use(cookieParser("secretCuisine123"));
app.use(
expressSession({
secret: "secretCuisine123",
cookie: {
maxAge: 4000000
},
resave: false,
saveUninitialized: false
})
);
app.use(connectFlash());
app.use(passport.initialize());
app.use(passport.session());