1.0.8 • Published 10 months ago

@mhmdzaien/nuxt-sequelize v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Nuxt Sequelize

npm version npm downloads License Nuxt

Nuxt module to integrate sequelize and model at server api

Features

  •  Integrate with sequelize model
  •  Add controller support on server handler
  •  Authentication using token header

Quick Setup

1.Install the module to your Nuxt application with one command:

npx nuxi@latest module add @mhmdzaien/nuxt-sequelize

2.Add @mhmdzaien/nuxt-sequelize, models path and nitro support decorator in nuxt.config.ts

export default defineNuxtConfig({
  modules: [@mhmdzaien/nuxt-sequelize],
  nitro: {
    esbuild: {
      options: {
        tsconfigRaw: {
          compilerOptions: {
            experimentalDecorators: true,
          },
        },
      },
    },
  },
  nuxtSequelize: {
    modelPath: './server/models',
  },
})

3.Create index.js inside 'modelPath' that contain loader to model

export function initModels(sequelize: Sequelize) {
  User.initModel(sequelize)
}

4.Create .env file contain database configuration

DB_NAME=
DB_USER=root
DB_PASSWORD=
DB_HOST=localhost
DB_DRIVER=

DB_DRIVER is one of sequelize supported dialect

That's it! You can now use My Module in your Nuxt app ✨

Server utils

defineMyEventHandler(handler, authorizeRequest?)

  • handler : Function(event) => callback handler with event parameter
  • authorizeRequest : "*" | Array => if set handler check authentication in token header accepted role number

Contribution

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago