Skip to content

Commit 3694511

Browse files
committed
refactor: Split config to api and global, change buildPlugin to buildApiPlugin
1 parent cc2b2bc commit 3694511

File tree

18 files changed

+123
-110
lines changed

18 files changed

+123
-110
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Blog
3+
description: xx
4+
icon: House
5+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Get Started
3+
description: xx
4+
---
5+
6+
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
7+
8+
<Tabs groupId='package-manager' persist items={['pnpm', 'npm', 'bun']} label='Create a Plugin'>
9+
10+
```bash tab="pnpm"
11+
pnpm create vitnode-app@canary --plugin
12+
```
13+
14+
```bash tab="npm"
15+
npx create-vitnode-app@canary --plugin
16+
```
17+
18+
```bash tab="bun"
19+
bun create vitnode-app@canary --plugin
20+
```
21+
22+
</Tabs>

apps/docs/content/docs/plugins/index.mdx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,4 @@ description: Create awesome plugins for VitNode.
44
icon: House
55
---
66

7-
## Create a Plugin
8-
9-
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
10-
11-
<Tabs groupId='package-manager' persist items={['pnpm', 'npm', 'bun']} label='Create a Plugin'>
12-
13-
```bash tab="pnpm"
14-
pnpm create vitnode-app@canary --plugin
15-
```
16-
17-
```bash tab="npm"
18-
npx create-vitnode-app@canary --plugin
19-
```
20-
21-
```bash tab="bun"
22-
bun create vitnode-app@canary --plugin
23-
```
24-
25-
</Tabs>
7+
test

apps/docs/content/docs/plugins/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"description": "Create and share own plugins",
44
"icon": "Plug",
55
"root": true,
6-
"pages": ["index", "..."]
6+
"pages": ["index", "---Plugins---", "blog", "---Custom Plugin---", "..."]
77
}

apps/web/src/app/api/[...route]/route.ts

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,14 @@
1+
import { vitNodeApiConfig } from '@/vitnode.api.config';
12
import { vitNodeConfig } from '@/vitnode.config';
23
import { OpenAPIHono } from '@hono/zod-openapi';
34
import { handle } from 'hono/vercel';
45
import { VitNodeAPI } from 'vitnode/api/config';
5-
import { NodemailerEmailPlugin } from 'vitnode/api/plugins/email/nodemailer';
6-
// import { ResendEmailPlugin } from 'vitnode/api/plugins/email/resend';
7-
import { DiscordSSOApiPlugin } from 'vitnode/api/plugins/sso/discord';
8-
import { FacebookSSOApiPlugin } from 'vitnode/api/plugins/sso/facebook';
9-
import { GoogleSSOApiPlugin } from 'vitnode/api/plugins/sso/google';
106

117
const app = new OpenAPIHono().basePath('/api');
128
VitNodeAPI({
139
app,
14-
plugins: vitNodeConfig.plugins,
15-
metadata: vitNodeConfig.metadata,
16-
// emailProvider: ResendEmailPlugin({
17-
// apiKey: process.env.RESEND_API_KEY ?? '',
18-
// from: process.env.RESEND_FROM ?? '',
19-
// }),
20-
emailProvider: NodemailerEmailPlugin({
21-
from: process.env.NODE_MAILER_FROM,
22-
host: process.env.NODE_MAILER_HOST,
23-
password: process.env.NODE_MAILER_PASSWORD,
24-
user: process.env.NOD_EMAILER_USER,
25-
}),
26-
authorization: {
27-
ssoPlugins: [
28-
DiscordSSOApiPlugin({
29-
clientId: process.env.DISCORD_CLIENT_ID,
30-
clientSecret: process.env.DISCORD_CLIENT_SECRET,
31-
}),
32-
GoogleSSOApiPlugin({
33-
clientId: process.env.GOOGLE_CLIENT_ID,
34-
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
35-
}),
36-
FacebookSSOApiPlugin({
37-
clientId: process.env.FACEBOOK_CLIENT_ID,
38-
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
39-
}),
40-
],
41-
},
10+
vitNodeApiConfig,
11+
vitNodeConfig,
4212
});
4313

4414
export const GET = handle(app);

apps/web/src/database/migrations/0000_hesitant_sumo.sql renamed to apps/web/src/database/migrations/0000_funny_korath.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ CREATE TABLE "core_languages" (
3030
"enabled" boolean DEFAULT true NOT NULL,
3131
"createdAt" timestamp DEFAULT now() NOT NULL,
3232
"updatedAt" timestamp NOT NULL,
33-
"time_24" boolean DEFAULT false NOT NULL,
34-
"allow_in_input" boolean DEFAULT true NOT NULL,
33+
"time24" boolean DEFAULT false NOT NULL,
3534
CONSTRAINT "core_languages_code_unique" UNIQUE("code")
3635
);
3736
--> statement-breakpoint

apps/web/src/database/migrations/meta/0000_snapshot.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "95791a90-7337-433f-9510-8d6f9e4125ff",
2+
"id": "fd378528-22f1-4e30-9108-4e06020776ba",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -299,19 +299,12 @@
299299
"primaryKey": false,
300300
"notNull": true
301301
},
302-
"time_24": {
303-
"name": "time_24",
302+
"time24": {
303+
"name": "time24",
304304
"type": "boolean",
305305
"primaryKey": false,
306306
"notNull": true,
307307
"default": false
308-
},
309-
"allow_in_input": {
310-
"name": "allow_in_input",
311-
"type": "boolean",
312-
"primaryKey": false,
313-
"notNull": true,
314-
"default": true
315308
}
316309
},
317310
"indexes": {

apps/web/src/database/migrations/meta/_journal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{
66
"idx": 0,
77
"version": "7",
8-
"when": 1746105704858,
9-
"tag": "0000_hesitant_sumo",
8+
"when": 1747245244787,
9+
"tag": "0000_funny_korath",
1010
"breakpoints": true
1111
}
1212
]

apps/web/src/database/schema/languages.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export const core_languages = pgTable(
1616
.timestamp()
1717
.notNull()
1818
.$onUpdate(() => new Date()),
19-
time_24: t.boolean().notNull().default(false),
20-
allow_in_input: t.boolean().default(true).notNull(),
19+
time24: t.boolean().notNull().default(false),
2120
}),
2221
t => [
2322
index('core_languages_code_idx').on(t.code),

apps/web/src/vitnode.api.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { blogApiPlugin } from 'vitnode-blog/plugin.config';
2+
import { NodemailerEmailPlugin } from 'vitnode/api/plugins/email/nodemailer';
3+
import { DiscordSSOApiPlugin } from 'vitnode/api/plugins/sso/discord';
4+
import { FacebookSSOApiPlugin } from 'vitnode/api/plugins/sso/facebook';
5+
import { GoogleSSOApiPlugin } from 'vitnode/api/plugins/sso/google';
6+
import { buildApiConfig } from 'vitnode/vitnode.config';
7+
8+
export const vitNodeApiConfig = buildApiConfig({
9+
plugins: [blogApiPlugin()],
10+
emailProvider: NodemailerEmailPlugin({
11+
from: process.env.NODE_MAILER_FROM,
12+
host: process.env.NODE_MAILER_HOST,
13+
password: process.env.NODE_MAILER_PASSWORD,
14+
user: process.env.NOD_EMAILER_USER,
15+
}),
16+
authorization: {
17+
ssoPlugins: [
18+
DiscordSSOApiPlugin({
19+
clientId: process.env.DISCORD_CLIENT_ID,
20+
clientSecret: process.env.DISCORD_CLIENT_SECRET,
21+
}),
22+
GoogleSSOApiPlugin({
23+
clientId: process.env.GOOGLE_CLIENT_ID,
24+
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
25+
}),
26+
FacebookSSOApiPlugin({
27+
clientId: process.env.FACEBOOK_CLIENT_ID,
28+
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
29+
}),
30+
],
31+
},
32+
});

0 commit comments

Comments
 (0)