Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move to typescript #26

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ charset = utf-8
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
end_of_line = lf

[*.yml]
indent_style = space
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
dist/
node_modules/
workers-site/node_modules/
workers-site/worker/**/*.js
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"extends": [
"@nodecraft"
"@nodecraft/eslint-config/typescript"
],
"plugins": [
"unicorn",
Expand All @@ -11,4 +11,4 @@
"rules": {
"node/no-unsupported-features/es-syntax": "off"
}
}
}
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
${{ runner.os }}-node-

- run: npm ci
- run: npm test
- run: npm run lint
- run: npm run check-types
- run: npm run test

deploy:
runs-on: ubuntu-latest
Expand All @@ -54,14 +56,14 @@ jobs:
- run: npm ci

- name: Publish
uses: cloudflare/wrangler-action@2.0.0
uses: cloudflare/wrangler-action@v3.3.2
# only publish if a direct `push`/`repository_dispatch`
# publish non-production deploy if it's a fork
if: github.event_name == 'repository_dispatch' || github.event_name == 'push' && github.repository_owner != 'Cherry'
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: "publish"
command: "deploy"

- name: Publish (production)
uses: cloudflare/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ worker/
node_modules/
.cargo-ok
.env
*.log
*.log
.wrangler
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact = true
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ placeholders.dev generates custom placeholder images on the fly, such as the exa
## Technology

This project makes use of Cloudflare Workers, and Cloudflare Workers Sites via Workers KV. It also implements a HTMLRewriter to update the total Cloudflare PoPs in multiple locations.

### Available API Options

- `width`
Expand Down Expand Up @@ -39,20 +40,11 @@ Example URL: `https://images.placeholders.dev/?width=1055&height=100&text=Made%2
### Prerequisites

#### Wrangler
`wrangler` is a CLI tool from Cloudflare, designed to push projects to Cloudflare Workers. See [Cloudflare's documentation](https://developers.cloudflare.com/workers/tooling/wrangler/) for more information.

Install it with npm:
- `npm i @cloudflare/wrangler -g`

After install run `wrangler config` and follow the prompts to add your Wrangler API token. Follow the instructions in [Cloudflare's](https://developers.cloudflare.com/workers/quickstart/#api-token) docs for information on this.


### Build
- `wrangler build`
`wrangler` is a CLI tool from Cloudflare, designed to push projects to Cloudflare Workers. See [Cloudflare's documentation](https://developers.cloudflare.com/workers/wrangler/install-and-update/) for more information.

### Run

- `npm run start:dev` (this will use `cloudworker` to run a server on `localhost:3000` mimicking the API Worker)
- `npm run start:dev` (this will use `wrangler dev` to locally start the Cloudflare Worker for testing)

or

Expand All @@ -62,10 +54,6 @@ or

- `npm run publish:staging` (push to `placeholders-staging` workers.dev)

or

- `npm run publish:preview` (push to Cloudflare Workers preview builder)

## Production

- `npm run publish:prod` (publishes to placeholders.dev via Workers)
Loading
Loading