### Install Node.js and npm
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/src/main/resources/static/readme.md
Ensures Node.js and npm are installed and accessible in the system's PATH. Verifies installations by checking their versions.
```bash
node --version
npm --version
```
--------------------------------
### Development Setup and Running
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
Instructions for setting up the development environment and running the Quarkus application. Requires JDK 17, Docker, and provides commands for database setup and application startup.
```bash
java -version
docker run -d --rm --name pg -ePOSTGRES_PASSWORD=postgres -p5432:5432 -t postgres
./gradlew quarkusDev
```
--------------------------------
### Install Project Dependencies and Compile TypeScript
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/src/main/resources/static/readme.md
Installs project dependencies using npm and starts the TypeScript compiler in watch mode. The compiler automatically recompiles TypeScript files to JavaScript when changes are detected.
```bash
npm install
npm run tsc -- -watch
```
--------------------------------
### Static Controller Example
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
A conceptual example of a Static Controller in Kotlin for serving versioned static assets.
```kotlin
package my.starter.controllers
import io.quarkus.qute.TemplatePath
import io.quarkus.qute.Template
import jakarta.inject.Inject
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.PathParam
import java.io.InputStream
import jakarta.ws.rs.Produces
import jakarta.ws.rs.core.MediaType
import jakarta.ws.rs.core.Response
@Path("/static/{version}/{resource:.*}")
class StaticController {
@Inject
@field:TemplatePath("static/${version}/${resource}") // Conceptual mapping
lateinit var staticTemplate: Template
@GET
fun getStaticResource(@PathParam("version") version: String, @PathParam("resource") resource: String): Response {
// In a real scenario, this would serve files from a specific directory structure
// For example: "src/main/resources/static/$version/$resource"
// And set appropriate Cache-Control headers.
println("Serving static resource: version=${version}, resource=${resource}")
// Placeholder response
return Response.ok("Content for ${resource} (version ${version})").header("Cache-Control", "public, max-age=31536000").build()
}
}
```
--------------------------------
### Freemarker UI Layout Inclusion
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
Example of how to include a sitewide Freemarker layout macro in a page template to apply common header, footer, and styling.
```freemarker
<@layout.layout>
This is the page content with header and footer and other common elements applied from layout macro.
@layout.layout>
```
--------------------------------
### TypeScript Auto-Compilation
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/src/main/resources/static/readme.md
Demonstrates how changes in TypeScript files within the 'static' folder are automatically compiled to JavaScript when the TypeScript compiler is running in watch mode.
```typescript
// Example: Update any .ts file in the static folder
// The compiler running in watch mode will automatically generate the corresponding .js file.
```
--------------------------------
### Static Asset URL Pattern
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
Illustrates the pattern used for serving static assets (CSS, JS, images) with versioned URLs to manage browser caching effectively. Changing the `release.version` property in `application.properties` forces a new download for updated assets.
```html
```
--------------------------------
### JOOQ Code Generation
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
Details on how JOOQ generates Kotlin code from the database schema using a Gradle task. This process involves running a PostgreSQL instance via Testcontainers, applying database migrations, and then generating the code. It's recommended to re-run this task after schema changes.
```bash
./gradlew generateJooqClasses
```
--------------------------------
### Page Specific JavaScript Inclusion
Source: https://github.com/praveenray/starter-web-app-kotlin-quarkus/blob/main/README.md
Demonstrates how to include page-specific JavaScript by defining a `pageJS` variable within a Freemarker template.
```freemarker
<#assign pageJS = "/users/new-user.js">
<@layout.layout>
@layout.layout>
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.