-
-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #424 from Dokploy/canary
v0.8.0
- Loading branch information
Showing
226 changed files
with
33,624 additions
and
2,266 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LEMON_SQUEEZY_API_KEY="" | ||
LEMON_SQUEEZY_STORE_ID="" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# dev | ||
.yarn/ | ||
!.yarn/releases | ||
.vscode/* | ||
!.vscode/launch.json | ||
!.vscode/*.code-snippets | ||
.idea/workspace.xml | ||
.idea/usage.statistics.xml | ||
.idea/shelf | ||
|
||
# deps | ||
node_modules/ | ||
|
||
# env | ||
.env | ||
.env.production | ||
|
||
# logs | ||
logs/ | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
# misc | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``` | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
``` | ||
open http://localhost:3000 | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "my-app", | ||
"scripts": { | ||
"dev": "tsx watch src/index.ts" | ||
}, | ||
"dependencies": { | ||
"@hono/node-server": "^1.12.1", | ||
"hono": "^4.5.8", | ||
"dotenv": "^16.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.17", | ||
"tsx": "^4.7.1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { serve } from "@hono/node-server"; | ||
import { config } from "dotenv"; | ||
import { Hono } from "hono"; | ||
import { cors } from "hono/cors"; | ||
import { validateLemonSqueezyLicense } from "./utils"; | ||
|
||
config(); | ||
|
||
const app = new Hono(); | ||
|
||
app.use( | ||
"/*", | ||
cors({ | ||
origin: ["http://localhost:3000", "http://localhost:3001"], // Ajusta esto a los orígenes de tu aplicación Next.js | ||
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"], | ||
allowHeaders: ["Content-Type", "Authorization"], | ||
exposeHeaders: ["Content-Length", "X-Kuma-Revision"], | ||
maxAge: 600, | ||
credentials: true, | ||
}), | ||
); | ||
|
||
export const LEMON_SQUEEZY_API_KEY = process.env.LEMON_SQUEEZY_API_KEY; | ||
export const LEMON_SQUEEZY_STORE_ID = process.env.LEMON_SQUEEZY_STORE_ID; | ||
|
||
app.get("/v1/health", (c) => { | ||
return c.text("Hello Hono!"); | ||
}); | ||
|
||
app.post("/v1/validate-license", async (c) => { | ||
const { licenseKey } = await c.req.json(); | ||
|
||
if (!licenseKey) { | ||
return c.json({ error: "License key is required" }, 400); | ||
} | ||
|
||
try { | ||
const licenseValidation = await validateLemonSqueezyLicense(licenseKey); | ||
|
||
if (licenseValidation.valid) { | ||
return c.json({ | ||
valid: true, | ||
message: "License is valid", | ||
metadata: licenseValidation.meta, | ||
}); | ||
} | ||
return c.json( | ||
{ | ||
valid: false, | ||
message: licenseValidation.error || "Invalid license", | ||
}, | ||
400, | ||
); | ||
} catch (error) { | ||
console.error("Error during license validation:", error); | ||
return c.json({ error: "Internal server error" }, 500); | ||
} | ||
}); | ||
|
||
const port = 4000; | ||
console.log(`Server is running on port ${port}`); | ||
|
||
serve({ | ||
fetch: app.fetch, | ||
port, | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export interface LemonSqueezyLicenseResponse { | ||
valid: boolean; | ||
error?: string; | ||
meta?: { | ||
store_id: string; | ||
order_id: number; | ||
order_item_id: number; | ||
product_id: number; | ||
product_name: string; | ||
variant_id: number; | ||
variant_name: string; | ||
customer_id: number; | ||
customer_name: string; | ||
customer_email: string; | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { LEMON_SQUEEZY_API_KEY, LEMON_SQUEEZY_STORE_ID } from "."; | ||
import type { LemonSqueezyLicenseResponse } from "./types"; | ||
|
||
export const validateLemonSqueezyLicense = async ( | ||
licenseKey: string, | ||
): Promise<LemonSqueezyLicenseResponse> => { | ||
try { | ||
const response = await fetch( | ||
"https://api.lemonsqueezy.com/v1/licenses/validate", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"x-api-key": LEMON_SQUEEZY_API_KEY as string, | ||
}, | ||
body: JSON.stringify({ | ||
license_key: licenseKey, | ||
store_id: LEMON_SQUEEZY_STORE_ID as string, | ||
}), | ||
}, | ||
); | ||
|
||
return response.json(); | ||
} catch (error) { | ||
console.error("Error validating license:", error); | ||
return { valid: false, error: "Error validating license" }; | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"types": ["node"], | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "hono/jsx" | ||
} | ||
} |
Oops, something went wrong.