Skip to content

Commit 0e1cc03

Browse files
committed
Merge branch 'feat/nginx-formatter' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/tools/index.ts # vite.config.ts
2 parents 3a3e8a0 + 535ba88 commit 0e1cc03

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
"monaco-editor": "^0.43.0",
162162
"naive-ui": "^2.35.0",
163163
"netmask": "^2.0.2",
164+
"nginx-config-formatter": "^1.4.5",
164165
"node-forge": "^1.3.1",
165166
"openpgp": "^5.11.1",
166167
"oui-data": "^1.0.10",

pnpm-lock.yaml

Lines changed: 20 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { tool as imageToCss } from './image-to-css';
6666
import { tool as jsonToGo } from './json-to-go';
6767
import { tool as jsonToSchema } from './json-to-schema';
6868
import { tool as markdownToHtml } from './markdown-to-html';
69+
import { tool as nginxFormatter } from './nginx-formatter';
6970
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
7071
import { tool as numeronymGenerator } from './numeronym-generator';
7172
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -275,6 +276,7 @@ export const toolsByCategory: ToolCategory[] = [
275276
jsonpathMemo,
276277
jsonToSchema,
277278
mongoObjectidConverter,
279+
nginxFormatter,
278280
],
279281
},
280282
{

src/tools/nginx-formatter/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Braces } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Nginx formatter',
6+
path: '/nginx-formatter',
7+
description: 'Format/prettify Nginx configuration files',
8+
keywords: ['nginx', 'formatter', 'prettier'],
9+
component: () => import('./nginx-formatter.vue'),
10+
icon: Braces,
11+
createdAt: new Date('2024-03-30'),
12+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import { formatContent } from 'nginx-config-formatter';
3+
import type { UseValidationRule } from '@/composable/validation';
4+
import { withDefaultOnError } from '@/utils/defaults';
5+
6+
const defaultValue = '{\n\t"hello": [\n\t\t"world"\n\t]\n}';
7+
const transformer = (value: string) => withDefaultOnError(() => formatContent(value), '');
8+
9+
const rules: UseValidationRule<string>[] = [
10+
{
11+
validator: (v: string) => v === '' || formatContent(v),
12+
message: 'Provided Nginx config is not valid.',
13+
},
14+
];
15+
</script>
16+
17+
<template>
18+
<format-transformer
19+
input-label="Your Nginx config"
20+
:input-default="defaultValue"
21+
input-placeholder="Paste your Nginx config here..."
22+
output-label="Prettified Nginx config"
23+
output-language="json"
24+
:input-validation-rules="rules"
25+
:transformer="transformer"
26+
/>
27+
</template>

0 commit comments

Comments
 (0)