Unverified Commit b706b0ea authored by Mark Stenglein's avatar Mark Stenglein
Browse files

begin move to modular configuration

parent 235cbae8
......@@ -14,8 +14,10 @@ var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var Sequelize = require('sequelize');
// Load site wide configurations
var config = require('./config');
// Load site wide configurations as well as the environment
// TODO: make the actual file an actual json file
var env = process.env.NODE_ENV || "development";
var config = require(path.join(__dirname, '..', 'config', 'config.json'))[env];
// Load in Routes
// TODO: Make this a dynamic loading system that simply scans the directory
......@@ -34,6 +36,7 @@ app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('node-sass-middleware')({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public'),
......
////////////////////////////////////////////////////////////////////////////////
// Mason SRCT: Schedules Main Configuration File
// - This file holds many of the global options for ease of use. Some of these
// settings are temporary because the dynamic methods have not been written in
// yet.
////////////////////////////////////////////////////////////////////////////////
var config = {}
// Application Name
config.siteName = "Schedules";
// Application Description (subtitle)
config.siteDescription = "A simple application to add your class schedule to calendar applications like Outlook and Google Calendar."
config.databaseInformation = {
'databaseName' : 'schedules',
'databaseUser' : 'schedules',
'databasePass' : 'srct',
'host' : 'localhost',
'dialect' : 'mysql',
'pool' : {
'max' : 5,
'min' : 0,
'idle' : 10000
}
}
// Object given to the front end to populate the semester and school selection
// dropdown lists.
// TODO: Make this dynamic instead of hard coding it into the system.
config.schoolSlugs = {
'schools': [
'GMU',
'VT'
],
'GMU': {
'longName': 'George Mason University',
'semesters': [
{
slug: 'GMU2016F',
longName: 'Fall 2016'
},
{
slug: 'GMU2016S',
longName: 'Summer 2016'
},
{
slug: 'GMU2016SP',
longName: 'Spring 2016'
}
]
},
'VT' : {
'longName': 'Virginia Tech',
'semesters': []
},
}
// Data files to load:
// TODO: Make this dynamic instead of hard coding it into the system. This is
// neccessary in order to make it so that the system can be updated from
// the site itself instead of relying on @patriot_down to upload the files
// from the backend.
config.dataFiles = [
'GMU2016F.min.json',
'GMU2016S.min.json',
'GMU2016SP.min.json'
]
module.exports = config;
# Schedules
*By Mason SRCT*
## Configuration Directory
This directory houses all of the various configuration files for the different
modules and sections of the web application. Each file houses a specific set of
settings that is documented here in this `README`.
### schoolSemesters.json
This file stores the names and slugs of all the different schools, semesters,
and data files to be loaded by the database on startup. It is structured as
shown below:
#### Structure
```json
{
// Starts with an array containing the different school slugs, which will
// be used to construct the api section of the application.
"schools": [
"SLUG",
...
]
// Moves on to one object for each individual school, using the given slug
// as the object name (the application uses the array above to reverence
// these objects).
"SLUG" : {
"longName" : "A Fantastic University",
"semesters" : [
{
"slug" : "SLUGYEAR{SP, S, F}",
"longName" : "{Spring, Summer, Fall} YEAR"
},
...
]
},
...,
// Finally defines the names of the datafiles that need to be loaded. The
// SLUG values inside need to match up with those defined in this file,
// or they will be rejected.
"dataFiles" : [
"SLUGYEAR{SP, S, F}.min.json",
...
]
}
```
### sequelize.json
This file stores the configuration settings for the database used by the
application. This file is a bit special because it stores sepeparate configs
for each different environment (dev, testing, and production).
The structure is defined below:
#### Structure
```json
{
// settings for development
"development" : {
// uses sqlite for local development, because it's easy.
"dialect" : "sqlite",
// storage location for the local database. Should be an actual
// file so that it is easy to debug any issues with the db manually
"storage" : "./db.development.sqlite"
},
// settings for testing (via gitlab CI, jenkins, Travis CI, etc)
"test" : {
// uses sqlite for the same reason as the dev environment
"dialect" : "sqlite",
// uses memory, because it's easy. This might become the norm for both
"storage" : ":memory:"
},
// production settings. In the repo, this file is going to stay as is.
// DO NOT CHANGE THIS FILE TO REAL VALUES. In fact, best to just leave
// this file to your sysadmin (unless that's you, of course).
"production" : {
// database username
"username" : "schedules",
// database user password
"password" : "srct",
// database name
"database" : "schedules",
// database host
"host" : "localhost",
// uses mysql because ??? (not sure if this is the final thing to use)
"dialect" : "mysql",
// use a pool of connection clients to keep the site able to handle
// large amounts of traffic to the api.
"pool" : {
"max" : 5,
"min" : 0,
"idle" : 10000
}
}
}
```
### siteInfo.json
This file stores information about the site deployment. In general, this can
stay untouched in version control unless additional variables need to be
tracked. Most of these are going to be branding variables, etc.
Again, the structure is defined below:
#### Structure
```json
{
// Name of the web app (shows on the main page??)
"name" : "Schedules",
// Description of the app (shows to google etc in the metadata for the
// page)
"description" : "A simple application to add your class schedules to calendar applications.",
// Information about the deploying organization (this is the main branding
// section)
"organization" : {
// Name of the deploying org
"name" : "Mason SRCT",
// Longer name of the deploying org
"description": "Student Run Computing and Technology",
// Website text and full URL of the deploying org
"website" : "srct.gmu.edu",
"websiteURL" : "https://srct.gmu.edu"
}
}
```
{
"schools" : [
"GMU",
"VT"
],
"GMU" : {
"longName" : "George Mason University",
"semesters" : [
{
"slug" : "GMU2016SP",
"longName" : "Spring 2016"
},
{
"slug" : "GMU2016S",
"longName" : "Summer 2016"
},
{
"slug" : "GMU2016F",
"longName" : "Fall 2016"
},
{
"slug" : "GMU2017SP",
"longName" : "Spring 2017"
}
]
},
"VT" : {
"longName" : "Virginia Tech",
"semesters" : []
},
"dataFiles" : [
"GMU2016SP.min.json",
"GMU2016S.min.json",
"GMU2016F.min.json",
"GMU2017SP.min.json"
]
}
{
"development" : {
"dialect" : "sqlite",
"storage" : "./db.development.sqlite"
},
"test" : {
"dialect" : "sqlite",
"storage" : ":memory:"
},
"production" : {
"username" : "schedules",
"password" : "srct",
"database" : "schedules",
"host" : "localhost",
"dialect" : "mysql",
"pool" : {
"max" : 5,
"min" : 0,
"idle" : 10000
}
}
}
{
"name" : "Schedules",
"description" : "A simple application to add your class schedules to calendar applications.",
"organization" : {
"name" : "Mason SRCT",
"description": "Student Run Computing and Technology",
"website" : "srct.gmu.edu",
"websiteURL" : "https://srct.gmu.edu"
}
}
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