wexts 4.1.5 → 4.1.6
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.
- package/README.md +49 -49
- package/bin/wexts.cjs +2 -2
- package/dist/chunk-27NEYQD2.mjs +222 -0
- package/dist/chunk-27NEYQD2.mjs.map +1 -0
- package/dist/chunk-2LJVUMXW.js +228 -0
- package/dist/chunk-2LJVUMXW.js.map +1 -0
- package/dist/chunk-5DBFN65W.mjs +183 -0
- package/dist/chunk-5DBFN65W.mjs.map +1 -0
- package/dist/chunk-75HBI2XG.js +504 -0
- package/dist/chunk-75HBI2XG.js.map +1 -0
- package/dist/chunk-AVMQJWYD.js +95 -0
- package/dist/chunk-AVMQJWYD.js.map +1 -0
- package/dist/chunk-C2AG7Q3C.mjs +65 -0
- package/dist/chunk-C2AG7Q3C.mjs.map +1 -0
- package/dist/chunk-DS5KVVWJ.mjs +95 -0
- package/dist/chunk-DS5KVVWJ.mjs.map +1 -0
- package/dist/chunk-FUPLZMSR.mjs +228 -0
- package/dist/chunk-FUPLZMSR.mjs.map +1 -0
- package/dist/chunk-HLT3IHJY.js +183 -0
- package/dist/chunk-HLT3IHJY.js.map +1 -0
- package/dist/chunk-L77ANWWT.mjs +22 -0
- package/dist/chunk-L77ANWWT.mjs.map +1 -0
- package/dist/chunk-P3Q4I5FD.js +222 -0
- package/dist/chunk-P3Q4I5FD.js.map +1 -0
- package/dist/chunk-VBIQGUDI.mjs +504 -0
- package/dist/chunk-VBIQGUDI.mjs.map +1 -0
- package/dist/chunk-WCKSKU3C.js +65 -0
- package/dist/chunk-WCKSKU3C.js.map +1 -0
- package/dist/chunk-XE4OXN2W.js +12 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/cli/index.d.mts +23 -0
- package/dist/cli/index.d.ts +23 -0
- package/dist/cli/index.js +745 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +747 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/index.d.mts +43 -0
- package/dist/client/index.d.ts +43 -0
- package/dist/client/index.js +187 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +166 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/codegen/index.d.mts +2 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +16 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/index.mjs +16 -0
- package/dist/codegen/index.mjs.map +1 -0
- package/dist/decorators-BiQtOHuF.d.ts +60 -0
- package/dist/decorators-vBopODtr.d.mts +60 -0
- package/dist/dev-server/index.d.mts +1 -0
- package/dist/dev-server/index.d.ts +1 -0
- package/dist/dev-server/index.js +13 -0
- package/dist/dev-server/index.js.map +1 -0
- package/dist/dev-server/index.mjs +13 -0
- package/dist/dev-server/index.mjs.map +1 -0
- package/dist/errors-D545UvXf.d.mts +37 -0
- package/dist/errors-D545UvXf.d.ts +37 -0
- package/dist/index-7RvU-jGE.d.mts +66 -0
- package/dist/index-7RvU-jGE.d.ts +66 -0
- package/dist/index-CJKs4wtN.d.ts +92 -0
- package/dist/index-CUR6CnLk.d.ts +27 -0
- package/dist/index-h66Vq9dK.d.mts +92 -0
- package/dist/index-tqmYsTUn.d.mts +27 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nest/index.d.mts +2 -0
- package/dist/nest/index.d.ts +2 -0
- package/dist/nest/index.js +36 -0
- package/dist/nest/index.js.map +1 -0
- package/dist/nest/index.mjs +36 -0
- package/dist/nest/index.mjs.map +1 -0
- package/dist/next/index.d.mts +66 -0
- package/dist/next/index.d.ts +66 -0
- package/dist/next/index.js +282 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +251 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/rpc/index.d.mts +32 -0
- package/dist/rpc/index.d.ts +32 -0
- package/dist/rpc/index.js +19 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +1 -0
- package/dist/rpc/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +55 -0
- package/dist/runtime/index.d.ts +55 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +15 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/server/index.d.mts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +58 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +58 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types/index.d.mts +12 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-CQ_aexOX.d.mts +32 -0
- package/dist/types-CQ_aexOX.d.ts +32 -0
- package/dist/vercel-builder/index.d.mts +58 -0
- package/dist/vercel-builder/index.d.ts +58 -0
- package/dist/vercel-builder/index.js +330 -0
- package/dist/vercel-builder/index.js.map +1 -0
- package/dist/vercel-builder/index.mjs +330 -0
- package/dist/vercel-builder/index.mjs.map +1 -0
- package/package.json +153 -153
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +17 -17
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -67
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +3 -3
- package/templates/nestjs-api/README.md +87 -87
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +17 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
- package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
- package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
- package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
- package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
- package/templates/nestjs-api/src/main.ts +32 -32
- package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
- package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
- package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
- package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
- package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
- package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
- package/templates/nestjs-api/src/users/users.controller.ts +14 -14
- package/templates/nestjs-api/src/users/users.module.ts +12 -12
- package/templates/nestjs-api/src/users/users.service.ts +19 -19
- package/templates/nestjs-api/tsconfig.json +39 -39
- package/templates/nextjs-web/README.md +76 -76
- package/templates/nextjs-web/app/actions/auth.ts +108 -108
- package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
- package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
- package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
- package/templates/nextjs-web/app/globals.css +93 -93
- package/templates/nextjs-web/app/layout.tsx +29 -29
- package/templates/nextjs-web/app/login/page.tsx +5 -5
- package/templates/nextjs-web/app/page.tsx +28 -28
- package/templates/nextjs-web/app/register/page.tsx +5 -5
- package/templates/nextjs-web/components/ui/button.tsx +56 -56
- package/templates/nextjs-web/components/ui/card.tsx +79 -79
- package/templates/nextjs-web/components/ui/input.tsx +25 -25
- package/templates/nextjs-web/components/ui/label.tsx +24 -24
- package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
- package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
- package/templates/nextjs-web/features/auth/api.ts +35 -35
- package/templates/nextjs-web/features/auth/index.ts +3 -3
- package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
- package/templates/nextjs-web/features/dashboard/api.ts +9 -9
- package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
- package/templates/nextjs-web/features/dashboard/index.ts +3 -3
- package/templates/nextjs-web/hooks/index.ts +4 -4
- package/templates/nextjs-web/lib/api-client.ts +89 -89
- package/templates/nextjs-web/lib/api.ts +115 -115
- package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
- package/templates/nextjs-web/lib/utils.ts +6 -6
- package/templates/nextjs-web/lib/wexts-client.ts +4 -4
- package/templates/nextjs-web/next-env.d.ts +6 -6
- package/templates/nextjs-web/next.config.ts +20 -20
- package/templates/nextjs-web/package.json +37 -37
- package/templates/nextjs-web/postcss.config.js +6 -6
- package/templates/nextjs-web/tailwind.config.ts +69 -69
- package/templates/nextjs-web/tsconfig.json +41 -41
- package/templates/nixpacks.toml +11 -11
- package/templates/root-package.json +31 -31
- package/templates/server.ts +66 -66
- package/templates/tsconfig.json +30 -30
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { NestFactory } from '@nestjs/core';
|
|
2
|
-
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
3
|
-
import { ValidationPipe } from '@nestjs/common';
|
|
4
|
-
import { AppModule } from './app.module';
|
|
5
|
-
|
|
6
|
-
async function bootstrap() {
|
|
7
|
-
const app = await NestFactory.create<NestFastifyApplication>(
|
|
8
|
-
AppModule,
|
|
9
|
-
new FastifyAdapter({ logger: true })
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
// Enable CORS
|
|
13
|
-
app.enableCors({
|
|
14
|
-
origin: process.env.FRONTEND_URL || 'http://localhost:3000',
|
|
15
|
-
credentials: true,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Global validation pipe
|
|
19
|
-
app.useGlobalPipes(
|
|
20
|
-
new ValidationPipe({
|
|
21
|
-
whitelist: true,
|
|
22
|
-
transform: true,
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const port = process.env.PORT || 5050;
|
|
27
|
-
await app.listen(port, '0.0.0.0');
|
|
28
|
-
|
|
29
|
-
console.log(`🚀 wexts API running on http://localhost:${port}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
bootstrap();
|
|
1
|
+
import { NestFactory } from '@nestjs/core';
|
|
2
|
+
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
3
|
+
import { ValidationPipe } from '@nestjs/common';
|
|
4
|
+
import { AppModule } from './app.module';
|
|
5
|
+
|
|
6
|
+
async function bootstrap() {
|
|
7
|
+
const app = await NestFactory.create<NestFastifyApplication>(
|
|
8
|
+
AppModule,
|
|
9
|
+
new FastifyAdapter({ logger: true })
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Enable CORS
|
|
13
|
+
app.enableCors({
|
|
14
|
+
origin: process.env.FRONTEND_URL || 'http://localhost:3000',
|
|
15
|
+
credentials: true,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Global validation pipe
|
|
19
|
+
app.useGlobalPipes(
|
|
20
|
+
new ValidationPipe({
|
|
21
|
+
whitelist: true,
|
|
22
|
+
transform: true,
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const port = process.env.PORT || 5050;
|
|
27
|
+
await app.listen(port, '0.0.0.0');
|
|
28
|
+
|
|
29
|
+
console.log(`🚀 wexts API running on http://localhost:${port}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
bootstrap();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Module, Global } from '@nestjs/common';
|
|
2
|
-
import { PrismaService } from './prisma.service';
|
|
3
|
-
|
|
4
|
-
@Global()
|
|
5
|
-
@Module({
|
|
6
|
-
providers: [PrismaService],
|
|
7
|
-
exports: [PrismaService],
|
|
8
|
-
})
|
|
9
|
-
export class PrismaModule { }
|
|
1
|
+
import { Module, Global } from '@nestjs/common';
|
|
2
|
+
import { PrismaService } from './prisma.service';
|
|
3
|
+
|
|
4
|
+
@Global()
|
|
5
|
+
@Module({
|
|
6
|
+
providers: [PrismaService],
|
|
7
|
+
exports: [PrismaService],
|
|
8
|
+
})
|
|
9
|
+
export class PrismaModule { }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
6
|
-
async onModuleInit() {
|
|
7
|
-
await this.$connect();
|
|
8
|
-
console.log('✅ Prisma connected');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async onModuleDestroy() {
|
|
12
|
-
await this.$disconnect();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { PrismaClient } from '@prisma/client';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
6
|
+
async onModuleInit() {
|
|
7
|
+
await this.$connect();
|
|
8
|
+
console.log('✅ Prisma connected');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async onModuleDestroy() {
|
|
12
|
+
await this.$disconnect();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { IsString, IsBoolean, IsOptional } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class CreateTodoDto {
|
|
4
|
-
@IsString()
|
|
5
|
-
title: string;
|
|
6
|
-
|
|
7
|
-
@IsString()
|
|
8
|
-
@IsOptional()
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class UpdateTodoDto {
|
|
13
|
-
@IsString()
|
|
14
|
-
@IsOptional()
|
|
15
|
-
title?: string;
|
|
16
|
-
|
|
17
|
-
@IsString()
|
|
18
|
-
@IsOptional()
|
|
19
|
-
description?: string;
|
|
20
|
-
|
|
21
|
-
@IsBoolean()
|
|
22
|
-
@IsOptional()
|
|
23
|
-
completed?: boolean;
|
|
24
|
-
}
|
|
1
|
+
import { IsString, IsBoolean, IsOptional } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class CreateTodoDto {
|
|
4
|
+
@IsString()
|
|
5
|
+
title: string;
|
|
6
|
+
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsOptional()
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class UpdateTodoDto {
|
|
13
|
+
@IsString()
|
|
14
|
+
@IsOptional()
|
|
15
|
+
title?: string;
|
|
16
|
+
|
|
17
|
+
@IsString()
|
|
18
|
+
@IsOptional()
|
|
19
|
+
description?: string;
|
|
20
|
+
|
|
21
|
+
@IsBoolean()
|
|
22
|
+
@IsOptional()
|
|
23
|
+
completed?: boolean;
|
|
24
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards, Request } from '@nestjs/common';
|
|
2
|
-
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
3
|
-
import { TodosService } from './todos.service';
|
|
4
|
-
import { CreateTodoDto, UpdateTodoDto } from './dto/todo.dto';
|
|
5
|
-
|
|
6
|
-
@Controller('todos')
|
|
7
|
-
@UseGuards(JwtAuthGuard)
|
|
8
|
-
export class TodosController {
|
|
9
|
-
constructor(private todosService: TodosService) { }
|
|
10
|
-
|
|
11
|
-
@Get()
|
|
12
|
-
async findAll(@Request() req) {
|
|
13
|
-
return this.todosService.findAll(req.user.userId);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@Get(':id')
|
|
17
|
-
async findOne(@Param('id') id: string, @Request() req) {
|
|
18
|
-
return this.todosService.findOne(id, req.user.userId);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Post()
|
|
22
|
-
async create(@Body() dto: CreateTodoDto, @Request() req) {
|
|
23
|
-
return this.todosService.create(dto, req.user.userId);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Put(':id')
|
|
27
|
-
async update(
|
|
28
|
-
@Param('id') id: string,
|
|
29
|
-
@Body() dto: UpdateTodoDto,
|
|
30
|
-
@Request() req,
|
|
31
|
-
) {
|
|
32
|
-
return this.todosService.update(id, dto, req.user.userId);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Delete(':id')
|
|
36
|
-
async remove(@Param('id') id: string, @Request() req) {
|
|
37
|
-
return this.todosService.remove(id, req.user.userId);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards, Request } from '@nestjs/common';
|
|
2
|
+
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
3
|
+
import { TodosService } from './todos.service';
|
|
4
|
+
import { CreateTodoDto, UpdateTodoDto } from './dto/todo.dto';
|
|
5
|
+
|
|
6
|
+
@Controller('todos')
|
|
7
|
+
@UseGuards(JwtAuthGuard)
|
|
8
|
+
export class TodosController {
|
|
9
|
+
constructor(private todosService: TodosService) { }
|
|
10
|
+
|
|
11
|
+
@Get()
|
|
12
|
+
async findAll(@Request() req) {
|
|
13
|
+
return this.todosService.findAll(req.user.userId);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Get(':id')
|
|
17
|
+
async findOne(@Param('id') id: string, @Request() req) {
|
|
18
|
+
return this.todosService.findOne(id, req.user.userId);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Post()
|
|
22
|
+
async create(@Body() dto: CreateTodoDto, @Request() req) {
|
|
23
|
+
return this.todosService.create(dto, req.user.userId);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Put(':id')
|
|
27
|
+
async update(
|
|
28
|
+
@Param('id') id: string,
|
|
29
|
+
@Body() dto: UpdateTodoDto,
|
|
30
|
+
@Request() req,
|
|
31
|
+
) {
|
|
32
|
+
return this.todosService.update(id, dto, req.user.userId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Delete(':id')
|
|
36
|
+
async remove(@Param('id') id: string, @Request() req) {
|
|
37
|
+
return this.todosService.remove(id, req.user.userId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
2
|
-
import { TodosService } from './todos.service';
|
|
3
|
-
import { TodosController } from './todos.controller';
|
|
4
|
-
import { PrismaModule } from '../prisma/prisma.module';
|
|
5
|
-
|
|
6
|
-
@Module({
|
|
7
|
-
imports: [PrismaModule], // ✅ Import PrismaModule
|
|
8
|
-
controllers: [TodosController],
|
|
9
|
-
providers: [TodosService],
|
|
10
|
-
})
|
|
11
|
-
export class TodosModule { }
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { TodosService } from './todos.service';
|
|
3
|
+
import { TodosController } from './todos.controller';
|
|
4
|
+
import { PrismaModule } from '../prisma/prisma.module';
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
imports: [PrismaModule], // ✅ Import PrismaModule
|
|
8
|
+
controllers: [TodosController],
|
|
9
|
+
providers: [TodosService],
|
|
10
|
+
})
|
|
11
|
+
export class TodosModule { }
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { Injectable, NotFoundException, ForbiddenException } from '@nestjs/common';
|
|
2
|
-
import { PrismaService } from '../prisma/prisma.service';
|
|
3
|
-
import { CreateTodoDto, UpdateTodoDto } from './dto/todo.dto';
|
|
4
|
-
|
|
5
|
-
@Injectable()
|
|
6
|
-
export class TodosService {
|
|
7
|
-
constructor(private prisma: PrismaService) { }
|
|
8
|
-
|
|
9
|
-
async findAll(userId: string) {
|
|
10
|
-
return this.prisma.todo.findMany({
|
|
11
|
-
where: { userId },
|
|
12
|
-
orderBy: { createdAt: 'desc' },
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async findOne(id: string, userId: string) {
|
|
17
|
-
const todo = await this.prisma.todo.findUnique({ where: { id } });
|
|
18
|
-
|
|
19
|
-
if (!todo) {
|
|
20
|
-
throw new NotFoundException('Todo not found');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (todo.userId !== userId) {
|
|
24
|
-
throw new ForbiddenException('Access denied');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return todo;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async create(dto: CreateTodoDto, userId: string) {
|
|
31
|
-
return this.prisma.todo.create({
|
|
32
|
-
data: {
|
|
33
|
-
...dto,
|
|
34
|
-
userId,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async update(id: string, dto: UpdateTodoDto, userId: string) {
|
|
40
|
-
await this.findOne(id, userId); // Check ownership
|
|
41
|
-
|
|
42
|
-
return this.prisma.todo.update({
|
|
43
|
-
where: { id },
|
|
44
|
-
data: dto,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async remove(id: string, userId: string) {
|
|
49
|
-
await this.findOne(id, userId); // Check ownership
|
|
50
|
-
|
|
51
|
-
return this.prisma.todo.delete({ where: { id } });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import { Injectable, NotFoundException, ForbiddenException } from '@nestjs/common';
|
|
2
|
+
import { PrismaService } from '../prisma/prisma.service';
|
|
3
|
+
import { CreateTodoDto, UpdateTodoDto } from './dto/todo.dto';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class TodosService {
|
|
7
|
+
constructor(private prisma: PrismaService) { }
|
|
8
|
+
|
|
9
|
+
async findAll(userId: string) {
|
|
10
|
+
return this.prisma.todo.findMany({
|
|
11
|
+
where: { userId },
|
|
12
|
+
orderBy: { createdAt: 'desc' },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async findOne(id: string, userId: string) {
|
|
17
|
+
const todo = await this.prisma.todo.findUnique({ where: { id } });
|
|
18
|
+
|
|
19
|
+
if (!todo) {
|
|
20
|
+
throw new NotFoundException('Todo not found');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (todo.userId !== userId) {
|
|
24
|
+
throw new ForbiddenException('Access denied');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return todo;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async create(dto: CreateTodoDto, userId: string) {
|
|
31
|
+
return this.prisma.todo.create({
|
|
32
|
+
data: {
|
|
33
|
+
...dto,
|
|
34
|
+
userId,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async update(id: string, dto: UpdateTodoDto, userId: string) {
|
|
40
|
+
await this.findOne(id, userId); // Check ownership
|
|
41
|
+
|
|
42
|
+
return this.prisma.todo.update({
|
|
43
|
+
where: { id },
|
|
44
|
+
data: dto,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async remove(id: string, userId: string) {
|
|
49
|
+
await this.findOne(id, userId); // Check ownership
|
|
50
|
+
|
|
51
|
+
return this.prisma.todo.delete({ where: { id } });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Controller, Get, UseGuards, Request } from '@nestjs/common';
|
|
2
|
-
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
3
|
-
import { UsersService } from './users.service';
|
|
4
|
-
|
|
5
|
-
@Controller('users')
|
|
6
|
-
@UseGuards(JwtAuthGuard)
|
|
7
|
-
export class UsersController {
|
|
8
|
-
constructor(private usersService: UsersService) { }
|
|
9
|
-
|
|
10
|
-
@Get('me')
|
|
11
|
-
async getMe(@Request() req) {
|
|
12
|
-
return this.usersService.findById(req.user.userId);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { Controller, Get, UseGuards, Request } from '@nestjs/common';
|
|
2
|
+
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
3
|
+
import { UsersService } from './users.service';
|
|
4
|
+
|
|
5
|
+
@Controller('users')
|
|
6
|
+
@UseGuards(JwtAuthGuard)
|
|
7
|
+
export class UsersController {
|
|
8
|
+
constructor(private usersService: UsersService) { }
|
|
9
|
+
|
|
10
|
+
@Get('me')
|
|
11
|
+
async getMe(@Request() req) {
|
|
12
|
+
return this.usersService.findById(req.user.userId);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
2
|
-
import { UsersService } from './users.service';
|
|
3
|
-
import { UsersController } from './users.controller';
|
|
4
|
-
import { PrismaModule } from '../prisma/prisma.module';
|
|
5
|
-
|
|
6
|
-
@Module({
|
|
7
|
-
imports: [PrismaModule], // ✅ Import PrismaModule
|
|
8
|
-
controllers: [UsersController],
|
|
9
|
-
providers: [UsersService],
|
|
10
|
-
exports: [UsersService],
|
|
11
|
-
})
|
|
12
|
-
export class UsersModule { }
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { UsersService } from './users.service';
|
|
3
|
+
import { UsersController } from './users.controller';
|
|
4
|
+
import { PrismaModule } from '../prisma/prisma.module';
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
imports: [PrismaModule], // ✅ Import PrismaModule
|
|
8
|
+
controllers: [UsersController],
|
|
9
|
+
providers: [UsersService],
|
|
10
|
+
exports: [UsersService],
|
|
11
|
+
})
|
|
12
|
+
export class UsersModule { }
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { PrismaService } from '../prisma/prisma.service';
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class UsersService {
|
|
6
|
-
constructor(private prisma: PrismaService) { }
|
|
7
|
-
|
|
8
|
-
async findById(id: string) {
|
|
9
|
-
return this.prisma.user.findUnique({
|
|
10
|
-
where: { id },
|
|
11
|
-
select: {
|
|
12
|
-
id: true,
|
|
13
|
-
email: true,
|
|
14
|
-
name: true,
|
|
15
|
-
createdAt: true,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { PrismaService } from '../prisma/prisma.service';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class UsersService {
|
|
6
|
+
constructor(private prisma: PrismaService) { }
|
|
7
|
+
|
|
8
|
+
async findById(id: string) {
|
|
9
|
+
return this.prisma.user.findUnique({
|
|
10
|
+
where: { id },
|
|
11
|
+
select: {
|
|
12
|
+
id: true,
|
|
13
|
+
email: true,
|
|
14
|
+
name: true,
|
|
15
|
+
createdAt: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"target": "ES2021",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"baseUrl": "./",
|
|
13
|
-
"incremental": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"strictNullChecks": false,
|
|
16
|
-
"noImplicitAny": false,
|
|
17
|
-
"strictBindCallApply": false,
|
|
18
|
-
"forceConsistentCasingInFileNames": false,
|
|
19
|
-
"noFallthroughCasesInSwitch": false,
|
|
20
|
-
"moduleResolution": "node",
|
|
21
|
-
"esModuleInterop": true,
|
|
22
|
-
"paths": {
|
|
23
|
-
"wexts/nest": [
|
|
24
|
-
"node_modules/wexts/dist/nest/index"
|
|
25
|
-
],
|
|
26
|
-
"wexts/next": [
|
|
27
|
-
"node_modules/wexts/dist/next/index"
|
|
28
|
-
],
|
|
29
|
-
"wexts/client": [
|
|
30
|
-
"node_modules/wexts/dist/client/index"
|
|
31
|
-
],
|
|
32
|
-
"wexts/types": [
|
|
33
|
-
"node_modules/wexts/dist/types/index"
|
|
34
|
-
],
|
|
35
|
-
"wexts": [
|
|
36
|
-
"node_modules/wexts/dist/index"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "ES2021",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strictNullChecks": false,
|
|
16
|
+
"noImplicitAny": false,
|
|
17
|
+
"strictBindCallApply": false,
|
|
18
|
+
"forceConsistentCasingInFileNames": false,
|
|
19
|
+
"noFallthroughCasesInSwitch": false,
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"paths": {
|
|
23
|
+
"wexts/nest": [
|
|
24
|
+
"node_modules/wexts/dist/nest/index"
|
|
25
|
+
],
|
|
26
|
+
"wexts/next": [
|
|
27
|
+
"node_modules/wexts/dist/next/index"
|
|
28
|
+
],
|
|
29
|
+
"wexts/client": [
|
|
30
|
+
"node_modules/wexts/dist/client/index"
|
|
31
|
+
],
|
|
32
|
+
"wexts/types": [
|
|
33
|
+
"node_modules/wexts/dist/types/index"
|
|
34
|
+
],
|
|
35
|
+
"wexts": [
|
|
36
|
+
"node_modules/wexts/dist/index"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
40
|
}
|