Initial commit of framework
This commit is contained in:
commit
ad0abe5b84
90
.gitignore
vendored
Normal file
90
.gitignore
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/node
|
||||
# Edit at https://www.gitignore.io/?templates=node
|
||||
|
||||
.idea
|
||||
.idea/*
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# 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 (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# End of https://www.gitignore.io/api/node
|
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2020 Garrett L. Mills.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# EECS 448 - Project 4
|
||||
This is the backend for our fantasy football game
|
89
Units.flitter.js
Normal file
89
Units.flitter.js
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* The Flitter Units File
|
||||
* -------------------------------------------------------------
|
||||
* Flitter uses a unit-chain style initialization system. This means that
|
||||
* individual components of Flitter and its add-ons are specified in order
|
||||
* here. Then, when the app is created, Flitter creates a single functional
|
||||
* chain by passing the next unit to the current unit's loading script. This
|
||||
* launches Flitter with a single function call (FlitterApp.up()) and enables
|
||||
* developers to contextualize Flitter within async or callback functions.
|
||||
*/
|
||||
const FlitterUnits = {
|
||||
|
||||
/*
|
||||
* The Core Flitter Units
|
||||
* -------------------------------------------------------------
|
||||
* These units comprise the core functionality of Flitter. Unless you
|
||||
* really know what you are doing, you should NEVER change them.
|
||||
*/
|
||||
'Canon' : require('libflitter/canon/CanonicalAccessUnit'),
|
||||
'Services' : require('libflitter/services/ServicesUnit'),
|
||||
'Config' : require('libflitter/config/ConfigUnit'),
|
||||
'Utility' : require('libflitter/utility/UtilityUnit'),
|
||||
'Database' : require('libflitter/database/DatabaseUnit'),
|
||||
'Models' : require('libflitter/database/DatabaseModelsUnit'),
|
||||
'Express' : require('libflitter/express/ExpressUnit'),
|
||||
'ViewEngine' : require('libflitter/views/ViewEngineUnit'),
|
||||
|
||||
/*
|
||||
* Pre-Routing Custom Units
|
||||
* -------------------------------------------------------------
|
||||
* Custom units that modify or add functionality that needs to be made
|
||||
* available to the middleware-routing-controller stack.
|
||||
*/
|
||||
'Locale' : require('flitter-i18n/src/LocaleUnit'),
|
||||
'Upload' : require('flitter-upload/UploadUnit'),
|
||||
|
||||
/*
|
||||
* The Core Flitter Units
|
||||
* -------------------------------------------------------------
|
||||
* These units comprise the core functionality of Flitter. Unless you
|
||||
* really know what you are doing, you should NEVER change them.
|
||||
*/
|
||||
'Middleware' : require('libflitter/middleware/MiddlewareUnit'),
|
||||
'Controller' : require('libflitter/controller/ControllerUnit'),
|
||||
'Routing' : require('libflitter/routing/RoutingUnit'),
|
||||
'Static' : require('libflitter/static/StaticUnit'),
|
||||
|
||||
/*
|
||||
* Secondary Flitter Units
|
||||
* -------------------------------------------------------------
|
||||
* These units aren't strictly required for the core functionality of
|
||||
* Flitter, but they enable the use of certain Flitter tools, like the
|
||||
* ./flitter command and its handlers.
|
||||
*/
|
||||
'Forms' : require('flitter-forms/FormsUnit'),
|
||||
'Auth' : require('flitter-auth/AuthUnit'),
|
||||
'Flap' : require('flitter-flap/FlapUnit'),
|
||||
|
||||
/*
|
||||
* Custom Flitter Units
|
||||
* -------------------------------------------------------------
|
||||
* Custom units should be specified here. They will be loaded in order
|
||||
* after the core of Flitter has been initialized.
|
||||
*/
|
||||
// 'CustomUnit' : new CustomUnit(),
|
||||
|
||||
/*
|
||||
* HTTP Error Handling
|
||||
* -------------------------------------------------------------
|
||||
* This unit provides default routes for invalid requests and tags them as
|
||||
* 404 errors. It also provides middleware to display error views according
|
||||
* to their HTTP status code. This allows for custom views which are located
|
||||
* in views/errors/.
|
||||
*/
|
||||
'Error' : require('libflitter/errors/ErrorUnit'),
|
||||
|
||||
/*
|
||||
* The Flitter App Unit
|
||||
* -------------------------------------------------------------
|
||||
* This should ALWAYS be the last unit to run. The app unit contains the
|
||||
* call to the Node HTTP server that launches Flitter. Units listed after
|
||||
* the app unit are in an lower context than the Flitter app and therefore
|
||||
* won't be available to Flitter or the underlying Express framework.
|
||||
*/
|
||||
'Cli' : require('flitter-cli/CliUnit'),
|
||||
'App' : require('libflitter/app/AppUnit'),
|
||||
}
|
||||
|
||||
module.exports = exports = FlitterUnits
|
0
app/assets/.gitkeep
Normal file
0
app/assets/.gitkeep
Normal file
BIN
app/assets/favicon.ico
Normal file
BIN
app/assets/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
app/assets/flitter.png
Normal file
BIN
app/assets/flitter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
28
app/controllers/Home.controller.js
Normal file
28
app/controllers/Home.controller.js
Normal file
@ -0,0 +1,28 @@
|
||||
const { Controller } = require('libflitter')
|
||||
|
||||
/*
|
||||
* Home Controller
|
||||
* -------------------------------------------------------------
|
||||
* Controller for the main homepage of this Flitter app. Methods here
|
||||
* are used as handlers for routes specified in the route files.
|
||||
*/
|
||||
class Home extends Controller {
|
||||
|
||||
/*
|
||||
* Serve the main welcome page.
|
||||
*/
|
||||
welcome(req, res){
|
||||
|
||||
/*
|
||||
* Return the welcome view.
|
||||
* The page() method is added by Flitter and passes some
|
||||
* helpful contextual data to the view as well.
|
||||
*/
|
||||
return res.page('welcome', {
|
||||
user: req.user,
|
||||
T: req.T,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Home
|
30
app/models/Example.model.js
Normal file
30
app/models/Example.model.js
Normal file
@ -0,0 +1,30 @@
|
||||
const { Model } = require('flitter-orm')
|
||||
|
||||
/*
|
||||
* Example Model
|
||||
* -------------------------------------------------------------
|
||||
* This is a sample model. The schema or structure of the model should
|
||||
* be specified here. It is then passed to flitter-orm and can be accessed
|
||||
* globally using the canonical models service.
|
||||
*/
|
||||
class Example extends Model {
|
||||
static get services() {
|
||||
return [...super.services, 'output']
|
||||
}
|
||||
|
||||
/*
|
||||
* Define the flitter-orm schema of the model.
|
||||
*/
|
||||
static get schema() {
|
||||
return {
|
||||
name: String,
|
||||
create_date: {type: Date, default: () => new Date},
|
||||
}
|
||||
}
|
||||
|
||||
log_name() {
|
||||
this.output.info(`[Example Model] ${this.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Example
|
18
app/routing/Middleware.js
Normal file
18
app/routing/Middleware.js
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Global Middleware Definitions
|
||||
* -------------------------------------------------------------
|
||||
* These middleware are applied, in order, before every request that
|
||||
* Flitter handles, regardless of request type. Each middleware class
|
||||
* can be referenced using the middleware's Flitter canonical name.
|
||||
*
|
||||
* Route-specific middleware should be specified in the corresponding
|
||||
* routes file.
|
||||
*/
|
||||
const Middleware = [
|
||||
|
||||
// Injects the RequestLocalizationHelper
|
||||
"i18n:Localize",
|
||||
|
||||
]
|
||||
|
||||
module.exports = exports = Middleware
|
32
app/routing/middleware/HomeLogger.middleware.js
Normal file
32
app/routing/middleware/HomeLogger.middleware.js
Normal file
@ -0,0 +1,32 @@
|
||||
const { Middleware } = require('libflitter')
|
||||
|
||||
/*
|
||||
* HomeLogger Middleware
|
||||
* -------------------------------------------------------------
|
||||
* This is a sample middleware. It simply prints a console message when
|
||||
* the route that it is tied to is accessed. By default, it is called if
|
||||
* the '/' route is accessed. It can be injected in routes globally using
|
||||
* the middlewares service.
|
||||
*/
|
||||
class HomeLogger extends Middleware {
|
||||
static get services() {
|
||||
return [...super.services, 'output']
|
||||
}
|
||||
|
||||
/*
|
||||
* Run the middleware test.
|
||||
* This method is required by all Flitter middleware.
|
||||
* It should either call the next function in the stack,
|
||||
* or it should handle the response accordingly.
|
||||
*/
|
||||
test(req, res, next, args) {
|
||||
this.output.debug('Home was accessed!')
|
||||
|
||||
/*
|
||||
* Call the next function in the stack.
|
||||
*/
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HomeLogger
|
7
app/routing/middleware/i18n/Localize.middleware.js
Normal file
7
app/routing/middleware/i18n/Localize.middleware.js
Normal file
@ -0,0 +1,7 @@
|
||||
const Middleware = require('flitter-i18n/src/middleware/Localize')
|
||||
|
||||
class LocalizeMiddleware extends Middleware {
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = LocalizeMiddleware
|
7
app/routing/middleware/i18n/Scope.middleware.js
Normal file
7
app/routing/middleware/i18n/Scope.middleware.js
Normal file
@ -0,0 +1,7 @@
|
||||
const Middleware = require('flitter-i18n/src/middleware/Scope')
|
||||
|
||||
class ScopeMiddleware extends Middleware {
|
||||
|
||||
}
|
||||
|
||||
module.exports = exports = ScopeMiddleware
|
43
app/routing/middleware/util/Config.middleware.js
Normal file
43
app/routing/middleware/util/Config.middleware.js
Normal file
@ -0,0 +1,43 @@
|
||||
const { Middleware } = require('libflitter')
|
||||
|
||||
/*
|
||||
* Config Middleware
|
||||
* -------------------------------------------------------------
|
||||
* Checks the specified configuration key (and optionally the value).
|
||||
* If the configuration matches the required value, the request can
|
||||
* proceed. Otherwise, a 404 will be returned.
|
||||
*
|
||||
* To use, add the call to your route's middleware:
|
||||
*
|
||||
* ['middleware::util:Config', {key: 'server.ssl.test', value: true}],
|
||||
*
|
||||
* In this case, the request would be allowed to proceed in the case:
|
||||
* services.configs.get('server.ssl.test') === true
|
||||
*
|
||||
* The 'value' attribute is optional. If none is provided, the request
|
||||
* can proceed if the config value is truthy.
|
||||
*/
|
||||
class Config extends Middleware {
|
||||
static get services() {
|
||||
return [...super.services, 'configs', 'output']
|
||||
}
|
||||
|
||||
/*
|
||||
* Run the middleware test.
|
||||
*/
|
||||
test(req, res, next, args = {}){
|
||||
if ( !args.key ) return res.error(500)
|
||||
|
||||
const config = this.configs.get(args.key)
|
||||
|
||||
if ( !args.value && !config ) {
|
||||
if ( !config && typeof config === 'undefined' )
|
||||
this.output.warn(`util:Config middleware check failed because it tried to access a config that doesn't exist. (${key})`)
|
||||
return res.error(404)
|
||||
}
|
||||
else if ( args.value && args.value !== config ) return res.error(404)
|
||||
else return next()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Config
|
71
app/routing/routers/index.routes.js
Normal file
71
app/routing/routers/index.routes.js
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Index Routes
|
||||
* -------------------------------------------------------------
|
||||
* This is a sample routes file. Routes and their handlers should be
|
||||
* defined here, but no logic should occur.
|
||||
*/
|
||||
const index = {
|
||||
|
||||
/*
|
||||
* Define the prefix applied to each of these routes.
|
||||
* For example, if prefix is '/auth':
|
||||
* '/' becomes '/auth'
|
||||
* '/login' becomes '/auth/login'
|
||||
*/
|
||||
prefix: '/',
|
||||
|
||||
/*
|
||||
* Define middleware that should be applied to all
|
||||
* routes defined in this file. Middleware should be
|
||||
* included using its non-prefixed canonical name.
|
||||
*
|
||||
* You can pass arguments along to a middleware by
|
||||
* specifying it as an array where the first element
|
||||
* is the canonical name of the middleware and the
|
||||
* second element is the argument passed to the
|
||||
* handler's test() method.
|
||||
*/
|
||||
middleware: [
|
||||
// Sets the locale scope
|
||||
['i18n:Scope', {scope: 'common'}],
|
||||
|
||||
['HomeLogger', {note: 'arguments can be specified as the second element in this array'}],
|
||||
// 'MiddlewareName', // Or without arguments
|
||||
],
|
||||
|
||||
/*
|
||||
* Define GET routes.
|
||||
* These routes are registered as GET methods.
|
||||
* Handlers for these routes should be specified as
|
||||
* an array of canonical references to controller methods
|
||||
* or middleware that are applied in order.
|
||||
*/
|
||||
get: {
|
||||
// handlers should be a list of either controller:: or middleware:: references
|
||||
// e.g. middleware::HomeLogger
|
||||
// e.g. controller::Home.welcome
|
||||
'/': [
|
||||
'controller::Home.welcome'
|
||||
],
|
||||
|
||||
// Placeholder for auth dashboard. You'd replace this with
|
||||
// your own route protected by 'middleware::auth:UserOnly'
|
||||
'/dash': [ 'controller::Home.welcome' ],
|
||||
},
|
||||
|
||||
/*
|
||||
* Define POST routes.
|
||||
* These routes are registered as POST methods.
|
||||
* Handlers for these routes should be specified as
|
||||
* an array of canonical references to controller methods
|
||||
* or middleware that are applied in order.
|
||||
*/
|
||||
post: {
|
||||
|
||||
},
|
||||
|
||||
// You can include other HTTP verbs here.
|
||||
// Supported ones are: get, post, put, delete, copy, patch
|
||||
}
|
||||
|
||||
module.exports = exports = index
|
7
app/views/errors/400.pug
Normal file
7
app/views/errors/400.pug
Normal file
@ -0,0 +1,7 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title Bad Request | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name 400: Bad Request
|
7
app/views/errors/401.pug
Normal file
7
app/views/errors/401.pug
Normal file
@ -0,0 +1,7 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title Access Denied | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name 401: Access Denied
|
7
app/views/errors/403.pug
Normal file
7
app/views/errors/403.pug
Normal file
@ -0,0 +1,7 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title Forbidden | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name 403: Forbidden
|
7
app/views/errors/404.pug
Normal file
7
app/views/errors/404.pug
Normal file
@ -0,0 +1,7 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title Not Found | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name 404: Not Found
|
9
app/views/errors/418.pug
Normal file
9
app/views/errors/418.pug
Normal file
@ -0,0 +1,9 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title I'm a Teapot | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name
|
||||
a(href='https://en.wikipedia.org/wiki/HTTP_418') 418: I'm a Teapot
|
||||
p.flitter-name Thank you for using Flitter. How'd you get here, anyway?
|
7
app/views/errors/500.pug
Normal file
7
app/views/errors/500.pug
Normal file
@ -0,0 +1,7 @@
|
||||
extends error
|
||||
|
||||
block head
|
||||
title Internal Server Error | #{_app ? _app.name : 'Flitter'}
|
||||
|
||||
block message
|
||||
p.flitter-name 500: Internal Server Error
|
47
app/views/errors/development.pug
Normal file
47
app/views/errors/development.pug
Normal file
@ -0,0 +1,47 @@
|
||||
html
|
||||
head
|
||||
title Uh-Oh! | #{_app ? _app.name : 'Flitter'}
|
||||
style(type="text/css").
|
||||
@import url('https://fonts.googleapis.com/css?family=Rajdhani');
|
||||
@import url('https://fonts.googleapis.com/css?family=Oxygen+Mono');
|
||||
html,
|
||||
body {
|
||||
background-color: #c7dbdf;
|
||||
font-family: "Rajdhani",sans-serif;
|
||||
padding-left: 2%;
|
||||
padding-top: 2%;
|
||||
}
|
||||
p {
|
||||
font-family: "Oxygen Mono",sans-serif;
|
||||
font-size: 14pt;
|
||||
}
|
||||
body
|
||||
h1 Error: #{error ? error.message : (message ? message : 'An unknown error has occurred.')}
|
||||
h3 Status: #{error ? error.status : (status ? status : 500)}
|
||||
h4#errmsg
|
||||
if error
|
||||
p !{error.stack.replace(/\n/g, '<br>')}
|
||||
|
||||
script.
|
||||
const errors = [
|
||||
'Insert your Windows installation disc and restart your computer.',
|
||||
'I am a teapot.',
|
||||
'Printing not supported on this printer.',
|
||||
'Keyboard not found. Press F1 to continue.',
|
||||
'Bailing out. You\'re on your own. Good luck.',
|
||||
'A team of highly trained monkeys is on its way.',
|
||||
'Well.... something happened.',
|
||||
'Beats the hell out of me, but something went wrong.',
|
||||
'Yeaaaaah... if you could, like, not, that\'d be great.',
|
||||
'I\'m fine. Everything is fine.',
|
||||
'Blocked by Windows Parental Controls.',
|
||||
'This is not the bug you\'re looking for.',
|
||||
'Houston, we have a problem.',
|
||||
'I don\'t think we\'re in Kansas anymore...',
|
||||
'Please enable ActiveX to continue. ;)',
|
||||
'Your PC ran into a wall.',
|
||||
'Are you on drugs?',
|
||||
'Error: Success',
|
||||
]
|
||||
|
||||
document.getElementById('errmsg').innerHTML = errors[Math.floor(Math.random()*errors.length)]
|
33
app/views/errors/error.pug
Normal file
33
app/views/errors/error.pug
Normal file
@ -0,0 +1,33 @@
|
||||
html
|
||||
head
|
||||
block head
|
||||
style(type="text/css").
|
||||
@import url('https://fonts.googleapis.com/css?family=Rajdhani');
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
overflow-y: hidden;
|
||||
background-color: #c7dbdf;
|
||||
}
|
||||
|
||||
.flitter-container {
|
||||
height: 60%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flitter-image {
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.flitter-name {
|
||||
font-family: "Rajdhani";
|
||||
font-size: 50pt;
|
||||
margin-left: 35px;
|
||||
color: #00323d;
|
||||
}
|
||||
body
|
||||
.flitter-container
|
||||
img.flitter-image(src="/assets/flitter.png")
|
||||
block message
|
46
app/views/welcome.pug
Normal file
46
app/views/welcome.pug
Normal file
@ -0,0 +1,46 @@
|
||||
html
|
||||
head
|
||||
title #{T('welcome')} | #{_app.name}
|
||||
style(type="text/css").
|
||||
@import url('https://fonts.googleapis.com/css?family=Rajdhani');
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
overflow-y: hidden;
|
||||
background-color: #c7dbdf;
|
||||
}
|
||||
|
||||
.flitter-container {
|
||||
height: 60%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flitter-image {
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.flitter-name {
|
||||
font-family: "Rajdhani";
|
||||
font-size: 50pt;
|
||||
margin-left: 35px;
|
||||
color: #00323d;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.flitter-text {
|
||||
font-family: "Rajdhani";
|
||||
font-size: 24pt;
|
||||
color: #00323d;
|
||||
}
|
||||
body
|
||||
.flitter-container
|
||||
img.flitter-image(src="/assets/flitter.png")
|
||||
a.flitter-name(href="https://flitter.garrettmills.dev/" target="_blank") #{T('powered_by_flitter')}
|
||||
if user
|
||||
.flitter-container
|
||||
p.flitter-text #{T('welcome')}, #{user.uid}! <a href="/auth/logout">#{T('log_out')}</a>
|
||||
else
|
||||
.flitter-container
|
||||
p.flitter-text #{T('new_to_flitter')} <a href="https://flitter.garrettmills.dev/" target="_blank">#{T('start_here')}</a>
|
21
config/app.config.js
Normal file
21
config/app.config.js
Normal file
@ -0,0 +1,21 @@
|
||||
const app_config = {
|
||||
|
||||
/*
|
||||
* The name of the application.
|
||||
* Used through-out the application as the proper display name.
|
||||
*/
|
||||
name: env('APP_NAME', 'Flitter'),
|
||||
|
||||
/*
|
||||
* URL of the application.
|
||||
* Can be used to generate fully-qualified links.
|
||||
*/
|
||||
url: env('APP_URL', 'http://localhost:8000/'),
|
||||
|
||||
/*
|
||||
* The default locale that new users to the site will be assigned.
|
||||
*/
|
||||
default_locale: env('APP_DEFAULT_LOCALE', 'en_US'),
|
||||
}
|
||||
|
||||
module.exports = app_config
|
34
config/database.config.js
Normal file
34
config/database.config.js
Normal file
@ -0,0 +1,34 @@
|
||||
const database_config = {
|
||||
|
||||
/*
|
||||
* The name of the database.
|
||||
*/
|
||||
name: env('DATABASE_NAME', 'flitter'),
|
||||
|
||||
/*
|
||||
* The hostname of the database server.
|
||||
* Should be fully-qualified or resolvable.
|
||||
*/
|
||||
host: env('DATABASE_HOST', 'localhost'),
|
||||
|
||||
/*
|
||||
* MongoDB port on the database host.
|
||||
*/
|
||||
port: env('DATABASE_PORT', 27017),
|
||||
|
||||
auth: {
|
||||
|
||||
/*
|
||||
* Boolean true if the database connection requires auth.
|
||||
*/
|
||||
require: env('DATABASE_AUTH', false),
|
||||
|
||||
/*
|
||||
* MongoDB username and password.
|
||||
*/
|
||||
username: env('DATABASE_USERNAME', ''),
|
||||
password: env('DATABASE_PASSWORD', ''),
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = database_config
|
93
config/server.config.js
Normal file
93
config/server.config.js
Normal file
@ -0,0 +1,93 @@
|
||||
const server_config = {
|
||||
|
||||
/*
|
||||
* The server port.
|
||||
* Currently, Flitter supports HTTP/S natively.
|
||||
*/
|
||||
port: env('SERVER_PORT', 80),
|
||||
|
||||
/*
|
||||
* The type of environment the application is running in.
|
||||
* Usually, either "production" or "development".
|
||||
* Development mode may cause the application to output extra
|
||||
* debugging information not secure enough for production.
|
||||
*/
|
||||
environment: env('ENVIRONMENT', 'production'),
|
||||
|
||||
logging: {
|
||||
|
||||
/*
|
||||
* The logging level. Usually, 1-4.
|
||||
* The higher the level, the more information is logged.
|
||||
*/
|
||||
level: env('LOGGING_LEVEL', 2),
|
||||
|
||||
/*
|
||||
* If true, API responses will be logged to the database.
|
||||
*/
|
||||
api_logging: env('LOG_API_RESPONSES', false),
|
||||
|
||||
/*
|
||||
* If true, caught request errors will be logged to the database.
|
||||
*/
|
||||
error_logging: env('LOG_REQUEST_ERRORS', true),
|
||||
},
|
||||
|
||||
session: {
|
||||
|
||||
/*
|
||||
* The secret used to encrypt the session.
|
||||
* This should be set in the environment.
|
||||
*/
|
||||
secret: env('SECRET', 'changeme'),
|
||||
|
||||
/*
|
||||
* The max age (in milliseconds) of the session cookie.
|
||||
* If undefined, the max-age will be set to "Session" so it is
|
||||
* cleared when the browser exits.
|
||||
*/
|
||||
max_age: env('SESSION_MAX_AGE', undefined),
|
||||
},
|
||||
|
||||
uploads: {
|
||||
/*
|
||||
* If true, the server will accept files uploaded in the request.
|
||||
*/
|
||||
enable: env('SERVER_ENABLE_UPLOADS', false),
|
||||
|
||||
/*
|
||||
* Regex to match routes that file uploads are accepted from.
|
||||
* By default, this accepts files uploaded on all routes.
|
||||
*/
|
||||
allowed_path: /./,
|
||||
|
||||
/*
|
||||
* Path for uploaded files.
|
||||
* Should be relative to the application root.
|
||||
*
|
||||
* Note that this is NOT the config for flitter-upload.
|
||||
*/
|
||||
destination: './tmp.uploads'
|
||||
},
|
||||
|
||||
ssl: {
|
||||
/*
|
||||
* If true, the server will be HTTPS, not HTTP.
|
||||
*/
|
||||
enable: env('SSL_ENABLE', false),
|
||||
|
||||
/*
|
||||
* Path to your domain's certificate file.
|
||||
* This should contain any intermediate certificates as well.
|
||||
*/
|
||||
cert_file: env('SSL_CERT_FILE', 'cert.pem'),
|
||||
|
||||
/*
|
||||
* Path to your domain's certificate key.
|
||||
*/
|
||||
key_file: env('SSL_KEY_FILE', 'cert.key'),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
module.exports = server_config
|
33
example.env
Normal file
33
example.env
Normal file
@ -0,0 +1,33 @@
|
||||
APP_NAME=Flitter
|
||||
APP_URL=http://localhost:8000/
|
||||
|
||||
SERVER_PORT=8000
|
||||
|
||||
# 1 - Error/Success
|
||||
# 2 - Warning
|
||||
# 3 - Message
|
||||
# 4 - Info
|
||||
# 5 - Debug
|
||||
LOGGING_LEVEL=2
|
||||
|
||||
DATABASE_HOST=127.0.0.1
|
||||
DATABASE_PORT=27017
|
||||
DATABASE_NAME=flitter
|
||||
|
||||
# if true, specify DATABASE_USERNAME and DATABASE_PASSWORD
|
||||
DATABASE_AUTH=false
|
||||
|
||||
# used to hash passwords and session keys
|
||||
# should be randomly generated - require('uuid/v4')()
|
||||
SECRET=changeme
|
||||
|
||||
# production | development
|
||||
# if development, errors are displayed in detail
|
||||
ENVIRONMENT=production
|
||||
|
||||
# if true, the Express.js server will use the SSL
|
||||
# certificate and key in the file to answer HTTPS
|
||||
# requests on the specified port
|
||||
SSL_ENABLE=false
|
||||
SSL_CERT_FILE=cert.pem
|
||||
SSL_KEY_FILE=cert.key
|
37
flaps.json
Normal file
37
flaps.json
Normal file
@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"id": 1555000000,
|
||||
"name": "create_flaps_json_file",
|
||||
"migratedOn": "2019-04-12T17:26:34.522Z"
|
||||
},
|
||||
{
|
||||
"id": 1555611659,
|
||||
"name": "move_views_dir_inside_app_dir",
|
||||
"migratedOn": "2019-04-18T19:24:16.741Z"
|
||||
},
|
||||
{
|
||||
"id": 1556469759,
|
||||
"name": "create_docker_env_file",
|
||||
"migratedOn": "2019-04-28T16:49:11.238Z"
|
||||
},
|
||||
{
|
||||
"id": 1560988609,
|
||||
"name": "move_database_unit_before_express_unit",
|
||||
"migratedOn": "2019-06-21T00:31:38.019Z"
|
||||
},
|
||||
{
|
||||
"id": 1565741502,
|
||||
"name": "convert_to_new_model_schema_definitions",
|
||||
"migratedOn": "2019-08-16T01:22:01.971Z"
|
||||
},
|
||||
{
|
||||
"id": 1565925593,
|
||||
"name": "make_existing_middleware_extend_base_class",
|
||||
"migratedOn": "2019-08-18T16:07:56.112Z"
|
||||
},
|
||||
{
|
||||
"id": 1566420176,
|
||||
"name": "add_ssl_to_server_config",
|
||||
"migratedOn": "2019-08-21T21:30:49.802Z"
|
||||
}
|
||||
]
|
7
flaps/README.md
Normal file
7
flaps/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
Flitter-Flap is an experimental code migration tool. It's goal is to write migrations for your codebase itself. That way, when core libraries like Flitter are updated, breaking changes can be accounted for in the migrations.
|
||||
|
||||
It's still a work in progress, so use it with caution. Try `node flitter flap` to get started. Migrations are provided by library packages. Each library package gets its own `.json` file in this directory to keep track of the migrations that have been applied.
|
||||
|
||||
Unless you really know what you're doing, you shouldn't modify these files. Otherwise, Flap might try to migrate something twice, or skip a migration.
|
||||
|
||||
https://flitter.garrettmills.dev/tutorial-getting-started-6.html
|
1
flaps/auth.json
Normal file
1
flaps/auth.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
12
flaps/config.json
Normal file
12
flaps/config.json
Normal file
@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"id": 1566420176,
|
||||
"name": "add_ssl_to_server_config",
|
||||
"migratedOn": "2019-09-01T23:27:50.764Z"
|
||||
},
|
||||
{
|
||||
"id": 1567371806,
|
||||
"name": "use_new_env_fetch_function",
|
||||
"migratedOn": "2019-09-01T23:55:55.366Z"
|
||||
}
|
||||
]
|
12
flaps/database.json
Normal file
12
flaps/database.json
Normal file
@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"id": 1565741502,
|
||||
"name": "convert_to_new_model_schema_definitions",
|
||||
"migratedOn": "2019-09-01T23:27:50.802Z"
|
||||
},
|
||||
{
|
||||
"id": 1567373786,
|
||||
"name": "add_graphql_unit_to_units_file",
|
||||
"migratedOn": "2019-09-01T23:56:19.038Z"
|
||||
}
|
||||
]
|
7
flaps/express.json
Normal file
7
flaps/express.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": 1560988609,
|
||||
"name": "move_database_unit_before_express_unit",
|
||||
"migratedOn": "2019-09-01T23:27:50.805Z"
|
||||
}
|
||||
]
|
7
flaps/flap.json
Normal file
7
flaps/flap.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": 1555000000,
|
||||
"name": "create_flaps_json_file",
|
||||
"migratedOn": "2019-09-01T23:27:50.820Z"
|
||||
}
|
||||
]
|
7
flaps/middleware.json
Normal file
7
flaps/middleware.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": 1565925593,
|
||||
"name": "make_existing_middleware_extend_base_class",
|
||||
"migratedOn": "2019-09-01T23:27:50.814Z"
|
||||
}
|
||||
]
|
7
flaps/utility.json
Normal file
7
flaps/utility.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": 1556469759,
|
||||
"name": "create_docker_env_file",
|
||||
"migratedOn": "2019-09-01T23:27:50.785Z"
|
||||
}
|
||||
]
|
7
flaps/views.json
Normal file
7
flaps/views.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": 1555611659,
|
||||
"name": "move_views_dir_inside_app_dir",
|
||||
"migratedOn": "2019-09-01T23:27:50.811Z"
|
||||
}
|
||||
]
|
23
flitter
Executable file
23
flitter
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
* ./flitter
|
||||
* -------------------------------------------------------------
|
||||
* The ./flitter command is used to interact with Flitter and its tools
|
||||
* in the development environment. Currently, it lends access to Flitter
|
||||
* shell, which is like a Node interactive prompt, but it's launched from
|
||||
* within the same context as the Flitter HTTP server, allowing developers
|
||||
* to interact with Flitter directly.
|
||||
*/
|
||||
const CliAppUnit = require('flitter-cli/CliAppUnit')
|
||||
const units = require('./Units.flitter')
|
||||
|
||||
/*
|
||||
* Replace the HTTP server application target with the CLI handler.
|
||||
*/
|
||||
units.App = CliAppUnit
|
||||
|
||||
const { FlitterApp, RunLevelErrorHandler } = require('libflitter')
|
||||
const flitter = new FlitterApp(units)
|
||||
const rleh = new RunLevelErrorHandler()
|
||||
|
||||
flitter.run().catch(rleh.handle) // calls up() and down()
|
43
index.js
Normal file
43
index.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Load the units file.
|
||||
* -------------------------------------------------------------
|
||||
* This file contains an ordered object of unit files. Flitter will load these
|
||||
* one at a time to launch the application. Each unit in the sequence is passed
|
||||
* the function for the next unit in the sequence. This forms the function stack
|
||||
* by chaining the units together, ending with the Flitter App unit.
|
||||
*/
|
||||
const units = require('./Units.flitter')
|
||||
|
||||
const { FlitterApp, RunLevelErrorHandler } = require('libflitter')
|
||||
|
||||
/*
|
||||
* Create the app.
|
||||
* -------------------------------------------------------------
|
||||
* The FlitterApp object contains the wrapper for the Express app, as well as
|
||||
* the initialization function that chains together the individual units. This
|
||||
* is why we pass it the units.
|
||||
*/
|
||||
const flitter = new FlitterApp(units)
|
||||
|
||||
/*
|
||||
* Create the error handler.
|
||||
* -------------------------------------------------------------
|
||||
* The run-level error handler is responsible for dealing with errors that make
|
||||
* it all the way to the top level of the running app. Most of the time, routing
|
||||
* errors are handled by the router and result in some kind of error page showing
|
||||
* to the user.
|
||||
*
|
||||
* The errors handled by the RLEH are structural errors that are problems with the
|
||||
* application itself.
|
||||
*/
|
||||
const rleh = new RunLevelErrorHandler()
|
||||
|
||||
/*
|
||||
* Launch the server.
|
||||
* -------------------------------------------------------------
|
||||
* This calls the first unit in the unit chain. This chain ends with the Flitter
|
||||
* server component which launches the Node HTTP server.
|
||||
*
|
||||
* Calls up() and down().
|
||||
*/
|
||||
flitter.run().catch(rleh.handle)
|
6
locale/default/common.locale.js
Normal file
6
locale/default/common.locale.js
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Translation phrases common among all locales.
|
||||
*/
|
||||
module.exports = exports = {
|
||||
flitter: 'Flitter',
|
||||
}
|
10
locale/en_US/common.locale.js
Normal file
10
locale/en_US/common.locale.js
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Common phrases. Used by the welcome page.
|
||||
*/
|
||||
module.exports = exports = {
|
||||
welcome: 'Welcome',
|
||||
powered_by_flitter: 'powered by flitter',
|
||||
new_to_flitter: 'New to Flitter?',
|
||||
start_here: 'Start Here.',
|
||||
log_out: 'Log out',
|
||||
}
|
10
locale/es_MX/common.locale.js
Normal file
10
locale/es_MX/common.locale.js
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Common phrases. Used by the welcome page.
|
||||
*/
|
||||
module.exports = exports = {
|
||||
welcome: 'Bienvenido',
|
||||
powered_by_flitter: 'impulsado por flitter',
|
||||
new_to_flitter: '¿Nuevo en Flitter?',
|
||||
start_here: 'Empieza aqui.',
|
||||
log_out: 'Cerrar sesión',
|
||||
}
|
29
package.json
Normal file
29
package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "flitter",
|
||||
"version": "0.1.0",
|
||||
"description": "Flitter is a simple MVC framework wrapper for Express.js.",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.garrettmills.dev/flitter/flitter"
|
||||
},
|
||||
"keywords": [
|
||||
"flitter",
|
||||
"glmdev",
|
||||
"framework",
|
||||
"express"
|
||||
],
|
||||
"author": "Garrett Mills <garrett@glmdev.tech> (https://garrettmills.dev/)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"flitter-auth": "^0.19.1",
|
||||
"flitter-cli": "^0.16.0",
|
||||
"flitter-di": "^0.5.0",
|
||||
"flitter-flap": "^0.5.2",
|
||||
"flitter-forms": "^0.8.1",
|
||||
"flitter-i18n": "^0.1.0",
|
||||
"flitter-orm": "^0.4.0",
|
||||
"flitter-upload": "^0.8.1",
|
||||
"libflitter": "^0.53.0"
|
||||
}
|
||||
}
|
0
tmp.uploads/.gitkeep
Normal file
0
tmp.uploads/.gitkeep
Normal file
0
uploads/.gitkeep
Normal file
0
uploads/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user