core-nails 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,22 +82,27 @@ export async function POST(req: Request) {
82
82
  // --- 6️⃣ API [id]/route.ts ---
83
83
  fs.mkdirSync(apiIdDir, { recursive: true });
84
84
  const apiIdRoutePath = path.join(apiIdDir, "route.ts");
85
- const apiIdRouteContent = `import ${camelName}Controller from "@controller/${camelName}";
85
+ const apiIdRouteContent = `import { NextRequest } from "next/server";
86
+ import ${camelName}Controller from "@controller/${camelName}";
86
87
 
87
- export async function GET(req: Request, { params }: { params: { id: string } }) {
88
- return ${camelName}Controller.show_action(req, params.id);
88
+ export async function GET(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
89
+ const { id } = await context.params;
90
+ return ${camelName}Controller.show_action(req, id);
89
91
  }
90
92
 
91
- export async function PATCH(req: Request, { params }: { params: { id: string } }) {
92
- return ${camelName}Controller.update_action(req, params.id);
93
+ export async function PATCH(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
94
+ const { id } = await context.params;
95
+ return ${camelName}Controller.update_action(req, id);
93
96
  }
94
97
 
95
- export async function PUT(req: Request, { params }: { params: { id: string } }) {
96
- return ${camelName}Controller.update_action(req, params.id);
98
+ export async function PUT(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
99
+ const { id } = await context.params;
100
+ return ${camelName}Controller.update_action(req, id);
97
101
  }
98
102
 
99
- export async function DELETE(req: Request, { params }: { params: { id: string } }) {
100
- return ${camelName}Controller.destroy_action(req, params.id);
103
+ export async function DELETE(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
104
+ const { id } = await context.params;
105
+ return ${camelName}Controller.destroy_action(req, id);
101
106
  }
102
107
  `;
103
108
  fs.writeFileSync(apiIdRoutePath, apiIdRouteContent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-nails",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "scripts": {
5
5
  "build": "tsc"
6
6
  },
@@ -110,22 +110,27 @@ export async function POST(req: Request) {
110
110
 
111
111
  const apiIdRoutePath = path.join(apiIdDir, "route.ts");
112
112
 
113
- const apiIdRouteContent = `import ${camelName}Controller from "@controller/${camelName}";
113
+ const apiIdRouteContent = `import { NextRequest } from "next/server";
114
+ import ${camelName}Controller from "@controller/${camelName}";
114
115
 
115
- export async function GET(req: Request, { params }: { params: { id: string } }) {
116
- return ${camelName}Controller.show_action(req, params.id);
116
+ export async function GET(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
117
+ const { id } = await context.params;
118
+ return ${camelName}Controller.show_action(req, id);
117
119
  }
118
120
 
119
- export async function PATCH(req: Request, { params }: { params: { id: string } }) {
120
- return ${camelName}Controller.update_action(req, params.id);
121
+ export async function PATCH(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
122
+ const { id } = await context.params;
123
+ return ${camelName}Controller.update_action(req, id);
121
124
  }
122
125
 
123
- export async function PUT(req: Request, { params }: { params: { id: string } }) {
124
- return ${camelName}Controller.update_action(req, params.id);
126
+ export async function PUT(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
127
+ const { id } = await context.params;
128
+ return ${camelName}Controller.update_action(req, id);
125
129
  }
126
130
 
127
- export async function DELETE(req: Request, { params }: { params: { id: string } }) {
128
- return ${camelName}Controller.destroy_action(req, params.id);
131
+ export async function DELETE(req: NextRequest, context: { params: Promise<{ id: string }> }): Promise<Response> {
132
+ const { id } = await context.params;
133
+ return ${camelName}Controller.destroy_action(req, id);
129
134
  }
130
135
  `;
131
136