feat(api): setup nestjs

This commit is contained in:
Julian Tölle 2020-01-25 22:19:14 +01:00
commit db62d5d908
25 changed files with 10115 additions and 0 deletions

View file

@ -0,0 +1,3 @@
export enum ConnectionType {
SPOTIFY = "spotify"
}

View file

@ -0,0 +1,14 @@
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
import { ConnectionType } from "./connection-type.enum";
@Entity()
export class Connection {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column()
userID: string;
@Column()
type: ConnectionType;
}

View file

@ -0,0 +1,18 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ConnectionsController } from "./connections.controller";
describe("Connections Controller", () => {
let controller: ConnectionsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ConnectionsController]
}).compile();
controller = module.get<ConnectionsController>(ConnectionsController);
});
it("should be defined", () => {
expect(controller).toBeDefined();
});
});

View file

@ -0,0 +1,4 @@
import { Controller } from "@nestjs/common";
@Controller("connections")
export class ConnectionsController {}

View file

@ -0,0 +1,12 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { ConnectionsController } from "./connections.controller";
import { ConnectionsRepository } from "./connections.repository";
import { ConnectionsService } from "./connections.service";
@Module({
imports: [TypeOrmModule.forFeature([ConnectionsRepository])],
controllers: [ConnectionsController],
providers: [ConnectionsService]
})
export class ConnectionsModule {}

View file

@ -0,0 +1,5 @@
import { EntityRepository, Repository } from "typeorm";
import { Connection } from "./connection.entity";
@EntityRepository(Connection)
export class ConnectionsRepository extends Repository<Connection> {}

View file

@ -0,0 +1,18 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ConnectionsService } from "./connections.service";
describe("ConnectionsService", () => {
let service: ConnectionsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ConnectionsService]
}).compile();
service = module.get<ConnectionsService>(ConnectionsService);
});
it("should be defined", () => {
expect(service).toBeDefined();
});
});

View file

@ -0,0 +1,7 @@
import { Injectable } from "@nestjs/common";
import { ConnectionsRepository } from "./connections.repository";
@Injectable()
export class ConnectionsService {
constructor(private readonly connectionRepository: ConnectionsRepository) {}
}