This commit is contained in:
garrettmills 2020-02-07 19:50:10 -06:00
commit 0a97c59169
42 changed files with 3961 additions and 0 deletions

90
.gitignore vendored Normal file
View 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
View File

@ -0,0 +1,7 @@
Copyright 2019 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.

60
README.md Normal file
View File

@ -0,0 +1,60 @@
<p align="center"><img height="200" src="https://static.glmdev.tech/flitter/flitter-big.png"></p>
# Flitter
Flitter is a quick & ligthweight web app framework based on Express.
### What?
Flitter is an MVC style framework that aims to get you up and running faster by providing a structure and a wrapper for Express.js. Files in predictable directories are parsed into routes, middleware, controllers, models, and views.
Flitter provides access to the Express app, while making it possible to create an app without needing to piece together the Express framework.
### Flitter Provides:
- Express for routing
- Mongoose for ODM
- Busboy for request parsing
- Favicon support
- `./flitter` - CLI tools for Flitter (including an interactive shell)
- User auth & sessions (see below)
### How?
Getting started with Flitter is easy. To create a new project, simply run the following commands:
```
# Download Flitter:
git clone https://git.glmdev.tech/flitter/flitter {project_name}
cd {project_name}
# Install dependencies:
yarn install
# Create default config:
cp example.env .env
# Launch Flitter!
node index.js
# Or use the interactive shell
./flitter shell
```
And voilà! You should have a Flitter app up and running on port `8000` by default.
### Why?
Flitter's creator is a former Laravel junkie, but loves Node and Express. He got tired of having to hammer out the same 500 lines of code to start every project, but didn't want the bulk and obfuscation of larger frameworks like AdonisJS.
Flitter is designed to be compartmentalized and easy to understand. Every piece of its core functionality is broken into "units." Each of these units does some task like loading config, parsing middleware, connecting to the database, etc. You can see exactly what units your application is loading by viewing the Units file in `config/Units.flitter.js`. Each of Flitters core units are open to view in the [libflitter](https://www.npmjs.com/package/libflitter) package.
Of course, this also means that Flitter is extremely easy to extend. If you want to add a custom package, simply require it and add its unit to the Units file!
### Who?
Flitter was created by [Garrett Mills](https://glmdev.tech/), and its use is governed by the terms of the MIT License as specified in the LICENSE file.
Of course, that does mean that Flitter is © 2019 Garrett Mills. ;)
This command will copy the necessary files to your Flitter install. The files are directly accessible and, therefore, completely customizable.

88
Units.flitter.js Normal file
View File

@ -0,0 +1,88 @@
/*
* 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.
*/
'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
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,25 @@
const Controller = require('libflitter/controller/Controller')
/*
* 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})
}
}
module.exports = Home

View File

@ -0,0 +1,31 @@
const Model = require('flitter-orm/src/model/Model')
/*
* 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.
* @returns {object}
*/
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

17
app/routing/Middleware.js Normal file
View File

@ -0,0 +1,17 @@
/*
* 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 = [
// 'MiddlewareName',
]
module.exports = exports = Middleware

View File

@ -0,0 +1,31 @@
/*
* 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 global mw() function.
*/
const Middleware = require('libflitter/middleware/Middleware')
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

View File

@ -0,0 +1,40 @@
/*
* 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:
* _flitter.mw('util:Config', {
* key: 'server.environment',
* value: 'development'
* })
*
* In this case, the request would be allowed to proceed in the case:
* _flitter.config('server.environment') === 'development'
*
* The 'value' attribute is optional. If none is provided, the request
* can proceed if the config value is truthy.
*/
const Middleware = require('libflitter/middleware/Middleware')
class Config extends Middleware {
static get services() {
return [...super.services, 'configs']
}
/*
* 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 ) return res.error(404)
else if ( args.value && args.value !== config ) return res.error(404)
else return next()
}
}
module.exports = Config

View File

@ -0,0 +1,63 @@
/*
* 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 exec() method.
*/
middleware: [
['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: {
},
}
module.exports = exports = index

7
app/views/errors/400.pug Normal file
View File

@ -0,0 +1,7 @@
extends error
block head
title Bad Request | Flitter
block message
p.flitter-name 400: Bad Request

7
app/views/errors/401.pug Normal file
View File

@ -0,0 +1,7 @@
extends error
block head
title Access Denied | Flitter
block message
p.flitter-name 401: Access Denied

7
app/views/errors/403.pug Normal file
View File

@ -0,0 +1,7 @@
extends error
block head
title Forbidden | Flitter
block message
p.flitter-name 403: Forbidden

7
app/views/errors/404.pug Normal file
View File

@ -0,0 +1,7 @@
extends error
block head
title Not Found | Flitter
block message
p.flitter-name 404: Not Found

9
app/views/errors/418.pug Normal file
View File

@ -0,0 +1,9 @@
extends error
block head
title I'm a Teapot | 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
View File

@ -0,0 +1,7 @@
extends error
block head
title Internal Server Error | Flitter
block message
p.flitter-name 500: Internal Server Error

View File

@ -0,0 +1,47 @@
html
head
title Uh-Oh! | 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)]

View 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
View File

@ -0,0 +1,46 @@
html
head
title Flitter
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") powered by flitter
if user
.flitter-container
p.flitter-text Welcome, #{user.uid}! <a href="/auth/logout">Log out.</a>
else
.flitter-container
p.flitter-text New to Flitter? <a href="https://flitter.garrettmills.dev/" target="_blank">Start here.</a>

17
config/app.config.js Normal file
View File

@ -0,0 +1,17 @@
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/"),
}
module.exports = app_config

34
config/database.config.js Normal file
View 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

61
config/server.config.js Normal file
View File

@ -0,0 +1,61 @@
const server_config = {
/*
* The server port.
* Currently, Flitter supports HTTP 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", 1)
},
session: {
/*
* The secret used to encrypt the session.
* This should be set in the environment.
*/
secret: env("SECRET", "changeme")
},
uploads: {
/*
* Used by flitter-upload. Path for uploaded files.
* Should be relative to the application root.
*/
destination: './uploads'
},
ssl: {
enable: (env("SSL_ENABLE") ? (env("SSL_ENABLE") === 'true') : 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

21
docker-compose.yml Normal file
View File

@ -0,0 +1,21 @@
version: "3"
services:
db:
image: mongo:latest
container_name: db
ports:
- 27017:27017
volumes:
- dbdata1:/data
web:
image: node:11.14-stretch
command: bash -c "cd /opt/flitterapp && yarn install && ./flitter up"
depends_on:
- db
ports:
- 8000:8000
volumes:
- ./:/opt/flitterapp
volumes:
dbdata1:
driver: local

17
docker.env Normal file
View File

@ -0,0 +1,17 @@
APP_NAME=Flitter
APP_URL=http://localhost:8000/
SERVER_PORT=8000
LOGGING_LEVEL=1
DATABASE_HOST=db
DATABASE_PORT=27017
DATABASE_NAME=flitter
DATABASE_AUTH=false
SECRET=changeme
ENVIRONMENT=production
SSL_ENABLE=false
SSL_CERT_FILE=cert.pem
SSL_CERT_KEY=cert.key

17
example.env Normal file
View File

@ -0,0 +1,17 @@
APP_NAME=Flitter
APP_URL=http://localhost:8000/
SERVER_PORT=8000
LOGGING_LEVEL=1
DATABASE_HOST=127.0.0.1
DATABASE_PORT=27017
DATABASE_NAME=flitter
DATABASE_AUTH=false
SECRET=changeme
ENVIRONMENT=production
SSL_ENABLE=false
SSL_CERT_FILE=cert.pem
SSL_CERT_KEY=cert.key

37
flaps.json Normal file
View 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"
}
]

1
flaps/auth.json Normal file
View File

@ -0,0 +1 @@
[]

12
flaps/config.json Normal file
View 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
View 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
View 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
View 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
View 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
View 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
View File

@ -0,0 +1,7 @@
[
{
"id": 1555611659,
"name": "move_views_dir_inside_app_dir",
"migratedOn": "2019-09-01T23:27:50.811Z"
}
]

22
flitter Executable file
View File

@ -0,0 +1,22 @@
#!/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 = require('libflitter/app/FlitterApp')
const flitter = new FlitterApp(units)
flitter.run()

27
index.js Normal file
View File

@ -0,0 +1,27 @@
/*
* 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')
/*
* 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 FlitterApp = require('libflitter/app/FlitterApp')
const flitter = new FlitterApp(units)
/*
* 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.
*/
flitter.run()

28
package.json Normal file
View File

@ -0,0 +1,28 @@
{
"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.18.0",
"flitter-cli": "^0.15.2",
"flitter-di": "^0.4.1",
"flitter-flap": "^0.5.2",
"flitter-forms": "^0.8.1",
"flitter-orm": "^0.2.0",
"flitter-upload": "^0.8.0",
"libflitter": "^0.46.2"
}
}

0
uploads/.gitkeep Normal file
View File

2998
yarn.lock Normal file

File diff suppressed because it is too large Load Diff