TypeScript Backend Toolkit

Dec 27, 2022 | Programming

Zod logo

Robust backend boilerplate designed for scalability, flexibility, and ease of development. It’s packed with modern technologies and best practices to kickstart your next backend project.

Prerequisites

Before you get started, make sure you have the following installed on your machine:

  • Docker + Docker Compose
  • PNPM
  • Node.js 20+ (LTS)

How to Run

  1. Set up Docker Services:

    Run the following command to start MongoDB and Redis instances locally:

    docker compose up -d
  2. Install Dependencies:

    Use pnpm to install all the necessary dependencies:

    pnpm i
  3. Configure Environment Variables:

    Create a .env file in the root directory. Use the provided .env.sample as a template to enter all the required environment variables.

Whats Included

Your new backend toolkit comes packed with features:

  • OpenAPI Autogenerated Swagger Docs: Automatically generated Swagger docs through MagicRouter API and Zod, accessible at api-docs.
  • Auth Module: Includes Google Sign-In support for easy authentication.
  • User Management: Comprehensive user management functionality.
  • File Upload: Handles file uploads with Multer and Amazon S3.
  • Data Validation & Serialization: Zod is used for validation and serialization of data.
  • Configuration Management: Managed using dotenv-cli and validated with Zod for accuracy and safety.
  • Middlewares:
    • Authorization: Built-in authorization middleware.
    • Zod Schema Validation: Ensures your API inputs are correctly validated.
    • JWT Extraction: Easily extract and verify JWT tokens.
  • Type-safe Email Handling: Emails are managed using Nodemailer with EJS templating.
  • Queues: Powered by BullMQ with Redis for handling background jobs.
  • ESLint Setup: Pre-configured ESLint setup for consistent code quality.
    pnpm run lint
  • Development Server: Run the server in development mode using ts-node-dev:
    pnpm run dev
  • Build Process: Efficiently bundle your project using tsup:
    pnpm run build
  • PM2 Support: Out-of-the-box support for PM2 to manage your production processes.

Roadmap

Future enhancements include:

  • Socket.io Support: Adding support for Redis adapter and a chat module.
  • Notification Infrastructure: Notifications via FCM and Novu.
  • React-Email and Mailgun Support: Improve email management with React-Email and Mailgun for more dynamic and flexible email handling.
  • Ansible Playbook: Create an Ansible playbook for server configuration to set up a basic environment quickly and consistently.
  • AWS CDK Support: Integrate AWS CDK for infrastructure management.
  • Monorepo Support: Implement monorepo architecture using Turborepo and Pnpm.
  • AWS Lambda Support: Add support for deploying serverless functions on AWS Lambda.
  • Cloudflare Workers Support: Enable Cloudflare Workers support for edge computing and faster request handling.
  • Postgres Support with Prisma: Add support for PostgreSQL using Prisma ORM.
  • Containerization with Docker: Ensure the project can be easily deployed using Docker.
  • Kubernetes Support: Integrate Kubernetes for container orchestration.
  • CICD with GitHub Actions: Implement a CICD pipeline to automate testing, building, and deployment processes.
  • Testing with Jest: Add support for unit and integration testing using Jest.

Troubleshooting

If you encounter issues while setting up your TypeScript Backend Toolkit, here are a few troubleshooting steps:

  • Ensure that Docker is running correctly by checking the Docker dashboard.
  • Verify that you have the correct version of Node.js installed (20+). You can check by running node -v in terminal.
  • If you experience issues with pnpm, try reinstalling it globally using npm install -g pnpm.
  • Double-check your environment variables in the .env file for correctness.
  • If encountering errors with Swagger documentation, ensure that all dependencies are installed properly with pnpm.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox