1.1.5 • Published 3 years ago

amenov-framework v1.1.5

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

The Amenov Framework

Setup

npm i -g amenov-framework

amenov-framework init my-project

cd my-project

Copy ".env.example" -> ".env" and add your private key to JWT_SECRET_KEY etc.

Note: Don't forget to set up your database for the next step!

npm install && npm install -g nodemon

npx sequelize db:migrate
npx sequelize db:seed:all

npm run dev or npm run start

Directory Structure

  • controllers
  • database:
    • migrations
    • models
    • seeders
  • docs
  • helpers
  • middleware
  • routes
  • storage

Config.js

module.exports = {
  global: {
    test: 123
  },
  server: {
    multiProcessing: false, // default
    port: process.env.PORT ?? 5000 // default
  },
  // Add your module aliases so they are always at hand
  moduleAlias: {
    '@some-folder': __dirname + '/directory/some-folder'
  },
  middleware: {
    rateLimit: {
      windowMs: 5 * 60 * 1000, // default
      max: 1000 // default
    },
    cors: {}, // default
    validator: {
      locale: 'en' // default: en || ru
    },
    router: {
      baseUrl: '/', // default
      routesPath: '/routes', // default
      apiDocs: {
        title: 'API-docs' // default
      }
    },
    // Add your global middleware
    extend: () => [require('@middleware/global/some'), ...]
  },
  master(config) {
    console.log('I am working in the wizard when multiprocessing is running')
  },
  start({ config, express, app, server }) {
    // Will be executed when the application starts

    // Calling a global variable
    console.log('Hello!', $test) // Hello 123
  }
}