This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const express = require('express'); | |
| // Import the Controller so we may assign specific functions to a route | |
| const controller = require('./user.controller'); | |
| // Assign the route variable to an Express.Route handler | |
| const router = express.Router(); | |
| /** | |
| * path: /api/user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const User = require('./user.model'); | |
| /** | |
| * Handles validation errors and returns the error to the user. | |
| * @param {Express.Response} res - an Express Response object | |
| * @param {number} statusCode - the result status code number | |
| */ | |
| function validationError(res, statusCode) { | |
| statusCode = statusCode || 422; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { AuthService } from './../providers/auth.service'; | |
| import { Injectable } from '@angular/core'; | |
| import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; | |
| import { Observable } from 'rxjs'; | |
| import 'rxjs/add/operator/map'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class AuthGuard implements CanActivate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mongoose = require('mongoose'); | |
| mongoose.Promise = require('bluebird'); | |
| const Schema = mongoose.Schema; // Mongoose model is a Schema | |
| // User Model Definition below | |
| const UserSchema = new Schema({ | |
| name: String, | |
| email: { | |
| type: String, | |
| lowercase: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const path = require('path'); | |
| const http = require('http'); | |
| const bodyParser = require('body-parser'); | |
| // Importing new installs | |
| const mongoose = require('mongoose'); | |
| mongoose.Promise = require('bluebird'); | |
| const connectMongo = require('connect-mongo'); | |
| const session = require('express-session'); | |
| const MongoStore = connectMongo(session); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const _ = require('lodash'); | |
| /** | |
| * Configuration settings for DB and application | |
| */ | |
| const all = { | |
| // secrets used to encrypt session data | |
| secrets: { | |
| // this secret is used to encrypt express session logs as well as user password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // We set the route of the templates and give it to expres | |
| app.set('views', `${__dirname}/server/views`); | |
| // Tell express's engine what file format we are targeting and what | |
| // library to use, in this case we use EJS and it;d renderfile engine | |
| app.engine('html', require('ejs').renderFile); | |
| // And lastly we set the 'view engine' to be HTML | |
| app.set('view engine', 'html'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const errors = require('./components/errors'); | |
| const path = require('path'); | |
| /** | |
| * Sets up all the routes for the Express app. | |
| * @param {Express} app - contains a reference to the Express App in the app.js file in the root of the project | |
| * @param {__dirname} root - contains an Object value pointing to the root of the project | |
| */ | |
| module.exports = function routes(app, root) { | |
| // Any new endpoints you create you will want to add them here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const path = require('path'); | |
| const http = require('http'); | |
| const bodyParser = require('body-parser'); | |
| /** | |
| * We create the app variable and initialize it to be an Express Application | |
| */ | |
| const app = express(); |
NewerOlder