CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/express-security-basics

Security defaults that belong in every Express application from day one.

93

6.18x
Quality

90%

Does it follow best practices?

Impact

99%

6.18x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Build a User Registration and Login API

Problem/Feature Description

A startup needs a user authentication API built with Express and TypeScript. The API will handle user signup and login using JWT tokens. A React single-page app on a separate domain will consume this API.

The API needs the following endpoints:

  • POST /api/auth/register -- create a new user account (accepts email, username, password)
  • POST /api/auth/login -- authenticate and return a JWT token
  • GET /api/auth/me -- return the current user's profile (requires valid JWT in Authorization header)

Use bcrypt for password hashing and jsonwebtoken for JWT creation/verification. Store users in an in-memory array (no database required). The JWT secret should come from an environment variable.

Output Specification

Produce:

  • app.ts -- Express application entry point with middleware and route wiring
  • routes/auth.ts -- Router module with register, login, and profile endpoints
  • middleware/authenticate.ts -- JWT verification middleware for protected routes
  • package.json -- With all required dependencies

evals

tile.json