Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create kotlin-server-springboot project #93

Closed
wants to merge 4 commits into from
Closed

Conversation

jmfayard
Copy link
Collaborator

@jmfayard jmfayard commented Nov 27, 2020

Closes: #24

Kickstart a project kotlin-server

It provides a CRUD api to books and authors

Everyone could then reimplement it with $FAVORITE_FRAMEWORK
like Spring-Fu Ktor Micronaut Quarkus Vertx Http4k Javalin

@Path("/book")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Component
class BookResource(
val bookService: BookService
) {
@GET
@Path("/{id}")
fun getBook(@PathParam("id") id: Long) =
bookService.getBook(id)
@GET
fun getBooks(@BeanParam pagination: PaginationDto): PageDto<BookDto> =
bookService.getBooks(pagination)
@POST
fun createBook(dto: BookDto): Long? =
bookService.createBook(dto)
@POST
@Path("/{id}")
fun updateBook(@PathParam("id") id: Long, dto: BookDto) =
bookService.updateBook(id, dto)
@DELETE
@Path("/{id}")
fun deleteBook(@PathParam("id") id: Long) =
bookService.deleteBook(id)
}

@Path("/author")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Component
class AuthorResource(
val authorService: AuthorService
) {
@GET
@Path("/{id}")
fun getAuthor(@PathParam("id") id: Long) =
authorService.getAuthor(id)
@GET
fun getAuthors(@BeanParam pagination: PaginationDto): PageDto<AuthorDto> =
authorService.getAuthors(pagination)
@POST
fun createAuthor(dto: AuthorDto): Long? =
authorService.createAuthor(dto)
@POST
@Path("/{id}")
fun updateAuthor(@PathParam("id") id: Long, dto: AuthorDto) =
authorService.updateAuthor(id, dto)
}

@jmfayard jmfayard self-assigned this Nov 27, 2020
@github-actions
Copy link

Buildscan url for run 387431201
https://gradle.com/s/vegk5o65a5im2

@jmfayard
Copy link
Collaborator Author

@LouisCAD I started a kotlin-server-springboot module that provides CRUD interfaces to authors and books
Hopefully others will volunteer to add a similar implementation with spring-fu, ktor, http4k or whatever framework they like.
Any feedback so far?

@jmfayard
Copy link
Collaborator Author

jmfayard commented Nov 28, 2020

@philiplb could you give me feedback on this REST api?
I plan to reimplement it with multiple server frameworks
like Spring-Fu Ktor Micronaut Quarkus Vertx Http4k Javalin

@jmfayard
Copy link
Collaborator Author

Closing this, it's better to have a separate project

@jmfayard jmfayard closed this Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kickstart a project kotlin-server
1 participant