Skip to content

Commit

Permalink
Add esp-web-install-button
Browse files Browse the repository at this point in the history
  • Loading branch information
zomco committed Jan 15, 2024
1 parent 09d9655 commit 2c4b035
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
15 changes: 1 addition & 14 deletions app/api/upload/route.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import { put } from '@vercel/blob'
import { NextResponse } from 'next/server'
import { customAlphabet } from 'nanoid'

export const runtime = 'edge'

const nanoid = customAlphabet(
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
7
) // 7-character random string
export async function POST(req: Request) {
const file = req.body || ''
const contentType = req.headers.get('content-type') || 'text/plain'
const filename = `${nanoid()}.${contentType.split('/')[1]}`
const blob = await put(filename, file, {
contentType,
access: 'public',
})

return NextResponse.json(blob)
return NextResponse.json({})
}
9 changes: 8 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import Script from 'next/script'
import * as React from 'react'
import styles from './page.module.css'

declare global {
namespace JSX {
interface IntrinsicElements {
'esp-web-install-button': any;
}
}
}

export default function Home() {
return (
Expand All @@ -15,7 +22,7 @@ export default function Home() {
<li>Get firmware installed and connected in less than 3 minutes!</li>
</ol>
<div className={styles.connect}>
<esp-web-install-button manifest="https://firmware.esphome.io/esphome-web/manifest.json" />
<esp-web-install-button manifest="/manifest_owcare.json" />
</div>
</div>
<div className="sm:absolute sm:bottom-0 w-full px-20 py-10 flex justify-between">
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
Expand Down

0 comments on commit 2c4b035

Please sign in to comment.