mirror of
https://github.com/microsoft/TypeScript-Node-Starter.git
synced 2025-11-08 16:17:37 +00:00
Merge pull request #200 from peterblazejewicz/update/deps
Update project dependencies
This commit is contained in:
884
package-lock.json
generated
884
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
102
package.json
102
package.json
@@ -27,68 +27,68 @@
|
||||
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\""
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "^2.6.0",
|
||||
"async": "^3.0.1",
|
||||
"bcrypt-nodejs": "^0.0.3",
|
||||
"bluebird": "^3.5.1",
|
||||
"body-parser": "^1.18.2",
|
||||
"compression": "^1.7.1",
|
||||
"connect-mongo": "^2.0.0",
|
||||
"dotenv": "^4.0.0",
|
||||
"errorhandler": "^1.5.0",
|
||||
"express": "^4.16.2",
|
||||
"bluebird": "^3.5.5",
|
||||
"body-parser": "^1.19.0",
|
||||
"compression": "^1.7.4",
|
||||
"connect-mongo": "^3.0.0",
|
||||
"dotenv": "^8.0.0",
|
||||
"errorhandler": "^1.5.1",
|
||||
"express": "^4.17.1",
|
||||
"express-flash": "0.0.2",
|
||||
"express-session": "^1.15.6",
|
||||
"express-validator": "^4.3.0",
|
||||
"fbgraph": "^1.4.1",
|
||||
"lodash": "^4.17.5",
|
||||
"lusca": "^1.5.2",
|
||||
"mongoose": "^5.4.2",
|
||||
"nodemailer": "^4.4.1",
|
||||
"express-session": "^1.16.2",
|
||||
"express-validator": "^6.0.1",
|
||||
"fbgraph": "^1.4.4",
|
||||
"lodash": "^4.17.11",
|
||||
"lusca": "^1.6.1",
|
||||
"mongoose": "^5.6.0",
|
||||
"nodemailer": "^6.2.1",
|
||||
"passport": "^0.4.0",
|
||||
"passport-facebook": "^2.1.1",
|
||||
"passport-facebook": "^3.0.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pug": "^2.0.3",
|
||||
"pug": "^2.0.4",
|
||||
"request": "^2.88.0",
|
||||
"request-promise": "^4.2.2",
|
||||
"winston": "^2.4.0"
|
||||
"request-promise": "^4.2.4",
|
||||
"winston": "^2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/async": "^2.0.45",
|
||||
"@types/async": "^3.0.0",
|
||||
"@types/bcrypt-nodejs": "^0.0.30",
|
||||
"@types/bluebird": "^3.5.20",
|
||||
"@types/body-parser": "^1.16.8",
|
||||
"@types/compression": "^0.0.35",
|
||||
"@types/connect-mongo": "^0.0.35",
|
||||
"@types/dotenv": "^4.0.2",
|
||||
"@types/bluebird": "^3.5.27",
|
||||
"@types/body-parser": "^1.17.0",
|
||||
"@types/compression": "^0.0.36",
|
||||
"@types/connect-mongo": "^0.0.42",
|
||||
"@types/dotenv": "^6.1.1",
|
||||
"@types/errorhandler": "^0.0.32",
|
||||
"@types/express": "^4.11.1",
|
||||
"@types/express-session": "^1.15.8",
|
||||
"@types/jest": "^22.1.3",
|
||||
"@types/express": "^4.17.0",
|
||||
"@types/express-session": "^1.15.13",
|
||||
"@types/jest": "^24.0.15",
|
||||
"@types/jquery": "^3.3.29",
|
||||
"@types/lodash": "^4.14.91",
|
||||
"@types/lusca": "^1.5.0",
|
||||
"@types/mongodb": "^3.0.5",
|
||||
"@types/mongoose": "^4.7.34",
|
||||
"@types/lodash": "^4.14.134",
|
||||
"@types/lusca": "^1.6.0",
|
||||
"@types/mongodb": "^3.1.28",
|
||||
"@types/mongoose": "^5.5.6",
|
||||
"@types/morgan": "^1.7.35",
|
||||
"@types/node": "^9.4.6",
|
||||
"@types/nodemailer": "^4.3.4",
|
||||
"@types/passport": "^0.4.3",
|
||||
"@types/passport-facebook": "^2.1.7",
|
||||
"@types/passport-local": "^1.0.32",
|
||||
"@types/request": "^2.47.0",
|
||||
"@types/shelljs": "^0.7.8",
|
||||
"@types/supertest": "^2.0.4",
|
||||
"@types/winston": "^2.3.7",
|
||||
"chai": "^4.1.2",
|
||||
"concurrently": "^3.5.1",
|
||||
"jest": "^24.0.0",
|
||||
"@types/node": "^12.0.10",
|
||||
"@types/nodemailer": "^6.2.0",
|
||||
"@types/passport": "^1.0.0",
|
||||
"@types/passport-facebook": "^2.1.9",
|
||||
"@types/passport-local": "^1.0.33",
|
||||
"@types/request": "^2.48.1",
|
||||
"@types/shelljs": "^0.8.5",
|
||||
"@types/supertest": "^2.0.7",
|
||||
"@types/winston": "^2.3.9",
|
||||
"chai": "^4.2.0",
|
||||
"concurrently": "^4.1.0",
|
||||
"jest": "^24.8.0",
|
||||
"node-sass": "^4.12.0",
|
||||
"nodemon": "^1.18.10",
|
||||
"shelljs": "^0.8.1",
|
||||
"supertest": "^3.0.0",
|
||||
"ts-jest": "^24.0.0",
|
||||
"ts-node": "^5.0.0",
|
||||
"tslint": "^5.9.1",
|
||||
"typescript": "^3.4.5"
|
||||
"nodemon": "^1.19.1",
|
||||
"shelljs": "^0.8.3",
|
||||
"supertest": "^4.0.2",
|
||||
"ts-jest": "^24.0.2",
|
||||
"ts-node": "^8.3.0",
|
||||
"tslint": "^5.18.0",
|
||||
"typescript": "^3.5.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import flash from "express-flash";
|
||||
import path from "path";
|
||||
import mongoose from "mongoose";
|
||||
import passport from "passport";
|
||||
import expressValidator from "express-validator";
|
||||
import bluebird from "bluebird";
|
||||
import { MONGODB_URI, SESSION_SECRET } from "./util/secrets";
|
||||
|
||||
@@ -35,7 +34,7 @@ const app = express();
|
||||
const mongoUrl = MONGODB_URI;
|
||||
(<any>mongoose).Promise = bluebird;
|
||||
|
||||
mongoose.connect(mongoUrl, { useMongoClient: true }).then(
|
||||
mongoose.connect(mongoUrl, { useNewUrlParser: true} ).then(
|
||||
() => { /** ready to use. The `mongoose.connect()` promise resolves to undefined. */ },
|
||||
).catch(err => {
|
||||
console.log("MongoDB connection error. Please make sure MongoDB is running. " + err);
|
||||
@@ -49,7 +48,6 @@ app.set("view engine", "pug");
|
||||
app.use(compression());
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(expressValidator());
|
||||
app.use(session({
|
||||
resave: true,
|
||||
saveUninitialized: true,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import nodemailer from "nodemailer";
|
||||
import { Request, Response } from "express";
|
||||
import { check, validationResult } from "express-validator";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: "SendGrid",
|
||||
@@ -24,14 +25,14 @@ export const getContact = (req: Request, res: Response) => {
|
||||
* Send a contact form via Nodemailer.
|
||||
*/
|
||||
export const postContact = (req: Request, res: Response) => {
|
||||
req.assert("name", "Name cannot be blank").notEmpty();
|
||||
req.assert("email", "Email is not valid").isEmail();
|
||||
req.assert("message", "Message cannot be blank").notEmpty();
|
||||
check("name", "Name cannot be blank").not().isEmpty();
|
||||
check("email", "Email is not valid").isEmail();
|
||||
check("message", "Message cannot be blank").not().isEmpty();
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/contact");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { User, UserDocument, AuthToken } from "../models/User";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { IVerifyOptions } from "passport-local";
|
||||
import { WriteError } from "mongodb";
|
||||
import request from "express-validator";
|
||||
import { check, sanitize, validationResult } from "express-validator";
|
||||
import "../config/passport";
|
||||
|
||||
/**
|
||||
@@ -27,21 +27,21 @@ export const getLogin = (req: Request, res: Response) => {
|
||||
* Sign in using email and password.
|
||||
*/
|
||||
export const postLogin = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("email", "Email is not valid").isEmail();
|
||||
req.assert("password", "Password cannot be blank").notEmpty();
|
||||
req.sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
check("email", "Email is not valid").isEmail();
|
||||
check("password", "Password cannot be blank").isLength({min: 1});
|
||||
sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/login");
|
||||
}
|
||||
|
||||
passport.authenticate("local", (err: Error, user: UserDocument, info: IVerifyOptions) => {
|
||||
if (err) { return next(err); }
|
||||
if (!user) {
|
||||
req.flash("errors", info.message);
|
||||
req.flash("errors", {msg: info.message});
|
||||
return res.redirect("/login");
|
||||
}
|
||||
req.logIn(user, (err) => {
|
||||
@@ -79,15 +79,15 @@ export const getSignup = (req: Request, res: Response) => {
|
||||
* Create a new local account.
|
||||
*/
|
||||
export const postSignup = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("email", "Email is not valid").isEmail();
|
||||
req.assert("password", "Password must be at least 4 characters long").len({ min: 4 });
|
||||
req.assert("confirmPassword", "Passwords do not match").equals(req.body.password);
|
||||
req.sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
check("email", "Email is not valid").isEmail();
|
||||
check("password", "Password must be at least 4 characters long").isLength({ min: 4 });
|
||||
check("confirmPassword", "Passwords do not match").equals(req.body.password);
|
||||
sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/signup");
|
||||
}
|
||||
|
||||
@@ -129,13 +129,13 @@ export const getAccount = (req: Request, res: Response) => {
|
||||
* Update profile information.
|
||||
*/
|
||||
export const postUpdateProfile = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("email", "Please enter a valid email address.").isEmail();
|
||||
req.sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
check("email", "Please enter a valid email address.").isEmail();
|
||||
sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/account");
|
||||
}
|
||||
|
||||
@@ -165,13 +165,13 @@ export const postUpdateProfile = (req: Request, res: Response, next: NextFunctio
|
||||
* Update current password.
|
||||
*/
|
||||
export const postUpdatePassword = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("password", "Password must be at least 4 characters long").len({ min: 4 });
|
||||
req.assert("confirmPassword", "Passwords do not match").equals(req.body.password);
|
||||
check("password", "Password must be at least 4 characters long").isLength({ min: 4 });
|
||||
check("confirmPassword", "Passwords do not match").equals(req.body.password);
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/account");
|
||||
}
|
||||
|
||||
@@ -245,13 +245,13 @@ export const getReset = (req: Request, res: Response, next: NextFunction) => {
|
||||
* Process the reset password request.
|
||||
*/
|
||||
export const postReset = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("password", "Password must be at least 4 characters long.").len({ min: 4 });
|
||||
req.assert("confirm", "Passwords must match.").equals(req.body.password);
|
||||
check("password", "Password must be at least 4 characters long.").isLength({ min: 4 });
|
||||
check("confirm", "Passwords must match.").equals(req.body.password);
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("back");
|
||||
}
|
||||
|
||||
@@ -320,13 +320,13 @@ export const getForgot = (req: Request, res: Response) => {
|
||||
* Create a random token, then the send user an email with a reset link.
|
||||
*/
|
||||
export const postForgot = (req: Request, res: Response, next: NextFunction) => {
|
||||
req.assert("email", "Please enter a valid email address.").isEmail();
|
||||
req.sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
check("email", "Please enter a valid email address.").isEmail();
|
||||
sanitize("email").normalizeEmail({ gmail_remove_dots: false });
|
||||
|
||||
const errors = req.validationErrors();
|
||||
const errors = validationResult(req);
|
||||
|
||||
if (errors) {
|
||||
req.flash("errors", errors);
|
||||
if (!errors.isEmpty()) {
|
||||
req.flash("errors", errors.array());
|
||||
return res.redirect("/forgot");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ const userSchema = new mongoose.Schema({
|
||||
* Password hash middleware.
|
||||
*/
|
||||
userSchema.pre("save", function save(next) {
|
||||
const user = this;
|
||||
const user = this as UserDocument;
|
||||
if (!user.isModified("password")) { return next(); }
|
||||
bcrypt.genSalt(10, (err, salt) => {
|
||||
if (err) { return next(err); }
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import winston from "winston";
|
||||
import { Logger } from "winston";
|
||||
import { Logger, LoggerOptions, transports } from "winston";
|
||||
|
||||
const logger = new (Logger)({
|
||||
transports: [
|
||||
new (winston.transports.Console)({ level: process.env.NODE_ENV === "production" ? "error" : "debug" }),
|
||||
new (winston.transports.File)({ filename: "debug.log", level: "debug"})
|
||||
]
|
||||
});
|
||||
const options: LoggerOptions = {
|
||||
transports: [
|
||||
new transports.Console({
|
||||
level: process.env.NODE_ENV === "production" ? "error" : "debug"
|
||||
}),
|
||||
new transports.File({ filename: "debug.log", level: "debug" })
|
||||
]
|
||||
};
|
||||
|
||||
const logger = new Logger(options);
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
logger.debug("Logging initialized at debug level");
|
||||
logger.debug("Logging initialized at debug level");
|
||||
}
|
||||
|
||||
export default logger;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
|
||||
Reference in New Issue
Block a user