generated from antfu/starter-ts
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
5,614 additions
and
198 deletions.
There are no files selected for viewing
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,26 @@ | ||
# Contributing | ||
|
||
Contributions are welcome and will be fully credited! | ||
|
||
We accept contributions via Pull Requests on [Github](https://github.com/{{ githubAccount }}/{{ name }}). | ||
|
||
## Pull Requests | ||
|
||
Here are some guidelines to make the process smoother: | ||
|
||
- **Add a test** - New features and bugfixes need tests. If you find it difficult to test, please tell us in the pull request and we will try to help you! | ||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
- **Run `npm test` locally** - This will allow you to go faster | ||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
- **Send coherent history** - Make sure your commits message means something | ||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
## Creating issues | ||
|
||
### Bug reports | ||
|
||
Always try to provide as much information as possible. If you are reporting a bug, try to provide a repro on jsfiddle.net (or anything else) or a stacktrace at the very least. This will help us check the problem quicker. | ||
|
||
### Feature requests | ||
|
||
Lay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting. |
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 |
---|---|---|
@@ -1 +1 @@ | ||
github: [antfu] | ||
github: [CodeDredd] |
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,9 @@ | ||
<!-- | ||
IMPORTANT: Please provide as much information as possible: | ||
- Reporting a bug: Provide a reproduction using this template: https://github.com/piniajs/bug-report | ||
If no reproduction is provided, your issue will be closed or moved to a discussion. | ||
- Feature request: lay out the reasoning behind it and propose an API for it | ||
--> |
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,46 @@ | ||
name: 🐞 Bug report | ||
description: Create a report to help us improve Pinia ORM | ||
labels: [pending triage] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Please use a template below to create a minimal reproduction | ||
👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz | ||
👉 https://codesandbox.io/s/github/nuxt/starter/tree/v3-codesandbox | ||
- type: textarea | ||
id: bug-env | ||
attributes: | ||
label: Environment | ||
description: You can use e.g. `npx nuxi info` for nuxt to fill this section | ||
placeholder: Environment | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduction | ||
attributes: | ||
label: Reproduction | ||
description: Please provide a link to a repo that can reproduce the problem you ran into. A [**minimal reproduction**](https://v3.nuxtjs.org/community/reporting-bugs#create-a-minimal-reproduction) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided we might close it. | ||
placeholder: Reproduction | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: bug-description | ||
attributes: | ||
label: Describe the bug | ||
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! | ||
placeholder: Bug description | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: additonal | ||
attributes: | ||
label: Additional context | ||
description: If applicable, add any other context about the problem here` | ||
- type: textarea | ||
id: logs | ||
attributes: | ||
label: Logs | ||
description: | | ||
Optional if provided reproduction. Please try not to insert an image but copy paste the log text. | ||
render: shell |
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,10 @@ | ||
contact_links: | ||
- name: 💬 Discussions | ||
url: https://github.com/CodeDredd/pinia-orm/discussions | ||
about: Ask a question or discuss about Pinia ORM | ||
- name: ☝ Ideas | ||
url: https://github.com/CodeDredd/pinia-orm/discussions/new?category=Ideas | ||
about: Start a discussion to improve Pinia | ||
- name: ❤ GitHub Sponsors | ||
url: https://github.com/sponsors/codedredd | ||
about: Like this project? Please consider supporting the author. |
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,32 @@ | ||
name: 🚀 Feature request | ||
description: Suggest a feature that will improve Pinia ORM | ||
labels: [pending triage] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thank you for taking the time to fill out this feature request! | ||
- type: textarea | ||
id: feature-description | ||
attributes: | ||
label: Describe the feature | ||
description: A clear and concise description of what you think would be a helpful addition to Nuxt, including the possible use cases and alternatives you have considered. If you have a working prototype or module that implements it, please include a link. | ||
placeholder: Feature description | ||
validations: | ||
required: true | ||
- type: checkboxes | ||
id: additional-info | ||
attributes: | ||
label: Additional information | ||
description: Additional information that helps us decide how to proceed. | ||
options: | ||
- label: Would you be willing to help implement this feature? | ||
- label: Could this feature be implemented as a module? | ||
- type: checkboxes | ||
id: required-info | ||
attributes: | ||
label: Final checks | ||
description: Before submitting, please make sure you do the following | ||
options: | ||
- label: Check existing [discussions](https://github.com/CodeDredd/pinia-orm/discussions) and [issues](https://github.com/CodeDredd/pinia-orm/issues). | ||
required: true |
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,32 @@ | ||
<!--- | ||
☝️ PR title should follow conventional commits (https://conventionalcommits.org) | ||
--> | ||
|
||
### 🔗 Linked issue | ||
|
||
<!-- Please ensure there is an open issue and mention its number as #123 --> | ||
|
||
### ❓ Type of change | ||
|
||
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> | ||
|
||
- [ ] 📖 Documentation (updates to the documentation or readme) | ||
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue) | ||
- [ ] 👌 Enhancement (improving an existing functionality like performance) | ||
- [ ] ✨ New feature (a non-breaking change that adds functionality) | ||
- [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change) | ||
|
||
### 📚 Description | ||
|
||
<!-- Describe your changes in detail --> | ||
<!-- Why is this change required? What problem does it solve? --> | ||
<!-- If it resolves an open issue, please link to the issue here. For example "Resolves #1337" --> | ||
|
||
### 📝 Checklist | ||
|
||
<!-- Put an `x` in all the boxes that apply. --> | ||
<!-- If your change requires a documentation PR, please link it appropriately --> | ||
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> | ||
|
||
- [ ] I have linked an issue or discussion. | ||
- [ ] I have updated the documentation accordingly. |
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ lib-cov | |
logs | ||
node_modules | ||
temp | ||
.idea |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,38 +1,123 @@ | ||
# pkg-placeholder | ||
# h3-compress | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![bundle][bundle-src]][bundle-href] | ||
[![JSDocs][jsdocs-src]][jsdocs-href] | ||
[![License][license-src]][license-href] | ||
|
||
_description_ | ||
## Features | ||
|
||
> **Note**: | ||
> Replace `pkg-placeholder`, `_description_` and `antfu` globally to use this template. | ||
✔️ **Zlib Compressions:** You can use zlib compression (brotli, gzip and deflate) | ||
|
||
✔️ **Stream Compression:** You can use native stream compressions (gzip, deflate) | ||
|
||
✔️ **Compression Detection:** It uses the best compression which is accepted | ||
|
||
|
||
|
||
## Install | ||
|
||
```bash | ||
# Using npm | ||
npm install h3-compress | ||
|
||
# Using yarn | ||
yarn add h3-compress | ||
|
||
# Using pnpm | ||
pnpm add h3-compress | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { createServer } from 'node:http' | ||
import { createApp, eventHandler, toNodeListener } from 'h3' | ||
import { useCompressionStream } from 'h3-compress' | ||
|
||
const app = createApp({ onBeforeResponse: useCompressionStream }) // or { onBeforeResponse: useCompression } | ||
app.use( | ||
'/', | ||
eventHandler(() => 'Hello world!'), | ||
) | ||
|
||
createServer(toNodeListener(app)).listen(process.env.PORT || 3000) | ||
``` | ||
|
||
Example using <a href="https://github.com/unjs/listhen">listhen</a> for an elegant listener: | ||
|
||
```ts | ||
import { createApp, eventHandler, toNodeListener } from 'h3' | ||
import { listen } from 'listhen' | ||
import { useCompressionStream } from 'h3-compress' | ||
|
||
const app = createApp({ onBeforeResponse: useCompressionStream }) // or { onBeforeResponse: useCompression } | ||
app.use( | ||
'/', | ||
eventHandler(() => 'Hello world!'), | ||
) | ||
|
||
listen(toNodeListener(app)) | ||
``` | ||
|
||
## Nuxt 3 Usage | ||
|
||
If you want to use it in nuxt 3 you can define a nitro plugin. But there only the Zlib compression works | ||
Create a new file in `server/plugins/compression.ts` | ||
|
||
````ts | ||
import { useCompression } from 'h3-compress' | ||
|
||
export default defineNitroPlugin((nitro) => { | ||
nitro.hooks.hook('render:response', async (response, { event }) => { | ||
if (!response.headers?.['content-type'].startsWith('text/html')) | ||
return | ||
|
||
await useCompression(event, response) | ||
}) | ||
}) | ||
```` | ||
|
||
## Utilities | ||
|
||
H3 has a concept of composable utilities that accept `event` (from `eventHandler((event) => {})`) as their first argument and `response` as their second. | ||
|
||
#### Zlib Compression | ||
|
||
- `useGZipCompression(event, response)` | ||
- `useDeflateCompression(event, response)` | ||
- `useBrotliCompression(event, response)` | ||
- `useCompression(event, response)` | ||
|
||
#### Stream Compression | ||
|
||
- `useGZipCompressionStream(event, response)` | ||
- `useDeflateCompressionStream(event, response)` | ||
- `useCompressionStream(event, response)` | ||
|
||
## Sponsors | ||
|
||
<p align="center"> | ||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> | ||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/> | ||
<a href="https://pinia-orm.codedredd.de/sponsorkit/sponsors.png"> | ||
<img src='https://pinia-orm.codedredd.de/sponsorkit/sponsors.svg'/> | ||
</a> | ||
</p> | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu) | ||
[MIT](./LICENSE) License © 2023-PRESENT [Gregor Becker](https://github.com/CodeDredd) | ||
|
||
|
||
<!-- Badges --> | ||
|
||
[npm-version-src]: https://img.shields.io/npm/v/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-version-href]: https://npmjs.com/package/pkg-placeholder | ||
[npm-downloads-src]: https://img.shields.io/npm/dm/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-downloads-href]: https://npmjs.com/package/pkg-placeholder | ||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669&label=minzip | ||
[bundle-href]: https://bundlephobia.com/result?p=pkg-placeholder | ||
[license-src]: https://img.shields.io/github/license/antfu/pkg-placeholder.svg?style=flat&colorA=080f12&colorB=1fa669 | ||
[license-href]: https://github.com/antfu/pkg-placeholder/blob/main/LICENSE | ||
[npm-version-src]: https://img.shields.io/npm/v/h3-compress?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-version-href]: https://npmjs.com/package/h3-compress | ||
[npm-downloads-src]: https://img.shields.io/npm/dm/h3-compress?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-downloads-href]: https://npmjs.com/package/h3-compress | ||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/h3-compress?style=flat&colorA=080f12&colorB=1fa669&label=minzip | ||
[bundle-href]: https://bundlephobia.com/result?p=h3-compress | ||
[license-src]: https://img.shields.io/github/license/CodeDredd/h3-compress.svg?style=flat&colorA=080f12&colorB=1fa669 | ||
[license-href]: https://github.com/CodeDredd/h3-compress/blob/main/LICENSE | ||
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669 | ||
[jsdocs-href]: https://www.jsdocs.io/package/pkg-placeholder | ||
[jsdocs-href]: https://www.jsdocs.io/package/h3-compress |
Oops, something went wrong.