Skip to content

yarso17/express-typescript-mockup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-typescript

Mockup of a simple express server using typescript.

Directory structure (suggested)

PROJECT-ROOT

  • public/ (if needed)
  • src/
    • types/ (custom types)
    • server.ts (entry point)
    • app.ts (express app)
    • middlewares.ts (express middlewares)
    • routers/ (express routers)
      • [entity].ts (entity router)
    • schemas/ (data validation)
      • [entity].ts (entity schema)
    • controllers/ (route handlers)
      • [entity].ts (entity controller)
    • models/ (data models)
      • [entity].ts (entity model)
    • services/ (third-party services integration)
    • lib/ (custom libraries and utilities)

Scripts

  • node --run dev - Start the server in development mode (watch mode is enabled).
  • node --run start - Start the server in production mode (Make sure to set environment variables properly).

Libraries in use

  • express - Fast, unopinionated, minimalist web framework for Node.js.
  • typescript - A typed superset of JavaScript that compiles to plain JavaScript.
  • typescript-eslint - An ESLint plugin which provides linting rules for TypeScript codebases.
    • eslint - A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript.

Recommended libraries

  • cookie-parser - Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
  • jsonwebtoken - An implementation of JSON Web Tokens.
  • bycrypt - A library to help you hash passwords.
  • cron - A simple cron-like job scheduler for Node.js.
  • multer - Middleware for handling multipart/form-data.
  • helmet - Helps you secure your Express apps by setting various HTTP headers.
  • resend - Email API for developers.
  • zod - TypeScript-first schema declaration and validation library.
  • pg - PostgreSQL client for Node.js.
  • mysql2 - MySQL client for Node.js.
  • qr-code - QR code generator.
  • sharp - High performance Node.js image processing.
  • pdfkit - PDF generation library.
  • express-rate-limit - Basic rate-limiting middleware for Express.

Considerations

  • Implement a jwt authentication system with 'jsonwebtoken'.
  • Set 'trus proxy' - If you are behind a proxy, you need to enable this option to properly get the client's IP address.
  • Only implement the libraries you need, don't overcomplicate your project.
  • Only implement dependency injection if its necessary, it can make your project harder to understand.
  • Use a code formatter like 'prettier' to keep your code clean and consistent. Use what you like, but be consistent.

About

Mockup of a simple express server using typescript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published