diff --git a/apps/golinks-v2/.env b/apps/golinks-v2/.env new file mode 100644 index 0000000..c498ab5 --- /dev/null +++ b/apps/golinks-v2/.env @@ -0,0 +1,7 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +DATABASE_URL="file:./dev.db" \ No newline at end of file diff --git a/apps/golinks-v2/README.md b/apps/golinks-v2/README.md index ad96177..e2ab94a 100644 --- a/apps/golinks-v2/README.md +++ b/apps/golinks-v2/README.md @@ -1,5 +1,8 @@ # `@andreijiroh-dev/golinks-rewrite` +[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io) +[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/andreijiroh-dev/api-servers/tree/main/apps/golinks-v2) + Made as part of [Hack Club Arcade / Summer of Making 2024](https://hackclub.com/arcade) ([see the scrapbook][scrapbook] for all the deets). A rewrite of [`golinks` Cloudflare Workers code](../golinks/), now with OpenAPI 3.1 @@ -8,7 +11,7 @@ powered by [chanfana](https://github.com/cloudflare/chanfana) and ## Environments -- Staging: https://golinks-next-staging.ajhalili2006.workers.dev (use `gostg_4487705fd01888c0efeb78cf` as API key, might reset data) +- Staging: https://golinks-next-staging.ajhalili2006.workers.dev (see the docs below for testing in staging) - Production: https://golinks-next.ajhalili2006.workers.dev ## Development diff --git a/apps/golinks-v2/package.json b/apps/golinks-v2/package.json index 2499b8d..6a6541d 100644 --- a/apps/golinks-v2/package.json +++ b/apps/golinks-v2/package.json @@ -1,6 +1,6 @@ { - "name": "cloudflare-workers-openapi", - "version": "0.0.1", + "name": "@andreijiroh-dev/golinks-rewrite", + "version": "0.1.0", "private": true, "scripts": { "deps:upgrade": "yarn yarn-upgrade-all", @@ -30,13 +30,13 @@ "zod": "^3.23.8" }, "devDependencies": { - "@cloudflare/workers-types": "^4.20240712.0", + "@cloudflare/workers-types": "^4.20240718.0", "@types/node": "^20.14.11", "@types/service-worker-mock": "^2.0.4", "prisma": "^5.17.0", "ts-node": "^10.9.2", "typescript": "^5.5.3", - "wrangler": "^3.65.0", + "wrangler": "^3.65.1", "yarn-upgrade-all": "^0.7.2" }, "type": "module" diff --git a/apps/golinks-v2/scripts/generate-api-token.ts b/apps/golinks-v2/scripts/generate-api-token.ts new file mode 100755 index 0000000..aba6cb8 --- /dev/null +++ b/apps/golinks-v2/scripts/generate-api-token.ts @@ -0,0 +1,8 @@ +import { generateSlug } from "../src/lib/utils"; +import { env } from "process"; + +const tokenPrefix = "goprod_"; +const username = env.GITHUB_USERNAME || "ajhalili2006"; +const token = generateSlug(48); + +console.log(`${tokenPrefix}${username}-${token}`); diff --git a/apps/golinks-v2/worker-configuration.d.ts b/apps/golinks-v2/worker-configuration.d.ts index a9999f7..93febe4 100644 --- a/apps/golinks-v2/worker-configuration.d.ts +++ b/apps/golinks-v2/worker-configuration.d.ts @@ -1,7 +1,8 @@ -// Generated by Wrangler on Wed Jul 17 2024 01:25:40 GMT+0800 (Philippine Standard Time) -// by running `wrangler types` +// Generated by Wrangler on Thu Jul 18 2024 01:03:07 GMT+0800 (Philippine Standard Time) +// by running `wrangler types --env staging` -export interface Env { - DEPLOY_ENV: 'production' | 'staging' | 'development'; - golinks: D1Database; +interface Env { + DEPLOY_ENV: "staging"; + ADMIN_KEY: "GOLINKS_ADMIN_API_KEY"; + golinks: D1Database; }