This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.codify.springbootgae.movie; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Service; | |
import java.util.List; | |
import java.util.Optional; | |
@Service | |
public class MovieService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.codify.springbootgae.movie; | |
import org.springframework.data.repository.CrudRepository; | |
import java.util.List; | |
import java.util.Optional; | |
public interface MovieRepository extends CrudRepository<Movie,Long> { | |
List<Movie> findAll(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.codify.springbootgae.movie; | |
import lombok.AllArgsConstructor; | |
import lombok.Data; | |
import lombok.NoArgsConstructor; | |
import javax.persistence.*; | |
@Data | |
@AllArgsConstructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.codify.springbootgae.movie; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.*; | |
import java.util.List; | |
import java.util.Optional; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { LightsaberController } from './lightsaber.controller'; | |
import { LightsaberService } from './lightsaber.service'; | |
import { Lightsaber } from './lightsaber.entity'; | |
import { TypeOrmModule } from '@nestjs/typeorm'; | |
@Module({ | |
controllers: [LightsaberController], | |
providers: [LightsaberService], | |
imports: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | |
@Entity() | |
export class Lightsaber { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() | |
name: string; | |
@Column() | |
color: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Get, Post, Body, Param, Put, Delete } from '@nestjs/common'; | |
import { LightsaberService } from './lightsaber.service'; | |
import { Lightsaber } from './lightsaber.entity'; | |
@Controller('light-saber') | |
export class LightsaberController { | |
constructor(private lightsaberService: LightsaberService) { } | |
@Get() | |
getAll() { | |
return this.lightsaberService.getAll(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { Lightsaber } from './lightsaber.entity'; | |
import { Repository, DeleteResult } from 'typeorm'; | |
import { InjectRepository } from '@nestjs/typeorm'; | |
@Injectable() | |
export class LightsaberService { | |
constructor( | |
@InjectRepository(Lightsaber) | |
private lightsaberRepository: Repository<Lightsaber>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NestFactory } from '@nestjs/core'; | |
import { AppModule } from './app.module'; | |
const HOST = '0.0.0.0'; | |
const PORT = Number(process.env.PORT) || 8080; | |
async function bootstrap() { | |
const app = await NestFactory.create(AppModule); | |
// app.enableCors(); | |
await app.listen(PORT, HOST).then(() => { | |
// tslint:disable-next-line:no-console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "star-wars-backend", | |
"version": "0.0.1", | |
"description": "", | |
"author": "Nils Weiser", | |
"license": "MIT", | |
"main": "dist/main.js", | |
"scripts": { | |
"prepare": "npm run build", | |
"pretest": "npm run build", |
NewerOlder