Quellcode durchsuchen

One-time pass with format & lint fixes for entire codebase

This should not be needed again now that we have lint-staged in place.
Michael Bromley vor 7 Jahren
Ursprung
Commit
46e3f3efd6
36 geänderte Dateien mit 148 neuen und 154 gelöschten Zeilen
  1. 8 9
      modules/core/api/auth/auth.controller.ts
  2. 1 1
      modules/core/api/customer/customer.controller.ts
  3. 3 3
      modules/core/api/customer/customer.resolver.ts
  4. 2 2
      modules/core/api/customer/customer.service.ts
  5. 1 1
      modules/core/api/product/product.resolver.ts
  6. 4 4
      modules/core/api/product/product.service.ts
  7. 10 13
      modules/core/app.module.ts
  8. 1 1
      modules/core/auth/auth-types.ts
  9. 17 20
      modules/core/auth/auth.service.ts
  10. 15 15
      modules/core/auth/jwt.strategy.ts
  11. 1 2
      modules/core/auth/password.service.ts
  12. 1 1
      modules/core/auth/role.ts
  13. 5 5
      modules/core/auth/roles-guard.ts
  14. 1 1
      modules/core/entity/address/address.entity.ts
  15. 4 4
      modules/core/entity/administrator/administrator.entity.ts
  16. 1 1
      modules/core/entity/administrator/administrator.interface.ts
  17. 6 5
      modules/core/entity/customer/customer.entity.ts
  18. 2 2
      modules/core/entity/customer/customer.interface.ts
  19. 1 1
      modules/core/entity/product-option-group/product-option-group-translation.entity.ts
  20. 2 2
      modules/core/entity/product-option-group/product-option-group.entity.ts
  21. 1 1
      modules/core/entity/product-option/product-option-translation.entity.ts
  22. 3 3
      modules/core/entity/product-option/product-option.entity.ts
  23. 1 1
      modules/core/entity/product-option/product-option.interface.ts
  24. 1 1
      modules/core/entity/product-variant/product-variant-translation.entity.ts
  25. 3 3
      modules/core/entity/product-variant/product-variant.entity.ts
  26. 1 1
      modules/core/entity/product/product-translation.entity.ts
  27. 6 6
      modules/core/entity/product/product.entity.ts
  28. 1 1
      modules/core/entity/product/product.interface.ts
  29. 1 1
      modules/core/entity/user/user.entity.ts
  30. 1 1
      modules/core/entity/user/user.interface.ts
  31. 9 6
      modules/core/locale/locale-types.ts
  32. 0 1
      modules/core/locale/locale.service.ts
  33. 3 3
      modules/core/repository/product-repository.ts
  34. 12 11
      modules/testing/mock-data.service.ts
  35. 2 4
      modules/testing/populate.ts
  36. 17 17
      test/app.e2e-spec.ts

+ 8 - 9
modules/core/api/auth/auth.controller.ts

@@ -1,13 +1,12 @@
-import { Body, Controller, Get, Post, Req } from "@nestjs/common";
-import { LoginDto } from "./login.dto";
-import { AuthService } from "../../auth/auth.service";
-import { RolesGuard } from "../../auth/roles-guard";
-import { Role } from "../../auth/role";
-import { UserEntity } from "../../entity/user/user.entity";
+import { Body, Controller, Get, Post, Req } from '@nestjs/common';
+import { AuthService } from '../../auth/auth.service';
+import { Role } from '../../auth/role';
+import { RolesGuard } from '../../auth/roles-guard';
+import { UserEntity } from '../../entity/user/user.entity';
+import { LoginDto } from './login.dto';
 
 @Controller('auth')
 export class AuthController {
-
     constructor(private authService: AuthService) {}
 
     /**
@@ -21,7 +20,7 @@ export class AuthController {
         if (token) {
             return {
                 token,
-                user: this.publiclyAccessibleUser(user)
+                user: this.publiclyAccessibleUser(user),
             };
         }
     }
@@ -43,7 +42,7 @@ export class AuthController {
         return {
             id: user.id,
             identifier: user.identifier,
-            roles: user.roles
+            roles: user.roles,
         };
     }
 }

+ 1 - 1
modules/core/api/customer/customer.controller.ts

@@ -1,6 +1,6 @@
 import { Controller, Get, Param } from '@nestjs/common';
+import { Customer } from '../../entity/customer/customer.interface';
 import { CustomerService } from './customer.service';
-import { Customer } from "../../entity/customer/customer.interface";
 
 @Controller('customers')
 export class CustomerController {

+ 3 - 3
modules/core/api/customer/customer.resolver.ts

@@ -1,8 +1,8 @@
 import { Query, ResolveProperty, Resolver } from '@nestjs/graphql';
-import { CustomerService } from './customer.service';
 import { Address } from '../../entity/address/address.interface';
-import { CustomerEntity } from "../../entity/customer/customer.entity";
-import { Customer } from "../../entity/customer/customer.interface";
+import { CustomerEntity } from '../../entity/customer/customer.entity';
+import { Customer } from '../../entity/customer/customer.interface';
+import { CustomerService } from './customer.service';
 
 @Resolver('Customer')
 export class CustomerResolver {

+ 2 - 2
modules/core/api/customer/customer.service.ts

@@ -3,8 +3,8 @@ import { InjectConnection } from '@nestjs/typeorm';
 import { Connection } from 'typeorm';
 import { AddressEntity } from '../../entity/address/address.entity';
 import { Address } from '../../entity/address/address.interface';
-import { CustomerEntity } from "../../entity/customer/customer.entity";
-import { Customer } from "../../entity/customer/customer.interface";
+import { CustomerEntity } from '../../entity/customer/customer.entity';
+import { Customer } from '../../entity/customer/customer.interface';
 
 @Injectable()
 export class CustomerService {

+ 1 - 1
modules/core/api/product/product.resolver.ts

@@ -1,6 +1,6 @@
 import { Query, Resolver } from '@nestjs/graphql';
-import { ProductService } from './product.service';
 import { Product } from '../../entity/product/product.interface';
+import { ProductService } from './product.service';
 
 @Resolver('Product')
 export class ProductResolver {

+ 4 - 4
modules/core/api/product/product.service.ts

@@ -1,13 +1,13 @@
 import { Injectable } from '@nestjs/common';
 import { InjectConnection } from '@nestjs/typeorm';
 import { Connection, createQueryBuilder } from 'typeorm';
-import { Product } from '../../entity/product/product.interface';
+import { ProductVariantEntity } from '../../entity/product-variant/product-variant.entity';
+import { ProductVariant } from '../../entity/product-variant/product-variant.interface';
 import { ProductEntity } from '../../entity/product/product.entity';
+import { Product } from '../../entity/product/product.interface';
 import { Translatable, Translation } from '../../locale/locale-types';
 import { LocaleService } from '../../locale/locale.service';
-import { ProductVariant } from '../../entity/product-variant/product-variant.interface';
-import { ProductVariantEntity } from '../../entity/product-variant/product-variant.entity';
-import { ProductRepository } from "../../repository/product-repository";
+import { ProductRepository } from '../../repository/product-repository';
 
 @Injectable()
 export class ProductService {

+ 10 - 13
modules/core/app.module.ts

@@ -1,18 +1,18 @@
 import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
-import { TypeOrmModule } from '@nestjs/typeorm';
 import { GraphQLModule } from '@nestjs/graphql';
-import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
 import { GraphQLFactory } from '@nestjs/graphql';
-import { CustomerService } from './api/customer/customer.service';
+import { TypeOrmModule } from '@nestjs/typeorm';
+import { graphiqlExpress, graphqlExpress } from 'apollo-server-express';
+import { AuthController } from './api/auth/auth.controller';
 import { CustomerController } from './api/customer/customer.controller';
 import { CustomerResolver } from './api/customer/customer.resolver';
-import { ProductService } from './api/product/product.service';
+import { CustomerService } from './api/customer/customer.service';
 import { ProductResolver } from './api/product/product.resolver';
+import { ProductService } from './api/product/product.service';
+import { AuthService } from './auth/auth.service';
+import { JwtStrategy } from './auth/jwt.strategy';
+import { PasswordService } from './auth/password.service';
 import { LocaleService } from './locale/locale.service';
-import { PasswordService } from "./auth/password.service";
-import { AuthService } from "./auth/auth.service";
-import { AuthController } from "./api/auth/auth.controller";
-import { JwtStrategy } from "./auth/jwt.strategy";
 
 @Module({
     imports: [
@@ -29,10 +29,7 @@ import { JwtStrategy } from "./auth/jwt.strategy";
             database: 'test',
         }),
     ],
-    controllers: [
-        AuthController,
-        CustomerController
-    ],
+    controllers: [AuthController, CustomerController],
     providers: [
         AuthService,
         JwtStrategy,
@@ -42,7 +39,7 @@ import { JwtStrategy } from "./auth/jwt.strategy";
         ProductService,
         ProductResolver,
         LocaleService,
-        PasswordService
+        PasswordService,
     ],
 })
 export class AppModule implements NestModule {

+ 1 - 1
modules/core/auth/auth-types.ts

@@ -1,4 +1,4 @@
-import { Role } from "./role";
+import { Role } from './role';
 
 export interface JwtPayload {
     identifier: string;

+ 17 - 20
modules/core/auth/auth.service.ts

@@ -1,28 +1,25 @@
+import { Injectable, UnauthorizedException } from '@nestjs/common';
+import { InjectConnection } from '@nestjs/typeorm';
 import * as jwt from 'jsonwebtoken';
-import { Injectable, UnauthorizedException } from "@nestjs/common";
-import { JwtPayload } from "./auth-types";
-import { Role } from "./role";
-import { PasswordService } from "./password.service";
-import { Connection } from "typeorm";
-import { InjectConnection } from "@nestjs/typeorm";
-import { UserEntity } from "../entity/user/user.entity";
+import { Connection } from 'typeorm';
+import { UserEntity } from '../entity/user/user.entity';
+import { JwtPayload } from './auth-types';
+import { PasswordService } from './password.service';
+import { Role } from './role';
 
 // TODO: make this configurable e.g. from environment
 export const JWT_SECRET = 'some_secret';
 
 @Injectable()
 export class AuthService {
+    constructor(private passwordService: PasswordService, @InjectConnection() private connection: Connection) {}
 
-    constructor(private passwordService: PasswordService,
-                @InjectConnection() private connection: Connection) {}
-
-    async createToken(identifier: string, password: string): Promise<{ user: UserEntity; token: string; }> {
-        const user = await this.connection.getRepository(UserEntity)
-            .findOne({
-                where: {
-                    identifier
-                }
-            });
+    async createToken(identifier: string, password: string): Promise<{ user: UserEntity; token: string }> {
+        const user = await this.connection.getRepository(UserEntity).findOne({
+            where: {
+                identifier,
+            },
+        });
 
         if (!user) {
             throw new UnauthorizedException();
@@ -33,7 +30,7 @@ export class AuthService {
         if (!passwordMatches) {
             throw new UnauthorizedException();
         }
-        const payload: JwtPayload = { identifier , roles: user.roles };
+        const payload: JwtPayload = { identifier, roles: user.roles };
         const token = jwt.sign(payload, JWT_SECRET, { expiresIn: 3600 });
 
         return { user, token };
@@ -42,8 +39,8 @@ export class AuthService {
     async validateUser(payload: JwtPayload): Promise<any> {
         return await this.connection.getRepository(UserEntity).findOne({
             where: {
-                identifier: payload.identifier
-            }
+                identifier: payload.identifier,
+            },
         });
     }
 }

+ 15 - 15
modules/core/auth/jwt.strategy.ts

@@ -1,23 +1,23 @@
+import { Injectable, UnauthorizedException } from '@nestjs/common';
+import { PassportStrategy } from '@nestjs/passport';
 import { ExtractJwt, Strategy } from 'passport-jwt';
+import { JwtPayload } from './auth-types';
 import { AuthService, JWT_SECRET } from './auth.service';
-import { PassportStrategy } from '@nestjs/passport';
-import { Injectable, UnauthorizedException } from '@nestjs/common';
-import { JwtPayload } from "./auth-types";
 
 @Injectable()
 export class JwtStrategy extends PassportStrategy(Strategy) {
-  constructor(private readonly authService: AuthService) {
-    super({
-      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
-      secretOrKey: JWT_SECRET,
-    });
-  }
+    constructor(private readonly authService: AuthService) {
+        super({
+            jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
+            secretOrKey: JWT_SECRET,
+        });
+    }
 
-  async validate(payload: JwtPayload, done: Function) {
-    const user = await this.authService.validateUser(payload);
-    if (!user) {
-      return done(new UnauthorizedException(), false);
+    async validate(payload: JwtPayload, done: (err: Error, user: any) => void) {
+        const user = await this.authService.validateUser(payload);
+        if (!user) {
+            return done(new UnauthorizedException(), false);
+        }
+        done(null, user);
     }
-    done(null, user);
-  }
 }

+ 1 - 2
modules/core/auth/password.service.ts

@@ -1,11 +1,10 @@
-import { Injectable } from "@nestjs/common";
+import { Injectable } from '@nestjs/common';
 import * as bcrypt from 'bcrypt';
 
 const SALT_ROUNDS = 12;
 
 @Injectable()
 export class PasswordService {
-
     hash(plaintext: string): Promise<string> {
         return bcrypt.hash(plaintext, SALT_ROUNDS);
     }

+ 1 - 1
modules/core/auth/role.ts

@@ -5,5 +5,5 @@ export enum Role {
     // The Authenticated role means simply that the user is logged in
     Authenticated = 'Authenticated',
     Customer = 'Customer',
-    Superadmin = 'Superadmin'
+    Superadmin = 'Superadmin',
 }

+ 5 - 5
modules/core/auth/roles-guard.ts

@@ -1,8 +1,8 @@
-import { CanActivate, ExecutionContext, UseGuards } from "@nestjs/common";
-import { AuthGuard } from "@nestjs/passport";
-import { Role } from "./role";
-import { UserEntity } from "../entity/user/user.entity";
+import { CanActivate, ExecutionContext, UseGuards } from '@nestjs/common';
+import { AuthGuard } from '@nestjs/passport';
 import { ExtractJwt, Strategy } from 'passport-jwt';
+import { UserEntity } from '../entity/user/user.entity';
+import { Role } from './role';
 
 /**
  * A guard which combines the JWT passport auth method with restrictions based on
@@ -43,7 +43,7 @@ function forRoles(roles: Role[]) {
                 return false;
             }
             return arraysIntersect(roles, user.roles);
-        }
+        },
     } as CanActivate;
 }
 

+ 1 - 1
modules/core/entity/address/address.entity.ts

@@ -1,7 +1,7 @@
 import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
+import { CustomerEntity } from '../customer/customer.entity';
 import { UserEntity } from '../user/user.entity';
 import { Address } from './address.interface';
-import { CustomerEntity } from "../customer/customer.entity";
 
 @Entity('address')
 export class AddressEntity implements Address {

+ 4 - 4
modules/core/entity/administrator/administrator.entity.ts

@@ -5,11 +5,11 @@ import {
     JoinColumn,
     OneToOne,
     PrimaryGeneratedColumn,
-    UpdateDateColumn
+    UpdateDateColumn,
 } from 'typeorm';
-import { Administrator } from "./administrator.interface";
-import { UserEntity } from "../user/user.entity";
-import { User } from "../user/user.interface";
+import { UserEntity } from '../user/user.entity';
+import { User } from '../user/user.interface';
+import { Administrator } from './administrator.interface';
 
 @Entity('administrator')
 export class AdministratorEntity implements Administrator {

+ 1 - 1
modules/core/entity/administrator/administrator.interface.ts

@@ -1,4 +1,4 @@
-import { User } from "../user/user.interface";
+import { User } from '../user/user.interface';
 
 /**
  * An administrator of the system.

+ 6 - 5
modules/core/entity/customer/customer.entity.ts

@@ -1,16 +1,17 @@
 import {
     Column,
     CreateDateColumn,
-    Entity, JoinColumn,
+    Entity,
+    JoinColumn,
     OneToMany,
     OneToOne,
     PrimaryGeneratedColumn,
-    UpdateDateColumn
+    UpdateDateColumn,
 } from 'typeorm';
 import { AddressEntity } from '../address/address.entity';
-import { Customer } from "./customer.interface";
-import { UserEntity } from "../user/user.entity";
-import { User } from "../user/user.interface";
+import { UserEntity } from '../user/user.entity';
+import { User } from '../user/user.interface';
+import { Customer } from './customer.interface';
 
 @Entity('customer')
 export class CustomerEntity implements Customer {

+ 2 - 2
modules/core/entity/customer/customer.interface.ts

@@ -1,5 +1,5 @@
-import { Address } from "../address/address.interface";
-import { User } from "../user/user.interface";
+import { Address } from '../address/address.interface';
+import { User } from '../user/user.interface';
 
 /**
  * A customer, i.e. a user who has trasacted with the shop in some way. A Customer may also be associated with

+ 1 - 1
modules/core/entity/product-option-group/product-option-group-translation.entity.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
 import { Translation } from '../../locale/locale-types';
-import { ProductOptionGroup } from './product-option-group.interface';
 import { ProductOptionGroupEntity } from './product-option-group.entity';
+import { ProductOptionGroup } from './product-option-group.interface';
 
 @Entity('product_option_group_translation')
 export class ProductOptionGroupTranslationEntity implements Translation<ProductOptionGroup> {

+ 2 - 2
modules/core/entity/product-option-group/product-option-group.entity.ts

@@ -1,8 +1,8 @@
 import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
 import { Translatable } from '../../locale/locale-types';
-import { ProductOptionGroup } from './product-option-group.interface';
-import { ProductOptionGroupTranslationEntity } from './product-option-group-translation.entity';
 import { ProductOptionEntity } from '../product-option/product-option.entity';
+import { ProductOptionGroupTranslationEntity } from './product-option-group-translation.entity';
+import { ProductOptionGroup } from './product-option-group.interface';
 
 @Entity('product_option_group')
 export class ProductOptionGroupEntity implements Translatable<ProductOptionGroup> {

+ 1 - 1
modules/core/entity/product-option/product-option-translation.entity.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
 import { Translation } from '../../locale/locale-types';
-import { ProductOption } from './product-option.interface';
 import { ProductOptionEntity } from './product-option.entity';
+import { ProductOption } from './product-option.interface';
 
 @Entity('product_option_translation')
 export class ProductOptionTranslationEntity implements Translation<ProductOption> {

+ 3 - 3
modules/core/entity/product-option/product-option.entity.ts

@@ -1,5 +1,3 @@
-import { Translatable } from '../../locale/locale-types';
-import { ProductOption } from './product-option.interface';
 import {
     Column,
     CreateDateColumn,
@@ -9,8 +7,10 @@ import {
     PrimaryGeneratedColumn,
     UpdateDateColumn,
 } from 'typeorm';
-import { ProductOptionTranslationEntity } from './product-option-translation.entity';
+import { Translatable } from '../../locale/locale-types';
 import { ProductOptionGroupEntity } from '../product-option-group/product-option-group.entity';
+import { ProductOptionTranslationEntity } from './product-option-translation.entity';
+import { ProductOption } from './product-option.interface';
 
 @Entity('product_option')
 export class ProductOptionEntity implements Translatable<ProductOption> {

+ 1 - 1
modules/core/entity/product-option/product-option.interface.ts

@@ -1,5 +1,5 @@
-import { ProductOptionGroup } from '../product-option-group/product-option-group.interface';
 import { LocaleString } from '../../locale/locale-types';
+import { ProductOptionGroup } from '../product-option-group/product-option-group.interface';
 
 export interface ProductOption {
     id: number;

+ 1 - 1
modules/core/entity/product-variant/product-variant-translation.entity.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
 import { Translation } from '../../locale/locale-types';
-import { ProductVariant } from './product-variant.interface';
 import { ProductVariantEntity } from './product-variant.entity';
+import { ProductVariant } from './product-variant.interface';
 
 @Entity('product_variant_translation')
 export class ProductVariantTranslationEntity implements Translation<ProductVariant> {

+ 3 - 3
modules/core/entity/product-variant/product-variant.entity.ts

@@ -1,5 +1,3 @@
-import { Translatable } from '../../locale/locale-types';
-import { ProductVariant } from './product-variant.interface';
 import {
     Column,
     CreateDateColumn,
@@ -11,9 +9,11 @@ import {
     PrimaryGeneratedColumn,
     UpdateDateColumn,
 } from 'typeorm';
+import { Translatable } from '../../locale/locale-types';
+import { ProductOptionEntity } from '../product-option/product-option.entity';
 import { ProductEntity } from '../product/product.entity';
 import { ProductVariantTranslationEntity } from './product-variant-translation.entity';
-import { ProductOptionEntity } from '../product-option/product-option.entity';
+import { ProductVariant } from './product-variant.interface';
 
 @Entity('product_variant')
 export class ProductVariantEntity implements Translatable<ProductVariant> {

+ 1 - 1
modules/core/entity/product/product-translation.entity.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
 import { Translation } from '../../locale/locale-types';
-import { Product } from './product.interface';
 import { ProductEntity } from './product.entity';
+import { Product } from './product.interface';
 
 @Entity('product_translation')
 export class ProductTranslationEntity implements Translation<Product> {

+ 6 - 6
modules/core/entity/product/product.entity.ts

@@ -9,14 +9,14 @@ import {
     UpdateDateColumn,
 } from 'typeorm';
 import { Translatable } from '../../locale/locale-types';
-import { Product } from './product.interface';
-import { ProductTranslationEntity } from './product-translation.entity';
-import { ProductVariantEntity } from '../product-variant/product-variant.entity';
-import { ProductVariant } from '../product-variant/product-variant.interface';
+import { ProductOptionGroupEntity } from '../product-option-group/product-option-group.entity';
+import { ProductOptionGroup } from '../product-option-group/product-option-group.interface';
 import { ProductOptionEntity } from '../product-option/product-option.entity';
 import { ProductOption } from '../product-option/product-option.interface';
-import { ProductOptionGroup } from '../product-option-group/product-option-group.interface';
-import { ProductOptionGroupEntity } from '../product-option-group/product-option-group.entity';
+import { ProductVariantEntity } from '../product-variant/product-variant.entity';
+import { ProductVariant } from '../product-variant/product-variant.interface';
+import { ProductTranslationEntity } from './product-translation.entity';
+import { Product } from './product.interface';
 
 @Entity('product')
 export class ProductEntity implements Translatable<Product> {

+ 1 - 1
modules/core/entity/product/product.interface.ts

@@ -1,6 +1,6 @@
 import { LocaleString } from '../../locale/locale-types';
-import { ProductVariant } from '../product-variant/product-variant.interface';
 import { ProductOptionGroup } from '../product-option-group/product-option-group.interface';
+import { ProductVariant } from '../product-variant/product-variant.interface';
 
 export interface Product {
     id: number;

+ 1 - 1
modules/core/entity/user/user.entity.ts

@@ -1,7 +1,7 @@
 import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
+import { Role } from '../../auth/role';
 import { AddressEntity } from '../address/address.entity';
 import { User } from './user.interface';
-import { Role } from "../../auth/role";
 
 @Entity('user')
 export class UserEntity implements User {

+ 1 - 1
modules/core/entity/user/user.interface.ts

@@ -1,5 +1,5 @@
+import { Role } from '../../auth/role';
 import { Address } from '../address/address.interface';
-import { Role } from "../../auth/role";
 
 /**
  * A registered user of the system, either a Customer or Administrator. The User interface / entity is responsible

+ 9 - 6
modules/core/locale/locale-types.ts

@@ -8,21 +8,24 @@ export type TranslatableKeys<T> = { [K in keyof T]: T[K] extends LocaleString ?
 
 export type NonTranslateableKeys<T> = { [K in keyof T]: T[K] extends LocaleString ? never : K }[keyof T];
 
+// prettier-ignore
 /**
  * Entities which have localizable string properties should implement this type.
  */
 export type Translatable<T> =
     // Translatable must include all non-translatable keys of the interface
     { [K in NonTranslateableKeys<T>]: T[K] extends Array<any> ? Array<Translatable<T[K][number]>> : T[K] } &
-        // Translatable must not include any translatable keys (these are instead handled by the Translation)
-        { [K in TranslatableKeys<T>]?: never } & { translations: Translation<T>[] }; // Translatable must include a reference to all translations of the translatable keys
+    // Translatable must not include any translatable keys (these are instead handled by the Translation)
+    { [K in TranslatableKeys<T>]?: never } &
+    // Translatable must include a reference to all translations of the translatable keys
+    { translations: Translation<T>[] };
 
+// prettier-ignore
 /**
  * Translations of localizable entities should implement this type.
  */
 export type Translation<T> =
     // Translation must include the languageCode and a reference to the base Translatable entity it is associated with
-    {
-        languageCode: string;
-        base: Translatable<T>;
-    } & { [K in TranslatableKeys<T>]: string }; // Translation must include all translatable keys as a string type
+    { languageCode: string; base: Translatable<T>; } &
+    // Translation must include all translatable keys as a string type
+    { [K in TranslatableKeys<T>]: string };

+ 0 - 1
modules/core/locale/locale.service.ts

@@ -3,7 +3,6 @@ import { Translatable } from './locale-types';
 
 @Injectable()
 export class LocaleService {
-
     translate<T>(translatable: Translatable<T>): T {
         return translate(translatable);
     }

+ 3 - 3
modules/core/repository/product-repository.ts

@@ -1,10 +1,10 @@
 import { EntityRepository, Repository, SelectQueryBuilder } from 'typeorm';
+import { ProductOptionGroup } from '../entity/product-option-group/product-option-group.interface';
+import { ProductOption } from '../entity/product-option/product-option.interface';
+import { ProductVariant } from '../entity/product-variant/product-variant.interface';
 import { ProductEntity } from '../entity/product/product.entity';
 import { Product } from '../entity/product/product.interface';
 import { translate } from '../locale/locale.service';
-import { ProductVariant } from '../entity/product-variant/product-variant.interface';
-import { ProductOptionGroup } from '../entity/product-option-group/product-option-group.interface';
-import { ProductOption } from '../entity/product-option/product-option.interface';
 
 @EntityRepository(ProductEntity)
 export class ProductRepository extends Repository<ProductEntity> {

+ 12 - 11
modules/testing/mock-data.service.ts

@@ -1,20 +1,21 @@
 import * as faker from 'faker/locale/en_GB';
 import { Connection, createConnection } from 'typeorm';
-import { CustomerEntity } from '../core/entity/customer/customer.entity';
-import { ProductVariantEntity } from '../core/entity/product-variant/product-variant.entity';
-import { ProductEntity } from '../core/entity/product/product.entity';
-import { ProductVariantTranslationEntity } from '../core/entity/product-variant/product-variant-translation.entity';
-import { AddressEntity } from '../core/entity/address/address.entity';
-import { Role } from '../core/auth/role';
-import { ProductTranslationEntity } from '../core/entity/product/product-translation.entity';
 import { PasswordService } from '../core/auth/password.service';
-import { UserEntity } from '../core/entity/user/user.entity';
+import { Role } from '../core/auth/role';
+import { AddressEntity } from '../core/entity/address/address.entity';
 import { AdministratorEntity } from '../core/entity/administrator/administrator.entity';
-import { ProductOptionGroupEntity } from '../core/entity/product-option-group/product-option-group.entity';
+import { CustomerEntity } from '../core/entity/customer/customer.entity';
 import { ProductOptionGroupTranslationEntity } from '../core/entity/product-option-group/product-option-group-translation.entity';
-import { ProductOptionEntity } from '../core/entity/product-option/product-option.entity';
+import { ProductOptionGroupEntity } from '../core/entity/product-option-group/product-option-group.entity';
 import { ProductOptionTranslationEntity } from '../core/entity/product-option/product-option-translation.entity';
+import { ProductOptionEntity } from '../core/entity/product-option/product-option.entity';
+import { ProductVariantTranslationEntity } from '../core/entity/product-variant/product-variant-translation.entity';
+import { ProductVariantEntity } from '../core/entity/product-variant/product-variant.entity';
+import { ProductTranslationEntity } from '../core/entity/product/product-translation.entity';
+import { ProductEntity } from '../core/entity/product/product.entity';
+import { UserEntity } from '../core/entity/user/user.entity';
 
+// tslint:disable:no-console
 /**
  * A Class used for generating mock data.
  */
@@ -128,7 +129,7 @@ export class MockDataService {
 
             // 1 - 4 variants
             const variantCount = Math.floor(Math.random() * 4) + 1;
-            let variants = [];
+            const variants = [];
             for (let j = 0; j < variantCount; j++) {
                 const variant = new ProductVariantEntity();
                 const variantName = `${name} variant ${j + 1}`;

+ 2 - 4
modules/testing/populate.ts

@@ -1,5 +1,3 @@
-import { MockDataService } from "./mock-data.service";
+import { MockDataService } from './mock-data.service';
 
-new MockDataService()
-    .populate()
-    .then(() => process.exit(0));
+new MockDataService().populate().then(() => process.exit(0));

+ 17 - 17
test/app.e2e-spec.ts

@@ -1,24 +1,24 @@
-import request from 'supertest';
-import { Test } from '@nestjs/testing';
 import { INestApplication } from '@nestjs/common';
-import {AppModule} from '../modules/core/app.module';
+import { Test } from '@nestjs/testing';
+import request from 'supertest';
+import { AppModule } from '../modules/core/app.module';
 
 describe('AppController (e2e)', () => {
-  let app: INestApplication;
+    let app: INestApplication;
 
-  beforeAll(async () => {
-    const moduleFixture = await Test.createTestingModule({
-      imports: [AppModule],
-    }).compile();
+    beforeAll(async () => {
+        const moduleFixture = await Test.createTestingModule({
+            imports: [AppModule],
+        }).compile();
 
-    app = moduleFixture.createNestApplication();
-    await app.init();
-  });
+        app = moduleFixture.createNestApplication();
+        await app.init();
+    });
 
-  it('/ (GET)', () => {
-    return request(app.getHttpServer())
-      .get('/')
-      .expect(200)
-      .expect('Hello World!');
-  });
+    it('/ (GET)', () => {
+        return request(app.getHttpServer())
+            .get('/')
+            .expect(200)
+            .expect('Hello World!');
+    });
 });