Created
November 6, 2019 16:20
-
-
Save dancgray/ef659fcfbd938ab3f2f247a097a3d728 to your computer and use it in GitHub Desktop.
Assets AbstractApiModule test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AbstractApiModule = require('adapt-authoring-api'); | |
const AssetSchema = require('../schema/asset.schema.js'); | |
/** | |
* Abstract module which handles course assets | |
* @extends {AbstractApiModule} | |
*/ | |
class AssetApiModule extends AbstractApiModule { | |
/** @override */ | |
static get def() { | |
return { | |
name: 'assets', | |
model: 'asset', | |
schemas: [ AssetSchema ], | |
routes: [ | |
{ | |
route: '/:_id?', | |
handlers: { | |
get: getFunction | |
} | |
} | |
] | |
}; | |
} | |
getFunction(req, res, next) { | |
console.log('Assets getFunction called'); | |
} | |
} | |
module.exports = AssetApiModule; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have just tested this out, and while there's nothing immediately wrong with the above, I think you're missing the
module: true
attribute from yourpackage.json
(see this doc page for an example).The original reasoning behind this was to allow the inclusion of dependencies which don't export a module (e.g. the testing, lint and doc modules). It may be an idea to change this so the package config is no longer needed, and the module export is required, i.e.
You'll also need to change where
getFunction
is declared, as thedef
is a static function.