1.6.0 • Published 4 years ago

meen-core v1.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

M.E.E.N

M.E.E.N = MongoDB + ExpressJS + EdgeJS + NodeJS

Methods

composeApp

/**
 * Compose an app. You can compose website or api app with built-in modules via `options` or your own fully-customised app by passing modules via `modules`
 * @param {String} appName Your app name
 * @param {Object} config App configuration, includes built-in modules' and custom configurations
 * @param {Array<Function>} modules Module must be function with first param is `app` as Express App Instance and second param is `config`
 */
composeApp(appName, config, modules);

Note: Order of configuration as the following: 1. Default 1. /config/app.js (will be loaded if available) 1. config param

composeModel

/**
 * Compose a Mongoose model
 * @param {String} modelName Name of model
 * @param {Object} schema Schema options of mongoose
 * @param {Object} options
 * @param {Object} options.index Equals with `mongooseSchema.index` method
 * @param {Object} options.virtual List of virtual properties with key is name of virtual and value is virtual options. If you pass value as function, it will be getter. 
 * Example: 
 * {
 *     url: {
 *         get: function () {
 *             return `/url/${this._id}`;
 *         }
 *     },
 *     type: function () {
 *         return this.type;
 *     }
 * }
 * @param {Array} options.plugins Each plugin will be passed via `mongooseSchema.plugin` method
 * @param {Object} options.index Same as `mongooseSchema.index` method
 * @param {Object} options.set Same as `mongooseSchema.set` method
 * @param {Object} options.static Static properties will be added to model
 */
composeModel(modelName, schema, options, dontEnhance);

Built-in modules

Each module has its own config same as its name. Example: publicFolder module will use publicFolder in config

Modules list:

Presets

MEEN provides presets for app types via config.app.preset. Order of modules will be loaded as specified in below

website:

  1. compression
  2. publicFolder
  3. view
  4. session
  5. bodyParser
  6. mongoose
  7. morgan

api:

  1. cors
  2. bodyParser
  3. mongoose
  4. morgan

Default configuration

const { resolvePath } = require('meen-utils');

module.exports = {
    preset: null,
    info: {
        title: 'M.E.E.N',
        version: '1.0.0',
    },
    mongoose: {
        debug: false,
        options: {
            useNewUrlParser: true,
            useUnifiedTopology: true,
        },
        itemPerPage: 20,
    },
    cors: '*',
    session: {
        secret: 'M.E.E.N',
        expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
        maxAge: 7 * 24 * 60 * 60 * 1000,
    },
    publicFolder: {
        path: resolvePath('public'),
        debug: false,
    },
    view: {
        minify: false,
        cache: false,
    },
    handleError: {
        enabled: false,
        debug: true,
        isJson: false,
    },
};

License

Please read at here

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago