ah-sequelize-plugin
Advanced tools
Comparing version 2.1.0 to 2.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT = void 0; | ||
const path = require("path"); | ||
@@ -4,0 +5,0 @@ exports.DEFAULT = { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT = void 0; | ||
const url_1 = require("url"); | ||
@@ -4,0 +5,0 @@ const path_1 = require("path"); |
@@ -0,2 +1,8 @@ | ||
import { Sequelize } from "sequelize-typescript"; | ||
import { Initializer } from "actionhero"; | ||
declare module "actionhero" { | ||
interface Api { | ||
sequelize: Sequelize; | ||
} | ||
} | ||
export declare class SequelizeInitializer extends Initializer { | ||
@@ -3,0 +9,0 @@ umzug: Array<any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SequelizeInitializer = void 0; | ||
const sequelize_typescript_1 = require("sequelize-typescript"); | ||
@@ -4,0 +5,0 @@ const Umzug = require("umzug"); |
@@ -12,45 +12,49 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Post = void 0; | ||
const sequelize_typescript_1 = require("sequelize-typescript"); | ||
const uuid = require("uuid/v4"); | ||
const User_1 = require("./User"); | ||
let Post = class Post extends sequelize_typescript_1.Model { | ||
static generateGuid(instance) { | ||
if (!instance.guid) { | ||
instance.guid = uuid(); | ||
let Post = /** @class */ (() => { | ||
let Post = class Post extends sequelize_typescript_1.Model { | ||
static generateGuid(instance) { | ||
if (!instance.guid) { | ||
instance.guid = uuid(); | ||
} | ||
} | ||
} | ||
}; | ||
__decorate([ | ||
sequelize_typescript_1.Column({ primaryKey: true }), | ||
__metadata("design:type", String) | ||
], Post.prototype, "guid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.ForeignKey(() => User_1.User), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "authorGuid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "title", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "body", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BelongsTo(() => User_1.User), | ||
__metadata("design:type", User_1.User) | ||
], Post.prototype, "user", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BeforeCreate, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], Post, "generateGuid", null); | ||
Post = __decorate([ | ||
sequelize_typescript_1.Table({ tableName: "posts", paranoid: true }) | ||
], Post); | ||
}; | ||
__decorate([ | ||
sequelize_typescript_1.Column({ primaryKey: true }), | ||
__metadata("design:type", String) | ||
], Post.prototype, "guid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.ForeignKey(() => User_1.User), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "authorGuid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "title", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], Post.prototype, "body", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BelongsTo(() => User_1.User), | ||
__metadata("design:type", User_1.User) | ||
], Post.prototype, "user", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BeforeCreate, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], Post, "generateGuid", null); | ||
Post = __decorate([ | ||
sequelize_typescript_1.Table({ tableName: "posts", paranoid: true }) | ||
], Post); | ||
return Post; | ||
})(); | ||
exports.Post = Post; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.User = void 0; | ||
const bcrypt = require("bcrypt"); | ||
@@ -17,61 +18,64 @@ const sequelize_typescript_1 = require("sequelize-typescript"); | ||
const Post_1 = require("./Post"); | ||
let User = class User extends sequelize_typescript_1.Model { | ||
constructor() { | ||
super(...arguments); | ||
this.saltRounds = 10; | ||
} | ||
static generateGuid(instance) { | ||
if (!instance.guid) { | ||
instance.guid = uuid(); | ||
let User = /** @class */ (() => { | ||
let User = class User extends sequelize_typescript_1.Model { | ||
constructor() { | ||
super(...arguments); | ||
this.saltRounds = 10; | ||
} | ||
} | ||
async updatePassword(password) { | ||
this.passwordHash = await bcrypt.hash(password, this.saltRounds); | ||
await this.save(); | ||
} | ||
async checkPassword(password) { | ||
if (!this.passwordHash) { | ||
throw new Error("password not set for this team member"); | ||
static generateGuid(instance) { | ||
if (!instance.guid) { | ||
instance.guid = uuid(); | ||
} | ||
} | ||
const match = await bcrypt.compare(password, this.passwordHash); | ||
return match; | ||
} | ||
}; | ||
__decorate([ | ||
sequelize_typescript_1.Column({ primaryKey: true }), | ||
__metadata("design:type", String) | ||
], User.prototype, "guid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "firstName", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "lastName", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.IsEmail, | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "email", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "passwordHash", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.HasMany(() => Post_1.Post), | ||
__metadata("design:type", Array) | ||
], User.prototype, "posts", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BeforeCreate, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], User, "generateGuid", null); | ||
User = __decorate([ | ||
sequelize_typescript_1.Table({ tableName: "users", paranoid: true }) | ||
], User); | ||
async updatePassword(password) { | ||
this.passwordHash = await bcrypt.hash(password, this.saltRounds); | ||
await this.save(); | ||
} | ||
async checkPassword(password) { | ||
if (!this.passwordHash) { | ||
throw new Error("password not set for this team member"); | ||
} | ||
const match = await bcrypt.compare(password, this.passwordHash); | ||
return match; | ||
} | ||
}; | ||
__decorate([ | ||
sequelize_typescript_1.Column({ primaryKey: true }), | ||
__metadata("design:type", String) | ||
], User.prototype, "guid", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "firstName", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "lastName", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.AllowNull(false), | ||
sequelize_typescript_1.IsEmail, | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "email", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.Column, | ||
__metadata("design:type", String) | ||
], User.prototype, "passwordHash", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.HasMany(() => Post_1.Post), | ||
__metadata("design:type", Array) | ||
], User.prototype, "posts", void 0); | ||
__decorate([ | ||
sequelize_typescript_1.BeforeCreate, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], User, "generateGuid", null); | ||
User = __decorate([ | ||
sequelize_typescript_1.Table({ tableName: "users", paranoid: true }) | ||
], User); | ||
return User; | ||
})(); | ||
exports.User = User; |
@@ -6,3 +6,3 @@ { | ||
"description": "Use Sequelize in ActionHero", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"homepage": "http://actionherojs.com", | ||
@@ -30,22 +30,22 @@ "repository": { | ||
"devDependencies": { | ||
"@types/bluebird": "^3.5.30", | ||
"@types/jest": "^25.2.1", | ||
"@types/node": "^13.11.0", | ||
"@types/bluebird": "^3.5.32", | ||
"@types/jest": "^25.2.3", | ||
"@types/node": "^14.0.9", | ||
"@types/validator": "^13.0.0", | ||
"actionhero": "^22.0.7", | ||
"bcrypt": "^4.0.1", | ||
"jest": "^25.2.7", | ||
"pg": "^8.0.0", | ||
"prettier": "^2.0.4", | ||
"jest": "^26.0.1", | ||
"pg": "^8.2.1", | ||
"prettier": "^2.0.5", | ||
"reflect-metadata": "^0.1.13", | ||
"sequelize": "^5.21.5", | ||
"sequelize-typescript": "^1.0.0", | ||
"ts-jest": "^25.3.1", | ||
"ts-jest": "^26.1.0", | ||
"ts-node-dev": "^1.0.0-pre.44", | ||
"typescript": "^3.8.3" | ||
"typescript": "^3.9.3" | ||
}, | ||
"peerDependencies": { | ||
"sequelize": ">=5.21.6", | ||
"sequelize": ">=5.21.11", | ||
"sequelize-typescript": ">=1.1.0", | ||
"actionhero": ">=22.0.7" | ||
"actionhero": ">=22.1.1" | ||
}, | ||
@@ -52,0 +52,0 @@ "scripts": { |
@@ -5,2 +5,8 @@ import { Sequelize } from "sequelize-typescript"; | ||
declare module "actionhero" { | ||
interface Api { | ||
sequelize: Sequelize; | ||
} | ||
} | ||
export class SequelizeInitializer extends Initializer { | ||
@@ -7,0 +13,0 @@ umzug: Array<any>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55473
1288