-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (44 loc) · 1.42 KB
/
index.js
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
48
49
50
51
52
53
54
55
56
//const express = require("express");
import Express from "express";
import customers_api from "./customers.api.js";
// middlewares
const server = Express();
server.use(Express.urlencoded({ extended: true }));
server.use(Express.json());
// connect customer api
server.use('/customers', customers_api);
// sign route
server.post("/sign-in", (req, res) => {
let {userName, password} = req.body;
if (userName !== "minnthetkoko" || password !== "123456789")
return res.status(401).send({
meta: {status: "error", status_code: 401},
message: 'sign in error',
detail: 'username and password is incorrect',
solution: 'change userneme or password try agin....'
});
res.send({
meta: {status: "success", status_code: 200 },
message: 'sign in success',
data: {
user_name: 'minnthetkoko'
}
});
});
// listsing port
server.listen(3000, console.log("Server listing port 3000.... "));
/* {
"meta": {
"status": "success",
"status_code": 200
},
"message": "Sign in admin success.",
"data": {
"_id": "62b2ce5c9282f939b4f09297",
"name": "Mg Wunna",
"role": "admin",
"user_name": "mgwunna"
},
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MmIyY2U1YzkyODJmOTM5YjRmMDkyOTciLCJyZWZyZXNoX3Rva2VuIjoyOTE2OTE0OSwiaWF0IjoxNjU2NTEwMTAwfQ.C0wMdOko6QQz2ReDz5vxBDZO2rfov-GhFlEIo1sE1oE"
}
*/