This guide walks you through setting up a local development instance of Judicial Backend from scratch. By the end you will have the Express server running, connected to a SQL Server database, and you will have exchanged credentials for a JWT access token that you can use against any protected endpoint.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt
Use this file to discover all available pages before exploring further.
Install prerequisites
Before you clone the repository, make sure the following are available in your environment:
The SQL Server instance must already exist and have the target database created. Judicial Backend uses TypeORM in non-synchronize mode — it will not create or alter tables at startup. Apply your schema migrations before starting the server.
| Dependency | Minimum version | Check |
|---|---|---|
| Node.js | 18.x | node --version |
| npm | 9.x (bundled with Node 18) | npm --version |
| SQL Server | 2017+ (or Azure SQL) | connection string must be reachable |
Clone the repository and install dependencies
Configure environment variables
Copy the example environment file and open it in your editor:At minimum you must supply values for the seven variables marked as required — the application calls The remaining variables have safe defaults (
process.exit(1) at boot if any of them is empty:PORT=4000, DB_PORT=1433, NODE_ENV=development, etc.) — you only need to override them when deploying to staging or production. See the Configuration reference for every available variable.EXTERNAL_AUTH_URL must point to a running instance of the identity provider that exposes POST /api/Auth/Login, POST /api/Auth/RefreshToken, and GET /api/AuthJWT/GetJwks. Without it the protect middleware cannot fetch the JWKS public keys needed to verify incoming JWTs.Start the development server
src/ for TypeScript changes and restarts automatically. On a successful start you will see Pino log output similar to:| URL | Description |
|---|---|
http://localhost:4000/api | REST API root — all module routes live under /api |
http://localhost:4000/api-docs | Interactive Swagger UI with all documented endpoints |
http://localhost:4000/api-docs.json | Raw OpenAPI 3.0 JSON spec |
Make your first authenticated API call
All protected routes require a valid Bearer JWT in the A successful response returns a JSON body with an Step 5b — Call a protected route using the access token:Copy the You should receive a
Authorization header. Start by obtaining a token from the login endpoint.Step 5a — Log in and receive an access token:access_token field and sets a Secure; HttpOnly refresh-token cookie:access_token value and pass it as a Bearer token. The following request fetches the appeal catalogues for the criminal (penal) matter type:200 OK response with catalogue data (courts, rooms, magistrates, etc.) populated from your SQL Server database.All routes under
/api/apelaciones, /api/busquedas, and /api/estadisticas require a valid Bearer JWT. Only the /api/auth/* endpoints (login, refresh, logout) are publicly accessible without a token.Available npm scripts
| Script | Description |
|---|---|
npm run dev | Start dev server with nodemon (ts-node, hot reload) |
npm run build | Compile TypeScript to dist/ |
npm start | Run compiled output from dist/server.js |
npm test | Run Jest test suite |
npm run test:watch | Run Jest in interactive watch mode |
npm run test:coverage | Run tests with coverage report |
npm run lint | Run ESLint on src/**/*.ts |
npm run lint:fix | Auto-fix ESLint violations |
npm run format:check | Check formatting with Prettier (no writes) |
npm run format:fix | Auto-format with Prettier |
npm run fix:all | Run Prettier then ESLint fix in sequence |