nails-boilerplate 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/nails.js CHANGED
@@ -98,12 +98,12 @@ function init_controllers(controller_lib) {
98
98
  function init_models(model_lib) {
99
99
  init_app_lib(Model, model_lib);
100
100
  }
101
- function init_app_lib(superclass, abs_path) {
101
+ async function init_app_lib(superclass, abs_path) {
102
102
  console.log('attempting to import:', abs_path);
103
103
  if (!fs.existsSync(abs_path))
104
104
  return console.log('Cannot initialize. Path not found.', abs_path);
105
105
  if (fs.statSync(abs_path).isFile()) {
106
- let subclass = require(abs_path);
106
+ let subclass = (await import(abs_path)).default;
107
107
  // Constructor function was provided
108
108
  if (!superclass.isPrototypeOf(subclass))
109
109
  return superclass.extend(subclass);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nails-boilerplate",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "A node.js webserver scaffold",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,13 @@
1
+ /*
2
+ const Controller =
3
+ require("../../../../../index.js").Controller;
4
+ */
5
+ import nails from "../../../../../index.js";
6
+ export default class MjsController extends nails.Controller {
7
+ // DO NOT OVERRIDE CONSTRUCTOR
8
+ index(params, request, response) {
9
+ response.json({
10
+ classbased_index: true
11
+ });
12
+ }
13
+ }