refactor: gather

This commit is contained in:
cha0s 2021-01-22 16:57:33 -06:00
parent c4329743da
commit 7d7f27fc71
5 changed files with 12 additions and 15 deletions

View File

@ -22,6 +22,7 @@
"test.js.map"
],
"dependencies": {
"@latus/core": "^2.0.0",
"debug": "4.3.1",
"glob": "^7.1.6",
"natsort": "^2.0.2",

View File

@ -1,4 +1,4 @@
export default (User) => class ProjectUser extends User {
export default (latus, User) => class ProjectUser extends User {
async projectsStructure() {
return (await this.getProjects())

View File

@ -6,7 +6,7 @@ import glob from 'glob';
import {pathsToTree} from '../tree-utils';
class Project extends Model {
export default () => class Project extends Model {
static get attributes() {
return {
@ -31,6 +31,4 @@ class Project extends Model {
return pathsToTree(paths);
}
}
export default Project;
};

View File

@ -1,14 +1,12 @@
import Project from '../models/project';
import ProjectUser from '../models/project-user';
import {decorateWithLatus, gatherWithLatus} from '@latus/core';
export default {
hooks: {
'@latus/db/server/models': () => ({
Project,
}),
'@latus/db/server/models.decorate': (Models) => ({
...Models,
User: ProjectUser(Models.User),
}),
'@latus/db/server/models': gatherWithLatus(
require.context('../models', false, /\.js$/),
),
'@latus/db/server/models.decorate': decorateWithLatus(
require.context('../models/decorators', false, /\.js$/),
),
},
};

View File

@ -901,7 +901,7 @@
object-assign "^4.1.1"
scheduler "^0.20.1"
"@latus/core@2.0.0":
"@latus/core@2.0.0", "@latus/core@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@latus%2fcore/-/core-2.0.0.tgz#2ca04903351edc14f29fcec2ad6ab5e19c72e072"
integrity sha512-Sq4nPpQzRektLgsXRFQqhZWpUWY1bFTrVbm5X0vGTyTTlfQPmMbHyddmtdVTB8NbANvleuw4PvfuNVqKU4le6w==