Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
Delete Mongo Account
Browse files Browse the repository at this point in the history
  • Loading branch information
samrobbins85 committed Sep 7, 2020
1 parent f165d93 commit 37d73ea
Show file tree
Hide file tree
Showing 3 changed files with 1,244 additions and 1,002 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ If this does not make sense to you, then consult the JavaScript documentation ht
The simplest case is getZones as it is a GET request, whereas the rest are POSTs, so this can be accessed in the browser.
Going to `localhost:3000/stockTake/getZones` you will see the output.

## MongoDB URL
`mongodb+srv://new-user:[email protected]/test?retryWrites=true&w=majority`
55 changes: 28 additions & 27 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
var bodyParser = require('body-parser');
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var cors = require("cors")
var bodyParser = require("body-parser");
var createError = require("http-errors");
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
var cors = require("cors");



let stockTakeRouter = require('./routes/stockTake')
let stockTakeRouter = require("./routes/stockTake");

var app = express();
app.use(cors())


app.use(cors());

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");
//app.set('view engine', 'jade');

app.use(logger('dev'));
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(express.static(path.join(__dirname, "public")));
app.use(bodyParser.json());

app.use(function(req, res, next) {
app.use(function (req, res, next) {
if (!req.headers.authorization) {
return res.status(403).json({ error: 'No credentials sent!' });
return res.status(403).json({ error: "No credentials sent!" });
}
if (req.headers.authorization!=="YWxhZGRpbjpvcGVuc2VzYW1l") {
return res.status(403).json({ error: 'Invalid credentials' });
if (
req.headers.authorization !==
Math.random()
.toString(36)
.replace(/[^a-z]+/g, "")
.substr(0, 5)
) {
return res.status(403).json({ error: "Invalid credentials" });
}
next();
});


app.use('/stockTake', stockTakeRouter);
app.use("/stockTake", stockTakeRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
app.use(function (req, res, next) {
next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
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 : {};
res.locals.error = req.app.get("env") === "development" ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
res.render("error");
});

module.exports = app;
Loading

0 comments on commit 37d73ea

Please sign in to comment.