From f6a4415af709ba3295700f510b7729b4e26d8fa7 Mon Sep 17 00:00:00 2001 From: Apichat.Tum Date: Tue, 11 Oct 2016 18:10:51 +0700 Subject: [PATCH] start smart-rms-calendar --- .eslintrc.js | 19 +++++++++++++++++++ .eslintrc.json | 23 +++++++++++++++++++++++ .gitignore | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .vscode/cSpell.json | 26 ++++++++++++++++++++++++++ .vscode/extensions.json | 13 +++++++++++++ .vscode/launch.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 17 +++++++++++++++++ app/controllers/home.controller.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/lib/index.js | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/routes/home.routes.js | 10 ++++++++++ bower.json | 36 ++++++++++++++++++++++++++++++++++++ client_secret.json | 14 ++++++++++++++ config/config.yml | 18 ++++++++++++++++++ jsconfig.json | 16 ++++++++++++++++ package.json | 32 ++++++++++++++++++++++++++++++++ public/views/index.html | 14 ++++++++++++++ quickstart.js | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 18 files changed, 857 insertions(+), 0 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 .vscode/cSpell.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 app/controllers/home.controller.js create mode 100644 app/lib/index.js create mode 100644 app/routes/home.routes.js create mode 100644 bower.json create mode 100644 client_secret.json create mode 100644 config/config.yml create mode 100644 jsconfig.json create mode 100644 package.json create mode 100644 public/views/index.html create mode 100644 quickstart.js create mode 100644 server.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..da2786e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,19 @@ +module.exports = { + "extends": ["standard"], + "env": { + "browser": 1 + }, + + "globals": { + "angular": 1 + }, + + "rules": { + "quotes": [2, "single"], + "space-before-function-paren": 0, + "eqeqeq": 0, + "strict": 0, + "indent": 0, + "eol-last": 0 + } +}; \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..7db5754 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "no-unused-vars": "warn", + "constructor-super": "warn", + "valid-typeof": "warn" + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a33f2c --- /dev/null +++ b/.gitignore @@ -0,0 +1,227 @@ + +# Created by https://www.gitignore.io/api/bower,node,osx,windows,jetbrains + +### Bower ### +bower_components +.bower-cache +.bower-registry +.bower-tmp + + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml + +# Sensitive or high-churn files: +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +<<<<<<< HEAD + + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +## commented out to support storage of libs in git +# *.jar +# *.war +# *.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +logs + +# logstatalarm # +logstatalarm +T16/Interface_Specification_SS7_Simulator_1.0_draft_J.docx diff --git a/.vscode/cSpell.json b/.vscode/cSpell.json new file mode 100644 index 0000000..6a288f0 --- /dev/null +++ b/.vscode/cSpell.json @@ -0,0 +1,26 @@ +// cSpell Settings +{ + // Version of the setting file. Always 0.1 + "version": "0.1", + // language - current active spelling language + "language": "en", + // words - list of words to be always considered correct + "words": [ + "ussd", + "eventlog", + "USSN", + "PUSR", + "GPRS", + "isup", + "toastr", + "}", + "lastname", + "firstname" + ], + // flagWords - list of words to be always considered incorrect + // This is useful for offensive words and common spelling errors. + // For example "hte" should be "the" + "flagWords": [ + "hte" + ] +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..1304837 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + "recommendations": [ + "christian-kohler.path-intellisense", + "dbaeumer.vscode-eslint", + "abusaidm.html-snippets", + "be5invis.vscode-icontheme-nomo-dark", + "alefragnani.Bookmarks", + "donjayamanne.githistory", + "karyfoundation.comment", + "ms-vscode.typescript-javascript-grammar", + "mkaufman.HTMLHint" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..adcbb94 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "node", + "request": "launch", + "program": "${workspaceRoot}/server.js", + "stopOnEntry": false, + "args": [], + "cwd": "${workspaceRoot}", + "preLaunchTask": null, + "runtimeExecutable": null, + "runtimeArgs": [ + "--nolazy" + ], + "env": { + "NODE_ENV": "localhost" + }, + "console": "integratedTerminal", + "sourceMaps": true, + "outDir": null + }, + { + "name": "Attach", + "type": "node", + "request": "attach", + "port": 5858, + "address": "localhost", + "restart": false, + "sourceMaps": false, + "outDir": null, + "localRoot": "${workspaceRoot}", + "remoteRoot": null + }, + { + "name": "Attach to Process", + "type": "node", + "request": "attach", + "processId": "${command.PickProcess}", + "port": 5858, + "sourceMaps": false, + "outDir": null + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f274124 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "editor.tabSize": 4, + "beautify.onSave": true, + "editor.renderIndentGuides": true, + "editor.wordWrap": false, + "editor.detectIndentation": false, + "editor.wrappingColumn": -1, + "editor.cursorBlinking": "smooth", + "editor.glyphMargin": true, + "editor.formatOnType": true, + "html.suggest.angular1": true, + "html.suggest.html5": true, + "editor.formatOnSave": true, + "workbench.editor.showIcons": true, + "eslint.enable": false +} \ No newline at end of file diff --git a/app/controllers/home.controller.js b/app/controllers/home.controller.js new file mode 100644 index 0000000..2c03ddc --- /dev/null +++ b/app/controllers/home.controller.js @@ -0,0 +1,73 @@ +'use strict' + +const console = process.console +const yamlConfig = require('node-yaml-config') +const path = require('path') +const config = yamlConfig.load(path.join(__dirname, '/../../config/config.yml')) + +const lib = require('../lib') + +// lib.authorize() +// lib.listEvents() +// lib.createEvent() + +const url = config.server.url +const port = config.server.port +const urlto = config.server.urlto +const portto = config.server.portto + +function index(req, res) { + res.send({ + message: 'Google Calendar API', + endpoint: { + listEvents: 'GET /events', + createEvent: 'POST /events' + } + }) +} + +function events(req, res) { + lib.authorize((err, auth) => { + if (err) { + res.send(err) + } + lib.listEvents(auth, (err, response) => { + if (err) { + res.send(err) + } else { + res.send(response) + } + }) + }) +} + +function create(req, res) { + let payload = req.body + + let summary = payload.summary + let description = payload.description + let email = payload.email + let startDate = payload.startDate + let endDate = payload.endDate + + lib.authorize((err, auth) => { + if (err) { + res.send(err) + } + + // let options = lib.eventBuilder(payload) + // options.auth = auth + + lib.createEvent(auth, payload, (err, result) => { + if (err) { + res.send(err) + } else { + res.send(result) + } + }) + }) +} + +module.exports.index = index +module.exports.events = events +module.exports.create = create diff --git a/app/lib/index.js b/app/lib/index.js new file mode 100644 index 0000000..3a356b3 --- /dev/null +++ b/app/lib/index.js @@ -0,0 +1,97 @@ +'use strict'; + +const google = require('googleapis'); +const googleAuth = require('google-auth-library'); +const calendar = google.calendar('v3'); + +const fs = require('fs'); + +const SCOPES = [process.env.SCOPES]; +const TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE) + '/.credentials/'; +const TOKEN_PATH = TOKEN_DIR + 'calendar-nodejs-quickstart.json'; + +module.exports = { + + authorize: (callback) => { + + fs.readFile('client_secret.json', function processClientSecrets(err, content) { + if (err) { + console.log('Error loading client secret file: ' + err); + return; + } + + let credentials = JSON.parse(content); + var clientSecret = credentials.installed.client_secret; + var clientId = credentials.installed.client_id; + var redirectUrl = credentials.installed.redirect_uris[0]; + var auth = new googleAuth(); + var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl); + + // Check if we have previously stored a token. + fs.readFile(TOKEN_PATH, function (err, token) { + if (err) { + return callback(err); + } else { + oauth2Client.credentials = JSON.parse(token); + return callback(null, oauth2Client); + } + }); + + }); + + }, + + getNewToken: (oauth2Client, callback) => { + var authUrl = oauth2Client.generateAuthUrl({ + access_type: 'offline', + scope: SCOPES + }); + console.log('Authorize this app by visiting this url: ', authUrl); + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + rl.question('Enter the code from that page here: ', function (code) { + rl.close(); + oauth2Client.getToken(code, function (err, token) { + if (err) { + console.log('Error while trying to retrieve access token', err); + return; + } + oauth2Client.credentials = token; + storeToken(token); + callback(oauth2Client); + }); + }); + }, + + listEvents: (auth, callback) => { + calendar.events.list({ + auth: auth, + calendarId: process.env.CALENDAR_ID, + timeMin: (new Date()).toISOString(), + maxResults: 50, + singleEvents: true, + orderBy: 'startTime' + }, (err, response) => { + if (err) { + return callback(err); + } + return callback(null, response); + }); + }, + + createEvent: (auth, event, callback) => { + + calendar.events.insert({ + auth: auth, + calendarId: process.env.CALENDAR_ID, + resource: event, + }, (err, event) => { + if (err) { + return callback('There was an error contacting the Calendar service: ' + err); + } + return callback(null, event.htmlLink); + }); + } +} \ No newline at end of file diff --git a/app/routes/home.routes.js b/app/routes/home.routes.js new file mode 100644 index 0000000..0a5847e --- /dev/null +++ b/app/routes/home.routes.js @@ -0,0 +1,10 @@ +// var console = process.console +var express = require('express') +var router = express.Router() +var home = require('../controllers/home.controller') + +router.get('/', home.index) +router.get('/events', home.events) +router.post('/events', home.create) + +module.exports = router \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..a51c070 --- /dev/null +++ b/bower.json @@ -0,0 +1,36 @@ +{ + "name": "ss7", + "description": "", + "main": "", + "license": "MIT", + "homepage": "", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "angular-datatables": "^0.5.4", + "yamljs": "^0.1.5", + "sweetalert": "^1.1.3", + "angular-ui-router": "^0.3.1", + "ui-router-extras": "^0.1.2", + "ng-slim-scroll": "^0.2.2", + "angular-slimscroll": "^1.1.5", + "angular-ladda": "^0.4.1", + "toastr": "^2.1.3", + "angular-toastr": "^2.1.1", + "angular-animate": "^1.5.8", + "angular-validation-match": "^1.9.0", + "ngFitText": "^4.2.1", + "angular-loading-bar": "^0.9.0", + "animate.css": "^3.5.2", + "ng-dialog": "^0.6.4" + }, + "resolutions": { + "angular-ui-router": "^0.3.1" + } +} diff --git a/client_secret.json b/client_secret.json new file mode 100644 index 0000000..0814463 --- /dev/null +++ b/client_secret.json @@ -0,0 +1,14 @@ +{ + "installed": { + "client_id": "16634359544-7crvssfmpmtp0ng3jbipms65ccl9aol1.apps.googleusercontent.com", + "project_id": "psyched-garage-146109", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://accounts.google.com/o/oauth2/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_secret": "lpIa_7Wwbang6jTypMfCpOR6", + "redirect_uris": [ + "urn:ietf:wg:oauth:2.0:oob", + "http://localhost" + ] + } +} \ No newline at end of file diff --git a/config/config.yml b/config/config.yml new file mode 100644 index 0000000..5312f8f --- /dev/null +++ b/config/config.yml @@ -0,0 +1,18 @@ +##### deverlopment Config +localhost: + skipLogin: true + debug: true + server: + url: 'localhost' + urlto: 'localhost' + port: 3001 + portto: 4001 + database: + host: 'localhost' + port: 27017 + name: 'ss7' + options: + user: + pass: + timerecheck: '10000' #millisecond + apitimeout: 3000 #millisecond \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..0136d6f --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,16 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=759670 + // for the documentation about the jsconfig.json format + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "allowSyntheticDefaultImports": true + }, + "exclude": [ + "node_modules", + "bower_components", + "jspm_packages", + "tmp", + "temp" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..4bf0dca --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "smart-rms-schedule", + "version": "1.0.0", + "dependencies": { + "async": "^2.0.1", + "bluebird": "^3.4.1", + "body-parser": "~1.15.0", + "busboy-body-parser": "0.0.10", + "ejs": "^2.5.2", + "express": "~4.13.0", + "formidable": "^1.0.17", + "google-auth-library": "^0.9.8", + "googleapis": "^14.0.0", + "indicative": "^2.1.0", + "moment": "^2.14.1", + "moment-timezone": "^0.5.5", + "node-yaml-config": "0.0.4", + "scribe-js": "^2.0.4", + "unirest": "^0.5.0" + }, + "devDependencies": { + "eslint": "^3.4.0", + "eslint-config-angular": "^0.5.0", + "eslint-config-defaults": "^9.0.0", + "eslint-config-google": "^0.6.0", + "eslint-config-standard": "^6.0.0", + "eslint-plugin-angular": "^1.3.1", + "eslint-plugin-promise": "^2.0.1", + "eslint-plugin-standard": "^2.0.0", + "gulp-ftp": "^1.1.0" + } +} diff --git a/public/views/index.html b/public/views/index.html new file mode 100644 index 0000000..5980aef --- /dev/null +++ b/public/views/index.html @@ -0,0 +1,14 @@ + + + + + Smart RMS Schedule + + + + + +

HELLO

+ + + \ No newline at end of file diff --git a/quickstart.js b/quickstart.js new file mode 100644 index 0000000..96b2678 --- /dev/null +++ b/quickstart.js @@ -0,0 +1,131 @@ + + +var fs = require('fs'); +var readline = require('readline'); +var google = require('googleapis'); +var googleAuth = require('google-auth-library'); + +// If modifying these scopes, delete your previously saved credentials +// at ~/.credentials/calendar-nodejs-quickstart.json +var SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']; +var TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH || + process.env.USERPROFILE) + '/.credentials/'; +var TOKEN_PATH = TOKEN_DIR + 'calendar-nodejs-quickstart.json'; + +// Load client secrets from a local file. +fs.readFile('client_secret.json', function processClientSecrets(err, content) { + if (err) { + console.log('Error loading client secret file: ' + err); + return; + } + // Authorize a client with the loaded credentials, then call the + // Google Calendar API. + authorize(JSON.parse(content), listEvents); +}); + +/** + * Create an OAuth2 client with the given credentials, and then execute the + * given callback function. + * + * @param {Object} credentials The authorization client credentials. + * @param {function} callback The callback to call with the authorized client. + */ +function authorize(credentials, callback) { + var clientSecret = credentials.installed.client_secret; + var clientId = credentials.installed.client_id; + var redirectUrl = credentials.installed.redirect_uris[0]; + var auth = new googleAuth(); + var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl); + + // Check if we have previously stored a token. + fs.readFile(TOKEN_PATH, function(err, token) { + if (err) { + getNewToken(oauth2Client, callback); + } else { + oauth2Client.credentials = JSON.parse(token); + callback(oauth2Client); + } + }); +} + +/** + * Get and store new token after prompting for user authorization, and then + * execute the given callback with the authorized OAuth2 client. + * + * @param {google.auth.OAuth2} oauth2Client The OAuth2 client to get token for. + * @param {getEventsCallback} callback The callback to call with the authorized + * client. + */ +function getNewToken(oauth2Client, callback) { + var authUrl = oauth2Client.generateAuthUrl({ + access_type: 'offline', + scope: SCOPES + }); + console.log('Authorize this app by visiting this url: ', authUrl); + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + rl.question('Enter the code from that page here: ', function(code) { + rl.close(); + oauth2Client.getToken(code, function(err, token) { + if (err) { + console.log('Error while trying to retrieve access token', err); + return; + } + oauth2Client.credentials = token; + storeToken(token); + callback(oauth2Client); + }); + }); +} + +/** + * Store token to disk be used in later program executions. + * + * @param {Object} token The token to store to disk. + */ +function storeToken(token) { + try { + fs.mkdirSync(TOKEN_DIR); + } catch (err) { + if (err.code != 'EEXIST') { + throw err; + } + } + fs.writeFile(TOKEN_PATH, JSON.stringify(token)); + console.log('Token stored to ' + TOKEN_PATH); +} + +/** + * Lists the next 10 events on the user's primary calendar. + * + * @param {google.auth.OAuth2} auth An authorized OAuth2 client. + */ +function listEvents(auth) { + var calendar = google.calendar('v3'); + calendar.events.list({ + auth: auth, + calendarId: 'primary', + timeMin: (new Date()).toISOString(), + maxResults: 10, + singleEvents: true, + orderBy: 'startTime' + }, function(err, response) { + if (err) { + console.log('The API returned an error: ' + err); + return; + } + var events = response.items; + if (events.length == 0) { + console.log('No upcoming events found.'); + } else { + console.log('Upcoming 10 events:'); + for (var i = 0; i < events.length; i++) { + var event = events[i]; + var start = event.start.dateTime || event.start.date; + console.log('%s - %s', start, event.summary); + } + } + }); +} \ No newline at end of file diff --git a/server.js b/server.js new file mode 100644 index 0000000..61e7051 --- /dev/null +++ b/server.js @@ -0,0 +1,45 @@ +var express = require('express') +var bodyParser = require('body-parser') +var yaml_config = require('node-yaml-config') +var busboyBodyParser = require('busboy-body-parser') +var scribe = require('scribe-js')() +var Async = require('async') + +var console = process.console +var app = express() +var router = express.Router() +var config = yaml_config.load(__dirname + '/config/config.yml') + +var url = config.server.url +var port = config.server.port + +app.use(bodyParser.urlencoded({ + extended: false +})) +app.use(bodyParser.json()) +app.use(express.static('public')) +app.use(express.static('bower_components')) + +var home = require('./app/routes/home.routes') + +app.set('views', './public/views') +app.set('view engine', 'html') +app.engine('html', require('ejs').renderFile) + +app.use(function (req, res, next) { + res.header('Access-Control-Allow-Origin', '*') + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') + next() +}) + +app.use('/', home) + +app.use(scribe.express.logger()) // Log each request +app.use('/logs', scribe.webPanel()) + +app.use(busboyBodyParser()) + +app.listen(port) +// console.log('Server is running at http://'+url+':'+port+''); + +console.tag('START').time().file().log('Server is running at http://' + url + ':' + port) \ No newline at end of file -- libgit2 0.21.2