Skip to content

Commit dbbe48f

Browse files
Nisreen OweidatNisreen Oweidat
authored andcommitted
13/3 final
1 parent 5c032d1 commit dbbe48f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ app.use(express.urlencoded({ extended: false }));
2020
app.use(cookieParser());
2121
app.use(express.static(path.join(__dirname, "public")));
2222

23-
app.use("/", indexRouter);
24-
app.use("/auth", authRouter);
25-
app.use("/pokemon", pokemonRouter);
23+
app.use("/", indexRouter); // localhost:3000 -> home page
24+
app.use("/auth", authRouter); // localhost:3000/auth/ -> auth page for login and register
25+
app.use("/pokemon", pokemonRouter);// localhost:3000/pokemon/ -> pokemon page for pokemon with hp / id / name/ type / create/ update/ delete
2626
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
2727

2828
module.exports = app;

src/routes/auth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
const express = require("express");
24
const jwt = require("jsonwebtoken"); // for generating token
35
const bcrypt = require("bcryptjs"); // for encrypting password
@@ -6,7 +8,7 @@ const router = express.Router();
68

79
const users = [];
810

9-
const SECRET_KEY = "your_secret_key";
11+
const SECRET_KEY = "nisreen`s token";
1012

1113
router.post("/signup", async (req, res) => { // create new user
1214
const { username, password } = req.body;
@@ -29,7 +31,7 @@ router.post("/login", async (req, res) => { // normal login
2931
const user = users.find(user => user.username === username);
3032

3133
if (!user || !(await bcrypt.compare(password, user.password))) {
32-
return res.status(401).json({ error: "Invalid credentials" });
34+
return res.status(401).json({ error: "username or password is incorrect" });
3335
}
3436

3537

0 commit comments

Comments
 (0)