A mix of technical expertise and personal curiosity. These are the skills I’ve honed over time, along with areas that keep me motivated and always learning.
A collection of technologies and practices that make up my development workflow.
// Express server setup
import express from 'express';
import helmet from 'helmet';
import cors from 'cors';
const app = express();
app.use(express.json(), helmet(), cors());
app.listen(3000, () => console.log('Server running'));
// Login route with Zod & JWT
const schema = z.object({
email: z.string().email(),
password: z.string().min(6)
});
app.post('/login', async (req, res) => {
const result = schema.safeParse(req.body);
if (!result.success) return res.status(400).json(result.error);
const user = await User.findByEmail(result.data.email);
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET!);
res.json({ token });
});
-- Simple PostgreSQL query
SELECT users.name, SUM(orders.total) AS revenue
FROM users
JOIN orders ON users.id = orders.user_id
WHERE orders.created_at >= NOW() - INTERVAL '1 month'
GROUP BY users.name;
// TypeORM mapping example
@Entity()
export class Order {
@PrimaryGeneratedColumn()
id: number;
@Column()
total: number;
}
// Stripe webhook handler
import Stripe from 'stripe';
app.post('/webhook',
express.raw({ type: 'application/json' }),
(req, res) => {
const event = stripe.webhooks.constructEvent(
req.body,
req.headers['stripe-signature']!,
process.env.STRIPE_SECRET!
);
console.log(event.type);
res.json({ received: true });
}
);
// NestJS Swagger decorators
@ApiTags('users')
@Controller('users')
export class UsersController {
@Post()
@ApiOperation({ summary: 'Create a new user' })
@ApiBody({ type: CreateUserDto })
@ApiResponse({ status: 201, type: User })
async create(@Body() dto: CreateUserDto) {
return this.usersService.create(dto);
}
}
// Redis caching with TTL and cache-aside pattern
const getUser = async (userId) => {
const cacheKey = `user:${userId}`;
const cached = await redis.get(cacheKey);
if (cached) return JSON.parse(cached);
const user = await User.findById(userId);
await redis.setex(cacheKey, 3600, JSON.stringify(user));
return user;
};
// Bull queue for email processing
const emailQueue = new Queue('email processing', {
redis: { host: 'localhost', port: 6379 }
});
emailQueue.process('welcome-email', async (job) => {
const { userId, email } = job.data;
await sendWelcomeEmail(email);
console.log(`Welcome email sent to ${email}`);
});
// Add job to queue
emailQueue.add('welcome-email', { userId: 123, email: 'user@example.com' });
// Global error handler with structured logging
const errorHandler = (err, req, res, next) => {
logger.error({
error: err.message,
stack: err.stack,
url: req.url,
method: req.method,
ip: req.ip,
userId: req.user?.id
});
if (err.name === 'ValidationError') {
return res.status(400).json({ error: 'Validation failed' });
}
res.status(500).json({ error: 'Internal server error' });
};
# Multi-stage Dockerfile for Node.js
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM node:18-alpine AS production
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
COPY --from=builder /app/node_modules ./node_modules
COPY . .
USER nodejs
EXPOSE 3000
CMD ["node", "dist/main.js"]
// Express rate limiting with Redis store
const rateLimit = require('express-rate-limit');
const RedisStore = require('rate-limit-redis');
const limiter = rateLimit({
store: new RedisStore({ client: redisClient }),
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
message: 'Too many requests, please try again later.',
standardHeaders: true,
});
app.use('/api/', limiter);
// Test endpoint with curl
curl -X POST https://api.example.com/webhook \
-H "Content-Type: application/json" \
-d '{"type":"order.created","data":{"id":"123"}}'
// Express handler
app.post('/webhook', (req, res) => res.status(200).send('OK'));
// NestJS Controller example
@Controller('users')
export class UsersController {
constructor(private usersService: UsersService) {}
@Get()
findAll() {
return this.usersService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.usersService.findById(id);
}
}