1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-24 01:18:01 +02:00

fix: project store was wrongly typing its id field as number (#822)

This commit is contained in:
Christopher Kolstad 2021-04-30 12:51:46 +02:00 committed by GitHub
parent 2df0907e1c
commit 4c3a77bc31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -7,20 +7,20 @@ const COLUMNS = ['id', 'name', 'description', 'created_at'];
const TABLE = 'projects'; const TABLE = 'projects';
export interface IProject { export interface IProject {
id: number; id: string;
name: string; name: string;
description: string; description: string;
createdAt: Date; createdAt: Date;
} }
interface IProjectInsert { interface IProjectInsert {
id: number; id: string;
name: string; name: string;
description: string; description: string;
} }
interface IProjectArchived { interface IProjectArchived {
id: number; id: string;
archived: boolean; archived: boolean;
} }
@ -51,7 +51,7 @@ class ProjectStore {
return rows.map(this.mapRow); return rows.map(this.mapRow);
} }
async get(id): Promise<IProject> { async get(id: string): Promise<IProject> {
return this.db return this.db
.first(COLUMNS) .first(COLUMNS)
.from(TABLE) .from(TABLE)
@ -59,7 +59,7 @@ class ProjectStore {
.then(this.mapRow); .then(this.mapRow);
} }
async hasProject(id): Promise<IProjectArchived> { async hasProject(id: string): Promise<IProjectArchived> {
return this.db return this.db
.first('id') .first('id')
.from(TABLE) .from(TABLE)

View File

@ -14,6 +14,8 @@ import {
PROJECT_DELETED, PROJECT_DELETED,
PROJECT_UPDATED, PROJECT_UPDATED,
} from '../types/events'; } from '../types/events';
import { IUnleashStores } from '../types/stores';
import { IUnleashConfig } from '../types/option';
const getCreatedBy = (user: User) => user.email || user.username; const getCreatedBy = (user: User) => user.email || user.username;
@ -36,8 +38,15 @@ export default class ProjectService {
private logger: any; private logger: any;
constructor( constructor(
{ projectStore, eventStore, featureToggleStore }, {
config: any, projectStore,
eventStore,
featureToggleStore,
}: Pick<
IUnleashStores,
'projectStore' | 'eventStore' | 'featureToggleStore'
>,
config: IUnleashConfig,
accessService: AccessService, accessService: AccessService,
) { ) {
this.projectStore = projectStore; this.projectStore = projectStore;
@ -51,7 +60,7 @@ export default class ProjectService {
return this.projectStore.getAll(); return this.projectStore.getAll();
} }
async getProject(id: number): Promise<IProject> { async getProject(id: string): Promise<IProject> {
return this.projectStore.get(id); return this.projectStore.get(id);
} }