File tree 7 files changed +5420
-4328
lines changed
apps/api/server/routes/api
7 files changed +5420
-4328
lines changed Original file line number Diff line number Diff line change 1
1
import HttpException from "~/models/http-exception.model" ;
2
- import articleMapper from "~/utils/article.mapper" ;
2
+ import articleMapper from "~/routes/api/ utils/article.mapper" ;
3
3
import { definePrivateEventHandler } from "~/auth-event-handler" ;
4
4
5
5
export default definePrivateEventHandler ( async ( event , { auth} ) => {
Original file line number Diff line number Diff line change 1
1
import HttpException from "~/models/http-exception.model" ;
2
- import articleMapper from "~/utils/article.mapper" ;
2
+ import articleMapper from "~/routes/api/ utils/article.mapper" ;
3
3
import slugify from 'slugify' ;
4
4
import { definePrivateEventHandler } from "~/auth-event-handler" ;
5
5
Original file line number Diff line number Diff line change 1
- import articleMapper from "~/utils/article.mapper" ;
1
+ import articleMapper from "~/routes/api/ utils/article.mapper" ;
2
2
import { definePrivateEventHandler } from "~/auth-event-handler" ;
3
3
4
4
export default definePrivateEventHandler ( async ( event , { auth} ) => {
Original file line number Diff line number Diff line change 1
- import articleMapper from "~/utils/article.mapper" ;
1
+ import articleMapper from "~/routes/api/ utils/article.mapper" ;
2
2
import { definePrivateEventHandler } from "~/auth-event-handler" ;
3
3
4
4
export default definePrivateEventHandler ( async ( event , { auth} ) => {
Original file line number Diff line number Diff line change 1
- import articleMapper from "~/utils/article.mapper" ;
1
+ import articleMapper from "~/routes/api/ utils/article.mapper" ;
2
2
import HttpException from "~/models/http-exception.model" ;
3
3
import slugify from 'slugify' ;
4
4
import { definePrivateEventHandler } from "~/auth-event-handler" ;
Original file line number Diff line number Diff line change @@ -8,11 +8,16 @@ export default defineEventHandler(async (event) => {
8
8
const username = user . username ?. trim ( ) ;
9
9
const password = user . password ?. trim ( ) ;
10
10
const { image, bio, demo} = user ;
11
+ const regex = new RegExp ( "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" ) ;
11
12
12
13
if ( ! email ) {
13
14
throw new HttpException ( 422 , { errors : { email : [ "can't be blank" ] } } ) ;
14
15
}
15
16
17
+ if ( ! regex . test ( email ) ) {
18
+ throw new HttpException ( 422 , { errors : { email : [ "must be a valid email address" ] } } ) ;
19
+ }
20
+
16
21
if ( ! username ) {
17
22
throw new HttpException ( 422 , { errors : { username : [ "can't be blank" ] } } ) ;
18
23
}
You can’t perform that action at this time.
0 commit comments