Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ah-sequelize-plugin

Package Overview
Dependencies
Maintainers
6
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ah-sequelize-plugin - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

.circleci/config.yml

17

classes/sequelize.js

@@ -42,4 +42,5 @@ const path = require('path')

fs.readdirSync(dir).forEach((file) => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
return importModelsFromDirectory(path.join(dir, file))
const filename = path.join(dir, file)
if (fs.statSync(filename).isDirectory()) {
return importModelsFromDirectory(filename)
}

@@ -49,4 +50,10 @@ if (path.extname(file) !== '.js') return

var name = nameParts[(nameParts.length - 1)].split('.')[0]
var modelFunc = currySchemaFunc(require(path.join(dir, file)))
var modelFunc = currySchemaFunc(require(filename))
this.sequelize.import(name, modelFunc)
api.watchFileAndAct(filename, async () => {
api.log(`*** Rebooting due to model change (${filename}) ***`, 'info')
delete require.cache[require.resolve(filename)]
delete this.sequelize.importCache[filename]
await api.commands.restart()
})
})

@@ -102,2 +109,6 @@ }

}
async close () {
return this.sequelize.close()
}
}

@@ -104,0 +115,0 @@

28

config/sequelize.js

@@ -36,16 +36,18 @@ exports.default = {

// Example test configuration (using sqlite in-memory)
// Example test configuration
// exports.test = {
// sequelize: (api) => {
// return {
// 'autoMigrate': true,
// 'loadFixtures': false,
// 'logging': false,
// 'dialect': 'sqlite',
// 'storage': ':memory:',
// 'host': 'localhost'
// }
// }
// }
exports.test = {
sequelize: (api) => {
return {
'autoMigrate': true,
'loadFixtures': false,
'database': 'TEST_DB',
'dialect': 'mysql',
'port': 3306,
'host': '127.0.0.1',
'username': 'root',
'password': ''
}
}
}

@@ -52,0 +54,0 @@ // You can define even more elaborate configurations (including replication).

@@ -24,2 +24,6 @@ const { Initializer, api } = require('actionhero')

}
async stop () {
await api.sequelize.close()
}
}
{
"author": "Evan Tahler <evantahler@gmail.com>",
"name": "ah-sequelize-plugin",
"license": "MIT",
"description": "Use Sequelize in ActionHero",
"version": "1.0.3",
"version": "1.0.4",
"homepage": "http://actionherojs.com",

@@ -29,3 +30,9 @@ "repository": {

"devDependencies": {
"standard": "^10.0.3"
"actionhero": "^19.0.1",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"mocha": "^5.2.0",
"mysql2": "^1.5.3",
"sequelize": "^4.37.8",
"standard": "^11.0.1"
},

@@ -37,4 +44,20 @@ "peerDependencies": {

"scripts": {
"test": "NODE_ENV=test mocha",
"pretest": "standard",
"postinstall": "node scripts/postinstall.js"
},
"standard": {
"globals": [
"fetch",
"FormData",
"confirm",
"prompt",
"before",
"after",
"it",
"describe",
"beforeEach",
"afterEach"
]
}
}
![plugin](https://i.imgur.com/nd1btLt.png)
# ah-sequelize-plugin
[![CircleCI](https://circleci.com/gh/actionhero/ah-sequelize-plugin.svg?style=svg)](https://circleci.com/gh/actionhero/ah-sequelize-plugin)
This plugin will use the sequelize orm to create `api.models` which contain your sequelize models.

@@ -16,3 +18,4 @@

- Add plugin to your project's `./config/plugins.js`:
```
```javascript
exports['default'] = {

@@ -162,25 +165,15 @@ plugins: (api) => {

```javascript
const ActionHero = require('actionhero')
const api = ActionHero.api
const { Initializer, api } = require('actionhero')
module.exports =
class AssociationsInitializer extends ActionHero.Initializer {
constructor () {
super()
this.name = 'associations'
this.loadPriority = 1000
this.startPriority = 1002
this.stopPriority = 1000
}
module.exports = class AssociationsInitializer extends Initializer {
constructor () {
super()
this.name = 'AssociationsInitializer'
}
initialize () { }
start () {
Object.entries(api.models).filter(([k, m]) => typeof m.associate === 'function')
.forEach(([k, m]) => m.associate(api.models))
}
stop () { }
start () {
Object.entries(api.models).filter(([k, m]) => typeof m.associate === 'function')
.forEach(([k, m]) => m.associate(api.models))
}
}
```

@@ -187,0 +180,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc