Sobes.tech
Junior — Middle

Tell about your contribution to current or previous projects.

sobes.tech AI

Answer from AI

In my previous projects, I contributed to developing server-side logic using Node.js, creating REST APIs for interaction with the frontend and database. For example, I implemented an authentication module using JWT, which enhanced the application's security.

I also optimized database operations by implementing query caching with Redis, significantly reducing response times.

Here's an example code for creating a simple API with Express and JWT:

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

app.use(express.json());

app.post('/login', (req, res) => {
  const { username, password } = req.body;
  // User verification (simplified)
  if(username === 'user' && password === 'pass') {
    const token = jwt.sign({ username }, 'secretkey', { expiresIn: '1h' });
    res.json({ token });
  } else {
    res.status(401).send('Unauthorized');
  }
});

app.listen(3000);