0% found this document useful (0 votes)
2 views2 pages

Backend Development Assignment

The document outlines an assignment test focused on backend development, covering backend architecture, sample login code using Node.js and Express, and a debugging exercise. It explains Client-Server and MVC architectures, provides a sample login implementation, and presents buggy code with a corrected version. Additionally, it includes assignment questions related to architecture differences, middleware, bug identification, and password hashing modification.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Backend Development Assignment

The document outlines an assignment test focused on backend development, covering backend architecture, sample login code using Node.js and Express, and a debugging exercise. It explains Client-Server and MVC architectures, provides a sample login implementation, and presents buggy code with a corrected version. Additionally, it includes assignment questions related to architecture differences, middleware, bug identification, and password hashing modification.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Backend Development Assignment Test

1. Backend Architecture Overview


Backend development typically follows architectures such as Client-Server and MVC
(Model-View-Controller). Client-Server Architecture: - Client sends requests (browser/mobile app) -
Server processes requests and returns responses MVC Architecture: - Model: Handles data and
database logic - View: UI (frontend) - Controller: Handles request logic and connects Model and
View

2. Sample Login Code ([Link] + Express)


const express = require('express');
const app = express();

[Link]([Link]());

const users = [{ username: "admin", password: "1234" }];

[Link]('/login', (req, res) => {


const { username, password } = [Link];

const user = [Link](u => [Link] === username && [Link] === password);

if (user) {
[Link]("Login successful");
} else {
[Link](401).send("Invalid credentials");
}
});

[Link](3000, () => [Link]("Server running on port 3000"));

3. Debugging Exercise
BUGGY CODE:

const express = require('express')


const app = express()

[Link]('/login', (req, res) => {


const user = [Link]
if(user = "admin") {
[Link]("Welcome")
}
})

FIXED CODE:

[Link]('/login', (req, res) => {


const user = [Link];
if(user === "admin") {
[Link]("Welcome");
} else {
[Link]("Access denied");
}
});

4. Assignment Questions
1. Explain the difference between Client-Server and MVC architecture. 2. What is middleware in
backend development? 3. Identify the bug in the provided login code. 4. Modify the login system to
include password hashing.

You might also like