1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-23 07:09:42 +02:00

Editorjs checklist tool (#98)

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
This commit is contained in:
Alexander Menshikov 2020-05-09 05:38:25 +03:00 committed by GitHub
parent c0a4f6f3fd
commit b744ed592a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 2628 additions and 2152 deletions

View file

@ -2,7 +2,7 @@ const { aliases: aliasesDb } = require('../utils/database/index');
const { binaryMD5 } = require('../utils/crypto');
/**
* @typedef {Object} AliasData
* @typedef {object} AliasData
* @property {string} _id - alias id
* @property {string} hash - alias binary hash
* @property {string} type - entity type
@ -25,22 +25,26 @@ class Alias {
/**
* Return Alias types
*
* @returns {Object}
* @returns {object}
*/
static get types() {
return {
PAGE: 'page'
PAGE: 'page',
};
};
/**
* Find and return alias with given alias
*
* @param {string} aliasName - alias of entity
* @returns {Promise<Alias>}
*/
static async get(aliasName) {
const hash = binaryMD5(aliasName);
let data = await aliasesDb.findOne({ hash: hash, deprecated: false });
let data = await aliasesDb.findOne({
hash: hash,
deprecated: false,
});
if (!data) {
data = await aliasesDb.findOne({ hash: hash });
@ -50,7 +54,7 @@ class Alias {
}
/**
* @constructor
* @class
*
* @param {AliasData} data
* @param {string} aliasName - alias of entity
@ -110,12 +114,13 @@ class Alias {
id: this.id,
type: this.type,
hash: this.hash,
deprecated: this.deprecated
deprecated: this.deprecated,
};
}
/**
* Mark alias as deprecated
*
* @param {string} aliasName - alias of entity
* @returns {Promise<Alias>}
*/