From e1330cb9186b26402b61069b7ff9511b4676dbaa Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sat, 8 Feb 2020 02:39:33 -0600 Subject: [PATCH] Add API routing and misc controller --- app/controllers/api/v1/Misc.controller.js | 17 ++++++++ app/routing/routers/api/v1.routes.js | 47 +++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 app/controllers/api/v1/Misc.controller.js create mode 100644 app/routing/routers/api/v1.routes.js diff --git a/app/controllers/api/v1/Misc.controller.js b/app/controllers/api/v1/Misc.controller.js new file mode 100644 index 0000000..df257b6 --- /dev/null +++ b/app/controllers/api/v1/Misc.controller.js @@ -0,0 +1,17 @@ +const Controller = require('libflitter/controller/Controller') + +/* + * Misc Controller + * ------------------------------------------------------------- + * Put some description here! + */ +class Misc extends Controller { + + hello_world(req, res) { + return res.api({ + hello: 'world', + }) + } +} + +module.exports = exports = Misc diff --git a/app/routing/routers/api/v1.routes.js b/app/routing/routers/api/v1.routes.js new file mode 100644 index 0000000..77de025 --- /dev/null +++ b/app/routing/routers/api/v1.routes.js @@ -0,0 +1,47 @@ +/* + * API v1 Routes + * ------------------------------------------------------------- + * Description here + */ +const index = { + + /* + * Define the prefix applied to each of these routes. + * For example, if prefix is '/auth': + * '/' becomes '/auth' + * '/login' becomes '/auth/login' + */ + prefix: '/api/v1', + + /* + * 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: [ + + ], + + /* + * 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: { + '/hello_world': [ 'controller::api:v1:Misc.hello_world' ], + }, + + post: { + + }, +} + +module.exports = exports = index