Skip to content

Commit

Permalink
feat(examples): add json2csv
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 13, 2023
1 parent 5a7a42a commit 0973d61
Show file tree
Hide file tree
Showing 20 changed files with 287 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/p-S3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@pergel/module-s3": "0.0.0",
"@pergel/nuxt": "^0.0.4"
"@pergel/nuxt": "^0.1.0"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
2 changes: 1 addition & 1 deletion examples/p-S3/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.0.4
# Version: 0.1.0
rocket:
S3:
env:
Expand Down
24 changes: 24 additions & 0 deletions examples/p-json2csv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
2 changes: 2 additions & 0 deletions examples/p-json2csv/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
ignore-workspace-root-check=true
75 changes: 75 additions & 0 deletions examples/p-json2csv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Nuxt 3 Minimal Starter

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

## Setup

Make sure to install the dependencies:

```bash
# npm
npm install

# pnpm
pnpm install

# yarn
yarn install

# bun
bun install
```

## Development Server

Start the development server on `http://localhost:3000`:

```bash
# npm
npm run dev

# pnpm
pnpm run dev

# yarn
yarn dev

# bun
bun run dev
```

## Production

Build the application for production:

```bash
# npm
npm run build

# pnpm
pnpm run build

# yarn
yarn build

# bun
bun run build
```

Locally preview production build:

```bash
# npm
npm run preview

# pnpm
pnpm run preview

# yarn
yarn preview

# bun
bun run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
5 changes: 5 additions & 0 deletions examples/p-json2csv/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>
14 changes: 14 additions & 0 deletions examples/p-json2csv/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: [
'@pergel/nuxt',
],
pergel: {
projects: {
rocket: {
json2csv: true,
},
},
},
})
24 changes: 24 additions & 0 deletions examples/p-json2csv/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "nuxt-app",
"type": "module",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@json2csv/node": "^7.0.4",
"@pergel/nuxt": "^0.1.0",
"node-cron": "^3.0.3"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@types/node-cron": "^3.0.11",
"nuxt": "^3.8.2",
"vue": "^3.3.8",
"vue-router": "^4.2.5"
}
}
9 changes: 9 additions & 0 deletions examples/p-json2csv/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.1.0
rocket:
json2csv:
# If pergel cli is installed, you can run `pergel install` automatically to install
packageJson:
dependencies: "@json2csv/node@^7.0.4"
devDependencies: ""
Binary file added examples/p-json2csv/public/favicon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions examples/p-json2csv/server/api/csvDownload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const datas = [
{
car: 'Audi',
price: 40000,
color: 'blue',
},
{
car: 'BMW',
price: 35000,
color: 'black',
},
{
car: 'Porsche',
price: 6000,
color: 'green',
},
]

export default defineEventHandler(async (event) => {
try {
const { setResponseCsv } = await pergelRocket().json2csv().use({
data: datas,
})

await setResponseCsv({
event,
csv: true,
})
}
catch (error: any) {
return error.message
}
})
30 changes: 30 additions & 0 deletions examples/p-json2csv/server/api/csvTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const datas = [
{
car: 'Audi',
price: 40000,
color: 'blue',
},
{
car: 'BMW',
price: 35000,
color: 'black',
},
{
car: 'Porsche',
price: 6000,
color: 'green',
},
]

export default defineEventHandler(async () => {
try {
const { csv } = await pergelRocket().json2csv().use({
data: datas,
})

return csv
}
catch (error: any) {
return error.message
}
})
3 changes: 3 additions & 0 deletions examples/p-json2csv/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
4 changes: 4 additions & 0 deletions examples/p-json2csv/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}
2 changes: 1 addition & 1 deletion examples/p-nodeCron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@pergel/nuxt": "^0.0.4",
"@pergel/nuxt": "^0.1.0",
"node-cron": "^3.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/p-nodeCron/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.0.4
# Version: 0.1.0
rocket:
nodeCron:
# If pergel cli is installed, you can run `pergel install` automatically to install
Expand Down
2 changes: 1 addition & 1 deletion examples/p-ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@aws-sdk/client-ses": "^3.470.0",
"@pergel/nuxt": "^0.0.4"
"@pergel/nuxt": "^0.1.0"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
2 changes: 1 addition & 1 deletion examples/p-ses/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.0.4
# Version: 0.1.0
rocket:
ses:
env:
Expand Down
65 changes: 57 additions & 8 deletions examples/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0973d61

Please sign in to comment.