summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/db.json24
-rw-r--r--examples/index.js33
-rw-r--r--examples/lib/okdumpfm/index.js39
-rw-r--r--examples/lib/okdumpfm/package.json14
-rw-r--r--examples/lib/okexample/index.js49
-rw-r--r--examples/lib/okexample/package.json11
6 files changed, 164 insertions, 6 deletions
diff --git a/examples/db.json b/examples/db.json
index 8805342..401bf26 100644
--- a/examples/db.json
+++ b/examples/db.json
@@ -154,13 +154,21 @@
"title": "Red",
"media": [
{
+ "uri": "https://ltho.s3.amazonaws.com/okcms-example/a91c4210-080c-11e6-8a7d-f30231d4ec26.png",
+ "width": "800",
+ "height": "800",
+ "caption": "",
+ "type": "image"
+ },
+ {
"uri": "http://asdf.us/",
"caption": "ASDF",
"type": "link"
}
],
"__index": 0,
- "dateCreated": "Mon, 28 Mar 2016 23:02:45 GMT"
+ "dateCreated": "Mon, 28 Mar 2016 23:02:45 GMT",
+ "flagged": false
},
{
"id": "blue",
@@ -210,5 +218,19 @@
],
"flagged": true
}
+ ],
+ "flour": [
+ {
+ "id": "test",
+ "title": "TEST",
+ "image": {
+ "uri": "https://ltho.s3.amazonaws.com/okcms-example/7be163d0-080b-11e6-8a7d-f30231d4ec26.png",
+ "caption": "",
+ "width": "800",
+ "height": "800"
+ },
+ "__index": 0,
+ "dateCreated": "Thu, 21 Apr 2016 21:52:44 GMT"
+ }
]
} \ No newline at end of file
diff --git a/examples/index.js b/examples/index.js
index fe37954..341a50b 100644
--- a/examples/index.js
+++ b/examples/index.js
@@ -1,10 +1,13 @@
var okcms = require('..');
+var isProduction = process.env.OK_PRODUCTION === 'true'
+
var app = okcms.createApp({
root: 'public',
- debug: true,
+ debug: !isProduction,
+ production: isProduction,
schemas: {
page: {
@@ -26,6 +29,11 @@ var app = okcms.createApp({
title: {type: 'string'},
flagged: {type: 'flag'},
media: {type: 'media-list'},
+ },
+ flour: {
+ id: {type: 'string', hidden: true},
+ title: {type: 'string'},
+ image: {type: 'image'},
}
},
@@ -34,6 +42,7 @@ var app = okcms.createApp({
{ type: 'page', static: {id: 'contact'}},
{ type: 'bread' },
{ type: 'test' },
+ { type: 'flour' },
],
services: {
@@ -42,10 +51,24 @@ var app = okcms.createApp({
secret: process.env.S3_SECRET,
bucket: process.env.S3_BUCKET,
dirname: "okcms-example",
- // TODO: maxbytes stuff isn't working, need to change underlying module
- image: { preserveFilename: false, maxbytes: 20000 },
- video: { preserveFilename: true, maxbytes: 0 },
- audio: { preserveFilename: true, maxbytes: 150000000 },
+ image: { allowed: true, preserveFilename: false, maxbytes: 2*1024*1024 },
+ video: { allowed: true, preserveFilename: true, maxbytes: 200*1024*1024 },
+ audio: { allowed: true, preserveFilename: true, maxbytes: 100*1024*1024 },
+ },
+
+ webhook: {
+ active: false,
+ secret: 'test',
+ command: '/path/to/build.sh',
+ },
+
+ example: {
+ lib: require("./lib/okexample"),
+ stuff: "things",
+ },
+
+ dumpfm: {
+ lib: require("./lib/okdumpfm"),
}
},
diff --git a/examples/lib/okdumpfm/index.js b/examples/lib/okdumpfm/index.js
new file mode 100644
index 0000000..4dc5461
--- /dev/null
+++ b/examples/lib/okdumpfm/index.js
@@ -0,0 +1,39 @@
+var request = require('request')
+
+/**
+ * Example service which queries the Dump search.
+ */
+function OKDumpfm (options) {
+ if (!(this instanceof OKDumpfm)) return new OKDumpfm(options)
+ options = options || {}
+ if (!options.express)
+ throw new Error('Express not provided to OKDumpfm');
+
+ var express = options.express
+ var router = express.Router()
+
+ router.get('*', function (req, res) {
+ var query = req.query.q
+ request('http://dump.fm/cmd/search/' + query, function (err, response, body) {
+ if (err || response.statusCode !== 200) {
+ res.status(response.statusCode)
+ res.send(err)
+ } else {
+ res.set('Content-Type', 'application/json; charset=utf-8')
+ res.send(body)
+ }
+ })
+ })
+
+ router.post('*', function (req, res) {
+ throw new Error('OKDumpfm POST requests not implemented')
+ })
+
+ this._router = router
+}
+
+OKDumpfm.prototype.middleware = function () {
+ return this._router
+}
+
+module.exports = OKDumpfm
diff --git a/examples/lib/okdumpfm/package.json b/examples/lib/okdumpfm/package.json
new file mode 100644
index 0000000..17bcba2
--- /dev/null
+++ b/examples/lib/okdumpfm/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "okdumpfm",
+ "version": "1.0.0",
+ "description": "service to query the dump search API",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "okfocus <frontdesk@okfoc.us>",
+ "license": "LNT",
+ "dependencies": {
+ "request": "^2.71.0"
+ }
+}
diff --git a/examples/lib/okexample/index.js b/examples/lib/okexample/index.js
new file mode 100644
index 0000000..04c5984
--- /dev/null
+++ b/examples/lib/okexample/index.js
@@ -0,0 +1,49 @@
+
+/**
+ * Example service to show how these things should be set up.
+ *
+ * Services should be added to index.js in the proper area,
+ * with any configuration parameters that you want passed in:
+ *
+ * services: {
+ * example: {
+ * lib: require("./lib/okexample"),
+ * stuff: "things",
+ * }
+ * },
+ *
+ * The service will be mounted on /_services/example
+ *
+ * This binds to route '*' but you can specify e.g. "/thing",
+ * and it will be mounted on /_services/example/thing
+ */
+
+function OKExample (options) {
+ if (!(this instanceof OKExample)) return new OKExample(options)
+ options = options || {}
+ if (!options.express)
+ throw new Error('Express not provided to OKExample');
+ if (!options.config)
+ throw new Error('Configuration not provided to OKExample');
+
+ var express = options.express
+ var router = express.Router()
+ var config = options.config
+ var db = options.db
+
+ router.get('*', function (req, res) {
+ res.send(config.stuff)
+ })
+
+ router.post('*', function (req, res) {
+ throw new Error('OKExample POST requests not implemented')
+ })
+
+ this._router = router
+}
+
+OKExample.prototype.middleware = function () {
+ return this._router
+}
+
+module.exports = OKExample
diff --git a/examples/lib/okexample/package.json b/examples/lib/okexample/package.json
new file mode 100644
index 0000000..2b2a47c
--- /dev/null
+++ b/examples/lib/okexample/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "okexample",
+ "version": "1.0.0",
+ "description": "example service",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "okfocus <frontdesk@okfoc.us>",
+ "license": "LNT"
+}