1
0
mirror of https://github.com/microsoft/TypeScript-Node-Starter.git synced 2025-11-08 16:17:37 +00:00

Update source and dependency to work with TypeScript 2.7. Closes #81

The commit brings compatibility with new features introduced in TypeScript 2.7.
The one with most impact on this project is ES6/ECMAScript module compatibility layer
added in 2.7 enabled in tsconfig.json for this project.
This allowed to rewrite source files to use shorted, better imports everywhere and
also use default exports.

To make project more aligned with updated TypeScript all the NPM depenendencies has been
updated making sure that everything works as expected and tests pass.

Thanks for the project!

Thanks!
This commit is contained in:
Peter Blazejewicz
2018-02-20 21:58:46 +01:00
parent dcb287e63d
commit 1b71586efa
15 changed files with 2423 additions and 1680 deletions

3945
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -41,7 +41,7 @@
"fbgraph": "^1.4.1",
"lodash": "^4.17.4",
"lusca": "^1.5.2",
"mongoose": "^4.13.7",
"mongoose": "^4.13.11",
"morgan": "^1.9.0",
"nodemailer": "^4.4.1",
"passport": "^0.4.0",
@@ -52,40 +52,40 @@
},
"devDependencies": {
"@types/async": "^2.0.45",
"@types/bcrypt-nodejs": "0.0.30",
"@types/bluebird": "^3.5.18",
"@types/bcrypt-nodejs": "^0.0.30",
"@types/bluebird": "^3.5.20",
"@types/body-parser": "^1.16.8",
"@types/compression": "0.0.33",
"@types/connect-mongo": "0.0.34",
"@types/compression": "^0.0.35",
"@types/connect-mongo": "^0.0.35",
"@types/dotenv": "^4.0.2",
"@types/errorhandler": "0.0.32",
"@types/express": "^4.0.35",
"@types/express-session": "^1.15.6",
"@types/jest": "^21.1.8",
"@types/errorhandler": "^0.0.32",
"@types/express": "^4.11.1",
"@types/express-session": "^1.15.8",
"@types/jest": "^22.1.3",
"@types/jquery": "^3.2.17",
"@types/lodash": "^4.14.91",
"@types/lusca": "^1.5.0",
"@types/mongodb": "^2.2.17",
"@types/mongoose": "^4.7.29",
"@types/morgan": "^1.7.32",
"@types/node": "^7.0.50",
"@types/nodemailer": "^1.3.32",
"@types/passport": "^0.3.3",
"@types/passport-facebook": "^2.1.3",
"@types/mongodb": "^3.0.5",
"@types/mongoose": "^4.7.34",
"@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.0.9",
"@types/request": "^2.47.0",
"@types/shelljs": "^0.7.8",
"@types/supertest": "^2.0.4",
"@types/shelljs": "^0.7.7",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
"jest": "^21.2.1",
"jest": "^22.0.4",
"node-sass": "^4.7.2",
"nodemon": "^1.13.0",
"shelljs": "^0.7.7",
"supertest": "^3.0.0",
"ts-jest": "^21.2.4",
"ts-node": "^4.0.2",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
"ts-jest": "^22.0.4",
"ts-node": "^5.0.0",
"tslint": "^5.9.1",
"typescript": "^2.7.2"
}
}

View File

@@ -1,17 +1,17 @@
import * as express from "express";
import * as compression from "compression"; // compresses requests
import * as session from "express-session";
import * as bodyParser from "body-parser";
import * as logger from "morgan";
import * as lusca from "lusca";
import * as dotenv from "dotenv";
import * as mongo from "connect-mongo";
import * as flash from "express-flash";
import * as path from "path";
import * as mongoose from "mongoose";
import * as passport from "passport";
import * as expressValidator from "express-validator";
import * as bluebird from "bluebird";
import express from "express";
import compression from "compression"; // compresses requests
import session from "express-session";
import bodyParser from "body-parser";
import logger from "morgan";
import lusca from "lusca";
import dotenv from "dotenv";
import mongo from "connect-mongo";
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";
const MongoStore = mongo(session);
@@ -82,7 +82,10 @@ app.use((req, res, next) => {
}
next();
});
app.use(express.static(path.join(__dirname, "public"), { maxAge: 31557600000 }));
app.use(
express.static(path.join(__dirname, "public"), { maxAge: 31557600000 })
);
/**
* Primary app routes.
@@ -119,4 +122,4 @@ app.get("/auth/facebook/callback", passport.authenticate("facebook", { failureRe
res.redirect(req.session.returnTo || "/");
});
module.exports = app;
export default app;

View File

@@ -1,8 +1,8 @@
import * as passport from "passport";
import * as request from "request";
import * as passportLocal from "passport-local";
import * as passportFacebook from "passport-facebook";
import * as _ from "lodash";
import passport from "passport";
import request from "request";
import passportLocal from "passport-local";
import passportFacebook from "passport-facebook";
import _ from "lodash";
// import { User, UserType } from '../models/User';
import { default as User } from "../models/User";

View File

@@ -1,8 +1,8 @@
"use strict";
import * as async from "async";
import * as request from "request";
import * as graph from "fbgraph";
import async from "async";
import request from "request";
import graph from "fbgraph";
import { Response, Request, NextFunction } from "express";

View File

@@ -1,4 +1,4 @@
import * as nodemailer from "nodemailer";
import nodemailer from "nodemailer";
import { Request, Response } from "express";
const transporter = nodemailer.createTransport({

View File

@@ -1,7 +1,7 @@
import * as async from "async";
import * as crypto from "crypto";
import * as nodemailer from "nodemailer";
import * as passport from "passport";
import async from "async";
import crypto from "crypto";
import nodemailer from "nodemailer";
import passport from "passport";
import { default as User, UserModel, AuthToken } from "../models/User";
import { Request, Response, NextFunction } from "express";
import { IVerifyOptions } from "passport-local";

View File

@@ -1,6 +1,6 @@
import * as bcrypt from "bcrypt-nodejs";
import * as crypto from "crypto";
import * as mongoose from "mongoose";
import bcrypt from "bcrypt-nodejs";
import crypto from "crypto";
import mongoose from "mongoose";
export type UserModel = mongoose.Document & {
email: string,

View File

@@ -1,6 +1,6 @@
import * as errorHandler from "errorhandler";
import errorHandler from "errorhandler";
const app = require("./app");
import app from "./app";
/**
* Error Handler. Provides full stack - remove for production
@@ -11,8 +11,12 @@ app.use(errorHandler());
* Start Express server.
*/
const server = app.listen(app.get("port"), () => {
console.log((" App is running at http://localhost:%d in %s mode"), app.get("port"), app.get("env"));
console.log(
" App is running at http://localhost:%d in %s mode",
app.get("port"),
app.get("env")
);
console.log(" Press CTRL-C to stop\n");
});
export = server;
export default server;

View File

@@ -1,5 +1,5 @@
import * as request from "supertest";
import * as app from "../src/app";
import request from "supertest";
import app from "../src/app";
describe("GET /api", () => {
it("should return 200 OK", () => {

View File

@@ -1,5 +1,5 @@
import * as request from "supertest";
import * as app from "../src/app";
import request from "supertest";
import app from "../src/app";
describe("GET /random-url", () => {
it("should return 404", (done) => {

View File

@@ -1,8 +1,8 @@
import * as request from "supertest";
import * as app from "../src/app";
import request from "supertest";
import app from "../src/app";
var chai = require('chai');
var expect = chai.expect;
const chai = require("chai");
const expect = chai.expect;
describe("GET /contact", () => {
it("should return 200 OK", (done) => {
@@ -22,6 +22,6 @@ describe("POST /contact", () => {
done();
})
.expect(302);
});
});

View File

@@ -1,5 +1,5 @@
import * as request from "supertest";
import * as app from "../src/app";
import request from "supertest";
import app from "../src/app";
describe("GET /", () => {
it("should return 200 OK", (done) => {

View File

@@ -1,8 +1,8 @@
import * as request from "supertest";
import * as app from "../src/app";
import request from "supertest";
import app from "../src/app";
var chai = require('chai');
var expect = chai.expect;
const chai = require("chai");
const expect = chai.expect;
describe("GET /login", () => {
it("should return 200 OK", () => {
@@ -29,6 +29,6 @@ describe("POST /login", () => {
expect(res.error).not.to.be.undefined;
done();
});
});
});

View File

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",