-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
47 lines (39 loc) · 868 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import express from "express";
import { validate } from "./validation";
const app = express();
app.use(express.json());
const schemaUser = {
username: {
required: 'username zorunlu alandır.'
},
password: {
min: 10,
max: 12,
},
email: {
format: "email",
required: 'Email zorunlu alandır.'
},
name:{
omitempity:1
},
age:{
type: "number"
}
}
const LoginValidate = {
userName: {
required: "kullanıcı adı zorunlu alandır.",
},
password: {
min:6,
required: "sifre zorunlu alandır."
}
}
app.post("/users", validate(schemaUser), (request, response) => {
return response.json(request.body)
})
app.post("/login",validate(LoginValidate), (request, response) => {
return response.json(request.body)
})
app.listen(3000, () => console.log("Server is running on PORT 3000"))