Sneak Preview: Nuxt Coolify Module
Introduction
Over the last few months I've been working on a Nuxt module for Coolify, it wraps the Coolify API and provides a set of server utilities for Nuxt and Nitro.
The module is still in the early stages of development, but it already provides a set of useful utilities. It injects our Nitro server utilities to your Nuxt project, which can be used to interact with the Coolify API from your Nitro server endpoints.
Quickstart
Use npx nuxi module add nuxt-coolify
to automaticly add the module to your project or,
Install nuxt-coolify
using your package manager of choice and add it manually to your modules: ['nuxt-coolify']
array within your nuxt.config.ts
file.
A follow up article will cover the module and usage in more detail, please check the docs or join the Discord server for more help or information.
Setup
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-coolify']
})
NUXT_COOLIFY_INSTANCES_DEFAULT_BASE_URL=<your-coolify-url>
NUXT_COOLIFY_INSTANCES_DEFAULT_API_TOKEN=<your-coolify-api-token>
NUXT_COOLIFY_PROVIDERS_HETZNER_BASE_URL=<your-hetzner-api-url>
NUXT_COOLIFY_PROVIDERS_HETZNER_API_TOKEN=<your-hetzner-api-token>
Usage Example in a Nitro endpoint
// List all instances
export default defineEventHandler(async (event) => {
// check auth permissions
return useCoolify().instances()
})
// List all resources for a specific Coolify instance
import type { Instance } from 'nuxt-coolify'
export default defineEventHandler(async (event) => {
const name = getRouterParam(event, 'name')
const { instances } = useRuntimeConfig().coolify
if (name && !Object.prototype.hasOwnProperty.call(instances, name)) {
return createError({
statusCode: 500,
message: 'Provided Instance is not configured.',
})
}
// check auth permissions
return useCoolify().instances(name as Instance)
})
More soon
Stay tuned for the full article.