Browse Source

refactor for new flitter DI

master
Garrett Mills 3 months ago
parent
commit
6cae91a968
9 changed files with 32 additions and 51 deletions
  1. 4
    5
      Units.flitter.js
  2. 2
    2
      app/MiscUnit.js
  3. 1
    15
      app/models/Greeting.model.js
  4. 0
    13
      app/models/api.graphql
  5. 7
    4
      app/routing/middleware/util/Config.middleware.js
  6. 1
    1
      flitter
  7. 1
    1
      index.js
  8. 2
    2
      package.json
  9. 14
    8
      yarn.lock

+ 4
- 5
Units.flitter.js View File

@@ -31,7 +31,7 @@ const FlitterUnits = {
* Custom units that modify or add functionality that needs to be made
* available to the middleware-routing-controller stack.
*/
'Upload' : require('flitter-upload/UploadUnit'),
// 'Upload' : require('flitter-upload/UploadUnit'),

/*
* The Core Flitter Units
@@ -60,10 +60,9 @@ const FlitterUnits = {
* Flitter, but they enable the use of certain Flitter tools, like the
* ./flitter command and its handlers.
*/
'GraphQL' : require('libflitter/database/GraphQLUnit'),
'Forms' : require('flitter-forms/FormsUnit'),
'Auth' : require('flitter-auth/AuthUnit'),
'Flap' : require('flitter-flap/FlapUnit'),
// 'Forms' : require('flitter-forms/FormsUnit'),
// 'Auth' : require('flitter-auth/AuthUnit'),
// 'Flap' : require('flitter-flap/FlapUnit'),


/*

+ 2
- 2
app/MiscUnit.js View File

@@ -31,8 +31,8 @@ class MiscUnit extends Unit {
* contexts are available here, so things like config(),
* model(), etc. work.
*/
async go(app, context){
await super.go(app, context)
async go(app){
await super.go(app)
// do stuff here

+ 1
- 15
app/models/Greeting.model.js View File

@@ -5,7 +5,7 @@ const Model = require('libflitter/database/Model')
* -------------------------------------------------------------
* This is a sample model. The schema or structure of the model should
* be specified here. It is then passed to Mongoose and can be accessed
* globally using the _flitter.model() function, or FlitterApp.d.models.get().
* globally using the canonical models service.
*/
class Greeting extends Model {

@@ -19,20 +19,6 @@ class Greeting extends Model {
name: String,
}
}

/* GraphQL. TBD.
async greeting(args, request, context) {
const match = await this.findOne({
id: args.id
})
if (match) return match
},

async greetings(args, request, context) {
const matches = await this.find()
return matches
},
*/
}

module.exports = exports = Greeting

+ 0
- 13
app/models/api.graphql View File

@@ -1,13 +0,0 @@
type Query {
# Get a Greeting by name.
greeting(id: String): Greeting,
# Get all greetings.
greetings: [Greeting],
}

# Homepage greeting messages.
type Greeting {
id: String,
name: String,
}

+ 7
- 4
app/routing/middleware/util/Config.middleware.js View File

@@ -19,17 +19,20 @@
*/
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 _flitter.error(res, 500)
if ( !args.key ) return res.error(500)

const config = this.app.d.config.get(args.key)
const config = this.configs.get(args.key)

if ( !args.value && !config ) return _flitter.error(res, 404)
else if ( args.value && args.value !== config ) return _flitter.error(res, 404)
if ( !args.value && !config ) return res.error(404)
else if ( args.value && args.value !== config ) return res.error(404)
else return next()
}
}

+ 1
- 1
flitter View File

@@ -16,4 +16,4 @@ units['App'] = CliAppUnit
const FlitterApp = require('libflitter/app/FlitterApp')
const flitter = new FlitterApp(units)

flitter.up()
flitter.run()

+ 1
- 1
index.js View File

@@ -24,4 +24,4 @@ const flitter = new FlitterApp(units)
* This calls the first unit in the unit chain. This chain ends with the Flitter
* server component which launches the Node HTTP server.
*/
flitter.up()
flitter.run()

+ 2
- 2
package.json View File

@@ -17,10 +17,10 @@
"license": "MIT",
"dependencies": {
"flitter-auth": "^0.15.1",
"flitter-cli": "^0.12.0",
"flitter-cli": "^0.13.0",
"flitter-flap": "^0.4.3",
"flitter-forms": "^0.7.3",
"flitter-upload": "^0.7.6",
"libflitter": "^0.38.2"
"libflitter": "^0.40.0"
}
}

+ 14
- 8
yarn.lock View File

@@ -971,16 +971,21 @@ flitter-auth@^0.15.1:
uuid "^3.3.2"
validator "^10.11.0"

flitter-cli@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/flitter-cli/-/flitter-cli-0.12.0.tgz#b4c635e60e2327762c659fc3bceae31f467bd62f"
integrity sha512-TLJg9CTRqpwVr/aFhCeg9901VO37lnb0TBZQu6ybcpzrXOKVJr3TIsKjl78I5zLMUnj0p1RrAsXJsQzxy/LMNA==
flitter-cli@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/flitter-cli/-/flitter-cli-0.13.0.tgz#a28f82b1d4e7680c50810541674fbaa1c4afe67f"
integrity sha512-qAD6z2eH6mtlq++TGLilKt1Lvo+yVcVDA2P4OjkpOD6aYxT+EZ2VryII6PTk8XwfJLt72twW/snest0aCxyoFw==
dependencies:
command-line-args "^5.0.2"
es6-promisify "^6.0.1"
mkdirp "^0.5.1"
nesh "^1.7.0"

flitter-di@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/flitter-di/-/flitter-di-0.1.2.tgz#0793606d2b50d7c2f3d430017bf94971c30f2d58"
integrity sha512-EsKxAvcUeyl+/XGe7KAcHK8knEoOVqSSzEUqOxRlCDh/Q5JM9lJPIcr2F/mYcTHuT9bbRrVOqCZwWPjA0BrxSA==

flitter-flap@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/flitter-flap/-/flitter-flap-0.4.0.tgz#ab1cdfc5b9ffe0b5b9fe2e3a8bdc87e9aac82c0e"
@@ -1455,10 +1460,10 @@ leven@^1.0.2:
resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3"
integrity sha1-kUS27ryl8dBoAWnxpncNzqYLdcM=

libflitter@^0.38.2:
version "0.38.2"
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.38.2.tgz#28538d3d6837d450dbec513a36ced15b2481b58a"
integrity sha512-ysli0HRynD8L3wufLIvNvg+VVs4Hg1BQX1bj/VKbLuyyDgzZPBnBc0rxg/Zz0TmOiWP0l1x256daXQuDcLGJOQ==
libflitter@^0.40.0:
version "0.40.0"
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.40.0.tgz#c7c3d03371b3f70be769d6bdc69b02dd0192faea"
integrity sha512-QO0oikmxc7ToLFlOqTLW4sds2Afagip2CJQT8TLstFn9r5LA4ZjKnJoOsct9A6Bhe8Nb8R4MVwQTv6zklzJmSQ==
dependencies:
colors "^1.3.3"
connect-mongodb-session "^2.2.0"
@@ -1469,6 +1474,7 @@ libflitter@^0.38.2:
express-favicon "^2.0.1"
express-graphql "^0.9.0"
express-session "^1.15.6"
flitter-di "^0.1.2"
graphql "^14.5.4"
mongo-schematic-class "^1.0.3"
mongoose "^5.4.13"

Loading…
Cancel
Save