Skip to content

Commit

Permalink
✨ add user & init monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
ileostar committed Jul 5, 2024
1 parent 266f301 commit cedad12
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"autorestart",
"ctsx",
"EDITMSG",
"gitmoji",
Expand Down
3 changes: 3 additions & 0 deletions apps/monitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 前端监控模块

- 监控网站情况
12 changes: 12 additions & 0 deletions apps/monitor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "monitor",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
17 changes: 17 additions & 0 deletions apps/server/ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
apps: [
{
name: 'poster-craft-server',
script: 'pnpm',
args: 'start:prod',
cwd: '.',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
},
},
],
};
2 changes: 0 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "server",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down Expand Up @@ -39,7 +38,6 @@
"superagent": "^8.1.2"
},
"devDependencies": {
"@electric-sql/pglite": "^0.1.2",
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
Expand Down
42 changes: 42 additions & 0 deletions apps/server/src/user/dto/user.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ApiProperty, PickType } from '@nestjs/swagger';
import { IsNotEmpty, Length } from 'class-validator';

export class CreateUserDto {
@ApiProperty({
example: 'admin',
description: '用户名不能为空,长度为2-20位',
})
@IsNotEmpty({ message: '用户名不能为空' })
@Length(2, 20, { message: '用户名长度为2-20位' })
username: string;

@ApiProperty({
example: '15512345678',
description: '手机号码不能为空,长度应在6-20位之间',
})
@IsNotEmpty({ message: '手机号码不能为空' })
@Length(6, 20, { message: '手机号码长度应在6到20位之间' })
phone: string;

@ApiProperty({
example: '123456',
description: '密码不能为空,长度应在6-20位之间',
})
@IsNotEmpty({ message: '密码不能为空' })
@Length(6, 20, { message: '密码长度为6-20位' })
password: string;

avatar: string;
}

export class FindUserDto {
@ApiProperty()
@IsNotEmpty({ message: '手机号码不能为空' })
@Length(6, 20, { message: '手机号码长度应在6到20位之间' })
phone: string;
}

export class UpdateUserDto extends PickType(CreateUserDto, [
'username',
'avatar',
]) {}
4 changes: 4 additions & 0 deletions apps/server/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Body, Controller, Get, Patch, Post, UseGuards } from '@nestjs/common';

@Controller('user')
export class UserController {}
15 changes: 15 additions & 0 deletions apps/server/src/user/user.decorators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createParamDecorator, ExecutionContext } from '@nestjs/common';

type User = {
userId: string;
};
export type UserEntity = User | null;

export const User: () => ParameterDecorator = createParamDecorator(
(data: unknown, ctx: ExecutionContext) => {
const request = ctx.switchToHttp().getRequest();
return {
userId: request.userId,
};
},
);
12 changes: 12 additions & 0 deletions apps/server/src/user/user.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';

import { UserController } from './user.controller';
import { UserService } from './user.service';

@Module({
imports: [],
providers: [UserService],
controllers: [UserController],
exports: [UserService],
})
export class UserModule {}
7 changes: 7 additions & 0 deletions apps/server/src/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { HttpException, Inject, Injectable } from '@nestjs/common';
import { eq } from 'drizzle-orm';

@Injectable()
export class UserService {
constructor() {}
}

0 comments on commit cedad12

Please sign in to comment.