Netpress Laravel-inspired backend framework for Node.js
Frameworkv0.1.14 Starterv0.1.12 Docsv1.0.3
Overview Installation Architecture CLI
Examples

Auth System Example

The starter kit already includes a complete auth flow, but this example shows the pattern clearly.

Route Layer

import { Router } from '@admicaa/netpress';
import authMiddleware from '../app/Http/Middleware/auth.js';
import AuthController from '../app/Http/Controllers/Auth/AuthController.js';

const router = Router();

router.post('/login', AuthController.login);
router.post('/register', AuthController.register);

router.group(authMiddleware, (router) => {
  router.get('/me', AuthController.me);
  router.post('/logout', AuthController.logout);
});

Controller Layer

import { BaseController } from '@admicaa/netpress';
import AuthService from '../../../Services/AuthService.js';

class AuthController extends BaseController {
  async login(req, res) {
    return res.success(await AuthService.login(req.body));
  }

  async me(req, res) {
    return res.success(req.user);
  }
}

Service Layer

AuthService owns the real work:

  • checking credentials
  • issuing tokens
  • rotating refresh tokens
  • loading the current user

Key Idea

Authentication should not live in route files. Middleware authenticates the request, the controller coordinates the action, and the service handles the auth workflow.