Commit 1a0849c5 authored by Jay Wilson's avatar Jay Wilson 🎤
Browse files

Merge branch '18-port-to-js' into 'master'

Resolve "Port to JS"

Closes #18

See merge request !1
parents b02cfb9a f5ef664e
This diff is collapsed.
This diff is collapsed.
$(document).ready(function() {
// Place JavaScript code here...
});
\ No newline at end of file
import errorHandler from "errorhandler";
import app from "./app";
/**
* Error Handler. Provides full stack - remove for production
*/
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(" Press CTRL-C to stop\n");
});
export default server;
/// <reference types="express" />
// Add RequestValidation Interface on to Express's Request Interface.
declare namespace Express {
interface Request extends Flash {}
}
interface Flash {
flash(type: string, message: any): void;
}
declare module "express-flash";
/** Declaration file generated by dts-gen */
export const version: string;
export function authorize(params: any, callback: any): any;
export function batch(reqs: any, additionalData: any, callback: any): any;
export function del(url: any, postData: any, callback: any): any;
export function extendAccessToken(params: any, callback: any): any;
export function fql(query: any, params: any, callback: any): any;
export function get(url: any, params?: any, callback?: any): any;
export function getAccessToken(): any;
export function getAppSecret(): any;
export function getGraphUrl(): any;
export function getOauthUrl(params: any, opts: any): any;
export function getOptions(): any;
export function post(url: any, postData: any, callback: any): any;
export function search(options: any, callback: any): any;
export function setAccessToken(token: any): any;
export function setAppSecret(token: any): any;
export function setGraphUrl(url: any): any;
export function setOptions(options: any): any;
export function setVersion(version: any): any;
/**
* Fairly incomplete. I only added some commonly used fields.
*/
export type FacebookUser = {
id: string,
name: string,
email: string,
first_name: string,
last_name: string,
gender: string,
link: string,
locale: string,
timezone: number
};
import winston from "winston";
import { Logger } from "winston";
import { ENVIRONMENT } from "./secrets";
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"})
]
});
if (process.env.NODE_ENV !== "production") {
logger.debug("Logging initialized at debug level");
}
export default logger;
import logger from "./logger";
import dotenv from "dotenv";
import fs from "fs";
if (fs.existsSync(".env")) {
logger.debug("Using .env file to supply config environment variables");
dotenv.config({ path: ".env" });
} else {
logger.debug("Using .env.example file to supply config environment variables");
dotenv.config({ path: ".env.example" }); // you can delete this after you create your own .env file!
}
export const ENVIRONMENT = process.env.NODE_ENV;
const prod = ENVIRONMENT === "production"; // Anything else is treated as 'dev'
import request from "supertest";
import app from "../src/app";
describe("GET /api", () => {
it("should return 200 OK", () => {
return request(app).get("/api")
.expect(200);
});
});
import request from "supertest";
import app from "../src/app";
describe("GET /random-url", () => {
it("should return 404", (done) => {
request(app).get("/reset")
.expect(404, done);
});
});
import request from "supertest";
import app from "../src/app";
const chai = require("chai");
const expect = chai.expect;
describe("GET /contact", () => {
it("should return 200 OK", (done) => {
request(app).get("/contact")
.expect(200, done);
});
});
describe("POST /contact", () => {
it("should return false from assert when no message is found", (done) => {
request(app).post("/contact")
.field("name", "John Doe")
.field("email", "john@me.com")
.end(function(err, res) {
expect(res.error).to.be.false;
done();
})
.expect(302);
});
});
\ No newline at end of file
import request from "supertest";
import app from "../src/app";
describe("GET /", () => {
it("should return 200 OK", (done) => {
request(app).get("/")
.expect(200, done);
});
});
import request from "supertest";
import app from "../src/app";
const chai = require("chai");
const expect = chai.expect;
describe("GET /login", () => {
it("should return 200 OK", () => {
return request(app).get("/login")
.expect(200);
});
});
describe("GET /signup", () => {
it("should return 200 OK", () => {
return request(app).get("/signup")
.expect(200);
});
});
describe("POST /login", () => {
it("should return some defined error message with valid parameters", (done) => {
return request(app).post("/login")
.field("email", "john@me.com")
.field("password", "Hunter2")
.expect(302)
.end(function(err, res) {
expect(res.error).not.to.be.undefined;
done();
});
});
});
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"extendedDiagnostics": false,
"paths": {
"*": [
"node_modules/*",
"node_modules/@types/*",
"src/types/*"
]
}
},
"include": [
"src/*"
]
}
{
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"no-var-keyword": true,
"quotemark": [
true,
"double",
"avoid-escape"
],
"semicolon": [
true,
"always",
"ignore-bound-class-methods"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
],
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-null-keyword": true,
"prefer-const": true,
"jsdoc-format": true
}
}
extends ../layout
block content
.page-header
h2
i.fa.fa-facebook-square(style='color: #335397')
| Facebook API
.btn-group.btn-group-justified
a.btn.btn-primary(href='https://developers.facebook.com/docs/graph-api/quickstart/', target='_blank')
i.fa.fa-check-square-o
| Quickstart
a.btn.btn-primary(href='https://developers.facebook.com/tools/explorer', target='_blank')
i.fa.fa-facebook
| Graph API Explorer
a.btn.btn-primary(href='https://developers.facebook.com/docs/graph-api/reference/', target='_blank')
i.fa.fa-code-fork
| API Reference
h3
i.fa.fa-user
| My Profile
img.thumbnail(src=`https://graph.facebook.com/${profile.id}/picture?type=large`, width='90', height='90', alt=(profile.name || profile.username))
h4= profile.name
h6 First Name: #{profile.first_name}
h6 Last Name: #{profile.last_name}
h6 Gender: #{profile.gender}
h6 Username: #{profile.username}
h6 Link: #{profile.link}
h6 Email: #{profile.email}
h6 Locale: #{profile.locale}
h6 Timezone: #{profile.timezone}
extends ../layout
block content
h2 API Examples
hr
.row
.col-sm-4
a(href='/api/facebook', style='color: #fff')
.panel.panel-default(style='background-color: #3b5998')
.panel-body
img(src='http://i.imgur.com/jiztYCH.png', height=40, alt='Facebook')
| Facebook
extends layout
block extra_head
link(rel='stylesheet' href='https://unpkg.com/leaflet@1.3.1/dist/leaflet.css' integrity='sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==' crossorigin='')
link(rel='stylesheet' href='../node_modules/titatoggle/dist/titatoggle-dist-min.css')
style.
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
width: 100%;
margin-bottom: 0;
}
#page-content {
height: 100%;
}
#map-container {
padding: 0;
margin: 0;
}
block content
#page-content.container-fluid
.row(style='height: 100%;')
nav.col-sm-3.col-md-2.d-none.d-sm-block.navbar-inverse.navbar-dark.bg-dark.sidebar
h1.navbar-brand.navbar-dark.bg-dark MapMason
p
h3.text-primary Search
form.form-inline.mt-2.mt-md-0
small.form-text.text-light Search via Name or Keyword
input.form-control.mr-sm-2(type='text' placeholder='Search' aria-label='Name or Keyword')
p
p
h3.text-primary Filter Locations
.nav.flex-column.text-light
.form-check.checkbox-slider--b-flat
label
input(type='checkbox')
span Parking
.form-check.checkbox-slider--b-flat
label
input(type='checkbox')
span Residence Halls
.form-check.checkbox-slider--b-flat
label
input(type='checkbox')
span Dining Halls
p
p.text-light
| Having problems?
a(href='mailto:srct@gmu.edu') Submit feedback
p.text-muted
| A service of
a(href='http://srct.gmu.edu') Mason SRCT
| . Licensed under the
a(href='http://opensource.org/licenses/Apache-2.0') Apache License, Version 2.0
| .
main#map-container.col-sm-9.ml-sm-auto.col-md-10(role='main')
#map
doctype html
html(lang='en')
head
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge')
meta(name='viewport', content='width=device-width, initial-scale=1.0, shrink-to-fit=no')
title #{title} - Where
//meta(name='description', content='')
//meta(name='csrf-token', content=_csrf)
//link(rel='shortcut icon', href='/images/favicon.png')
link(rel='stylesheet', href='https://srct.gmu.io/masonstrap/css/masonstrap.min.css')
block extra_head
body
block content
script(async defer src='https://code.jquery.com/jquery-3.2.1.slim.min.js', integrity='sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN', crossorigin='anonymous')
script(src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', integrity='sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q', crossorigin='anonymous')
script(src='https://srct.gmu.io/masonstrap/js/masonstrap.min.js')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment