Skip to content

Commit

Permalink
Merge pull request #407 from aXenDeveloper/refactor/fetcher
Browse files Browse the repository at this point in the history
refactor(frontend)!: Remove try/catch from server action, add this in…
  • Loading branch information
aXenDeveloper authored Jul 9, 2024
2 parents 8731d8d + 5df6fbc commit 20c643a
Show file tree
Hide file tree
Showing 148 changed files with 948 additions and 1,598 deletions.
2 changes: 1 addition & 1 deletion apps/backend/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type Mutation {
admin__core_email_settings__edit(color_primary: String!, color_primary_foreground: String!, smtp_host: String!, smtp_password: String!, smtp_port: Int!, smtp_secure: Boolean!, smtp_user: String!): ShowAdminEmailSettingsServiceObj!
admin__core_email_settings__test(from: String!, message: String!, preview_text: String, subject: String!, to: String!): String!
admin__core_files__delete(id: Int!): String!
admin__core_groups__create(content: ContentCreateAdminGroups!, name: [TextLanguageInput!]!): ShowAdminGroups!
admin__core_groups__delete(id: Int!): String!
admin__core_groups__edit(content: ContentCreateAdminGroups!, id: Int!, name: [TextLanguageInput!]!): ShowAdminGroups!
admin__core_languages__create(allow_in_input: Boolean!, code: String!, locale: String!, name: String!, time_24: Boolean!, timezone: String!): ShowCoreLanguages!
Expand Down Expand Up @@ -233,7 +234,6 @@ type Mutation {
admin_sessions__sign_out: String!
core_editor_files__delete(id: Int!, security_key: String): String!
core_editor_files__upload(file: Upload!, folder: String!, plugin: String!): ShowCoreFiles!
core_groups__admin_create(content: ContentCreateAdminGroups!, name: [TextLanguageInput!]!): ShowAdminGroups!
core_members__avatar__delete: String!
core_members__avatar__upload(file: Upload!): UploadAvatarCoreMembersObj!
core_members__delete(id: Int!): String!
Expand Down
32 changes: 14 additions & 18 deletions apps/docs-new/content/docs/dev/captcha.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,19 @@ interface Args extends Core_Sessions__Sign_UpMutationVariables {
}

export const mutationApi = async (variables: Args) => {
try {
const { data } = await fetcher<
Core_Sessions__Sign_UpMutation,
Core_Sessions__Sign_UpMutationVariables
>({
query: Core_Sessions__Sign_Up,
variables,
headers: {
'x-vitnode-captcha-token': variables.token, // [!code highlight]
},
});

revalidatePath('/', 'layout');

return { data };
} catch (error) {
return { error };
}
const data = await fetcher<
Core_Sessions__Sign_UpMutation,
Core_Sessions__Sign_UpMutationVariables
>({
query: Core_Sessions__Sign_Up,
variables,
headers: {
'x-vitnode-captcha-token': variables.token, // [!code highlight]
},
});

revalidatePath('/', 'layout');

return data;
};
```
1 change: 0 additions & 1 deletion apps/docs-new/content/docs/dev/cron.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Cron } from "@nestjs/schedule";

@Injectable()
export class ClearCoreMembersCron {

@Cron('45 * * * * *')
async exampleCron() {
...
Expand Down
9 changes: 7 additions & 2 deletions apps/docs-new/content/docs/dev/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
<Accordion title="Why VitNode?">My Content</Accordion>
</Accordions>

### 🖥️ Hardware
### Requirements

- [Node.js 20+](https://nodejs.org/)
- [PostgreSQL 16+](https://www.postgresql.org/)

#### 🖥️ Hardware

| | Minimum | Recommended |
| :------ | :------------- | :------------- |
Expand All @@ -50,7 +55,7 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
| Storage | 10GB | 20GB |
| Network | 100Mbps | 300Mbps |

### 🧑‍💻 Browser
#### 🧑‍💻 Browser

| | Minimum | Recommended |
| :------ | :------ | :---------- |
Expand Down
20 changes: 20 additions & 0 deletions apps/docs-new/content/docs/dev/pages.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Pages
---

## Default Page

VitNode handle automaticly default page for you. You need to create a file `themes/1/{your_plugin}/default-page.tsx` in your plugin template.

Use `export default` for your template.

```tsx
export default async function DefaultPage() {
const data = await getData();
const t = await getTranslations('core');

return <div>{t('info', { data })}</div>;
}
```

Test it by set your plugin as default in `AdminCP` and go to your website.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Sitemap
---
title: Sitemap
description: Generate a sitemap.xml file automatically.
---

Thanks to [NextJS Sitemap](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap) we can generate a sitemap.xml file automatically. This file is used by search engines to index your website.

## How it works in VitNode?

TODO
TODO: Add content
6 changes: 3 additions & 3 deletions apps/docs-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.0.6-canary.1",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev",
"start": "next start"
"dev:docs": "next dev --port 3030",
"build:docs": "next build",
"start:docs": "next start --port 3030"
},
"dependencies": {
"clsx": "^2.1.1",
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Maciej Piotr (aXenDev) Balcerzak",
"license": "GPL-3.0 license",
"scripts": {
"dev:docs": "next dev --port 3030",
"dev:docs": "next dev --port 3031",
"build:docs": "next build",
"start:docs": "next start --port 3030"
"start:docs": "next start --port 3031"
},
"dependencies": {
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand Down
50 changes: 0 additions & 50 deletions apps/docs/pages/docs/index.mdx

This file was deleted.

Loading

0 comments on commit 20c643a

Please sign in to comment.