Fix a bunch of ESLint errors
This commit is contained in:
Родитель
1133c043a7
Коммит
90f1300561
|
@ -1,3 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
development: {
|
||||
client: "postgresql",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const Model = require("objection").Model;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const Model = require("objection").Model;
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const Model = require("objection").Model;
|
||||
|
||||
class Subscriber extends Model {
|
||||
// Table name is the only required property.
|
||||
static get tableName() {
|
||||
return "subscribers";
|
||||
}
|
||||
|
||||
/*
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: "object",
|
||||
required: [],
|
||||
|
||||
properties: {
|
||||
id: { type: "integer" },
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
static get relationMappings() {
|
||||
return {
|
||||
sha1: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: __dirname + "/EmailHash",
|
||||
join: {
|
||||
from: "subscribers.sha1_id",
|
||||
to: "email_hashes.id",
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Subscriber;
|
14
db/utils.js
14
db/utils.js
|
@ -8,10 +8,12 @@ const getSha1 = require("../sha1-utils");
|
|||
const DBUtils = {
|
||||
async createBreach(name, meta) {
|
||||
try {
|
||||
return await Breach
|
||||
.query()
|
||||
.insert({ name, meta });
|
||||
} catch(e) {}
|
||||
return await Breach
|
||||
.query()
|
||||
.insert({ name, meta });
|
||||
} catch(e) {
|
||||
// Duplicate (TODO: check properly)
|
||||
}
|
||||
},
|
||||
|
||||
async deleteBreach(id) {
|
||||
|
@ -37,7 +39,7 @@ const DBUtils = {
|
|||
return await existingEntries[0]
|
||||
.$query()
|
||||
.patch({ email })
|
||||
.returning('*'); // Postgres trick to return the updated row as model.
|
||||
.returning("*"); // Postgres trick to return the updated row as model.
|
||||
}
|
||||
|
||||
return existingEntries[0];
|
||||
|
@ -65,7 +67,7 @@ const DBUtils = {
|
|||
await existingEntries[0]
|
||||
.$query()
|
||||
.patch({ email: null })
|
||||
.returning('*'); // Postgres trick to return the updated row as model.
|
||||
.returning("*"); // Postgres trick to return the updated row as model.
|
||||
},
|
||||
|
||||
async addBreachedHash(breachName, sha1) {
|
||||
|
|
|
@ -6,7 +6,7 @@ const express = require("express");
|
|||
const hbs = require("express-hbs");
|
||||
const sessions = require("client-sessions");
|
||||
const Knex = require("knex");
|
||||
const knexConfig = require('./db/knexfile');
|
||||
const knexConfig = require("./db/knexfile");
|
||||
const { Model } = require("objection");
|
||||
|
||||
const EmailUtils = require("./email-utils");
|
||||
|
|
|
@ -4,6 +4,6 @@ const crypto = require("crypto");
|
|||
|
||||
function getSha1(email) {
|
||||
return crypto.createHash("sha1").update(email).digest("hex");
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getSha1;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
require("dotenv").load();
|
||||
const Knex = require("knex");
|
||||
const knexConfig = require('../../db/knexfile');
|
||||
const knexConfig = require("../../db/knexfile");
|
||||
const { Model } = require("objection");
|
||||
|
||||
const DBUtils = require("../../db/utils")
|
||||
const DBUtils = require("../../db/utils");
|
||||
|
||||
const knex = Knex(knexConfig.development);
|
||||
Model.knex(knex);
|
||||
|
|
Загрузка…
Ссылка в новой задаче