Convert Figma logo to code with AI

FoalTS logofoal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.

1,894
139
1,894
21

Top Related Projects

66,731

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

16,828

AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.

15,054

The API and real-time application framework

64,773

Fast, unopinionated, minimalist web framework for node.

35,113

Expressive middleware for node.js using ES2017 async functions

31,844

Fast and low overhead web framework, for Node.js

Quick Overview

FoalTS is a Node.js framework for building web applications and APIs. It is written in TypeScript and focuses on providing a robust architecture for creating scalable and maintainable applications. FoalTS emphasizes developer productivity and code quality through its comprehensive set of features and tools.

Pros

  • Strong TypeScript support, providing type safety and improved developer experience
  • Comprehensive set of built-in features, including authentication, authorization, and validation
  • Modular architecture that promotes code organization and reusability
  • Extensive documentation and tutorials for easy learning and adoption

Cons

  • Steeper learning curve compared to some other Node.js frameworks
  • Smaller community and ecosystem compared to more established frameworks like Express or NestJS
  • Opinionated structure may not suit all project types or developer preferences
  • Limited third-party integrations and plugins compared to more popular frameworks

Code Examples

  1. Creating a simple controller:
import { Context, Get, HttpResponseOK } from '@foal/core';

export class AppController {
  @Get('/')
  index(ctx: Context) {
    return new HttpResponseOK('Hello, world!');
  }
}
  1. Setting up authentication:
import { Context, Get, HttpResponseOK, UserRequired } from '@foal/core';

@UserRequired()
export class ProfileController {
  @Get('/profile')
  profile(ctx: Context) {
    return new HttpResponseOK({ username: ctx.user.username });
  }
}
  1. Validating request body:
import { Context, Post, HttpResponseCreated, ValidateBody } from '@foal/core';
import { IsString, IsEmail } from '@foal/typestack';

export class UserController {
  @Post('/users')
  @ValidateBody({
    username: { type: 'string' },
    email: { type: 'string', format: 'email' }
  })
  createUser(ctx: Context) {
    const user = { username: ctx.request.body.username, email: ctx.request.body.email };
    // Save user to database
    return new HttpResponseCreated(user);
  }
}

Getting Started

To get started with FoalTS, follow these steps:

  1. Install FoalTS CLI:
npm install -g @foal/cli
  1. Create a new project:
foal createapp my-app
cd my-app
  1. Start the development server:
npm run develop

Your FoalTS application is now running at http://localhost:3001. You can start building your application by editing the files in the src directory.

Competitor Comparisons

66,731

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

Pros of Nest

  • Larger community and ecosystem, with more third-party packages and resources
  • Built-in support for microservices architecture and message patterns
  • More comprehensive documentation and extensive examples

Cons of Nest

  • Steeper learning curve due to its complexity and extensive feature set
  • Heavier framework with more dependencies, potentially impacting performance
  • Opinionated structure may be less flexible for some projects

Code Comparison

Nest:

@Controller('cats')
export class CatsController {
  @Get()
  findAll(): string {
    return 'This action returns all cats';
  }
}

Foal:

export class CatsController {
  @Get('/')
  findAll() {
    return new HttpResponseOK('This action returns all cats');
  }
}

Both frameworks use decorators for routing, but Foal's approach is slightly more explicit with its HTTP response objects. Nest's controller definition is more concise, while Foal requires less boilerplate for simple responses.

Nest offers a more comprehensive set of features out-of-the-box, making it suitable for large-scale applications. Foal, on the other hand, provides a simpler and more lightweight approach, which can be advantageous for smaller projects or developers who prefer more control over their application structure.

16,828

AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.

Pros of AdonisJS

  • More mature and established framework with a larger community and ecosystem
  • Comprehensive documentation and extensive learning resources
  • Built-in features like authentication, database ORM, and validation out of the box

Cons of AdonisJS

  • Steeper learning curve due to its opinionated nature and larger API surface
  • Heavier framework with more dependencies, potentially impacting performance
  • Less flexibility in terms of customization compared to FoalTS

Code Comparison

AdonisJS route definition:

Route.get('/users', 'UserController.index')
Route.post('/users', 'UserController.store')

FoalTS route definition:

@Get('/users')
async getUsers() {
  // Handler logic
}

@Post('/users')
async createUser() {
  // Handler logic
}

Both frameworks offer clean and expressive syntax for defining routes, with AdonisJS using a more traditional approach and FoalTS leveraging decorators for a more concise implementation. AdonisJS separates route definitions from controller logic, while FoalTS combines them in a single class.

15,054

The API and real-time application framework

Pros of Feathers

  • Mature ecosystem with a large community and extensive plugin support
  • Real-time capabilities out of the box, ideal for building real-time applications
  • Flexible and lightweight, allowing for easy integration with existing projects

Cons of Feathers

  • Less opinionated structure, which may lead to inconsistencies in large projects
  • Steeper learning curve for developers new to its concepts and architecture
  • TypeScript support is available but not as deeply integrated as in FoalTS

Code Comparison

Feathers service creation:

const messages = {
  async find(params) {
    return [];
  },
  async create(data, params) {}
};

app.use('messages', messages);

FoalTS controller creation:

import { Context, Get, Post } from '@foal/core';

export class MessageController {
  @Get()
  list(ctx: Context) {
    return [];
  }

  @Post()
  create(ctx: Context) {}
}

Both frameworks offer straightforward ways to create services or controllers, but FoalTS leverages TypeScript decorators for a more declarative approach, while Feathers uses a more traditional JavaScript object structure.

64,773

Fast, unopinionated, minimalist web framework for node.

Pros of Express

  • Mature ecosystem with extensive middleware and plugins
  • Lightweight and minimalist, allowing for flexible architecture
  • Huge community support and extensive documentation

Cons of Express

  • Lacks built-in TypeScript support, requiring additional setup
  • No integrated ORM or database abstraction layer
  • Less opinionated structure, potentially leading to inconsistent code organization

Code Comparison

Express:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

FoalTS:

import { Context, Get, HttpResponseOK } from '@foal/core';

export class AppController {
  @Get('/')
  index(ctx: Context) {
    return new HttpResponseOK('Hello World!');
  }
}

Express provides a more straightforward approach, while FoalTS offers a more structured, decorator-based setup with built-in TypeScript support. FoalTS also includes additional features like dependency injection and built-in security measures, which are not present in Express out of the box. However, Express's simplicity and flexibility allow for easier customization and integration with various tools and libraries.

35,113

Expressive middleware for node.js using ES2017 async functions

Pros of Koa

  • Lightweight and minimalist design, allowing for greater flexibility and customization
  • Extensive middleware ecosystem, providing a wide range of plugins and extensions
  • Simpler learning curve for developers familiar with Express.js

Cons of Koa

  • Less opinionated structure, requiring more setup and configuration for large projects
  • Lacks built-in TypeScript support, necessitating additional setup for type safety
  • Fewer out-of-the-box features compared to more comprehensive frameworks

Code Comparison

Koa:

const Koa = require('koa');
const app = new Koa();

app.use(async ctx => {
  ctx.body = 'Hello World';
});

app.listen(3000);

FoalTS:

import { Config, createApp } from '@foal/core';

async function main() {
  const app = await createApp(AppController);
  const port = Config.get('port', 3000);
  app.listen(port, () => console.log(`Listening on port ${port}...`));
}

main().catch(err => console.error(err));

Koa offers a more concise setup for simple applications, while FoalTS provides a more structured approach with built-in TypeScript support and additional features out of the box.

31,844

Fast and low overhead web framework, for Node.js

Pros of Fastify

  • Extremely high performance, often benchmarking faster than Express and other Node.js frameworks
  • Extensive plugin ecosystem, allowing for easy extensibility
  • Built-in support for JSON Schema validation

Cons of Fastify

  • Steeper learning curve compared to simpler frameworks
  • Less opinionated, which may require more setup and configuration
  • Smaller community compared to more established frameworks

Code Comparison

Fastify route example:

fastify.get('/', async (request, reply) => {
  return { hello: 'world' }
})

Foal route example:

@Get('/')
index() {
  return { hello: 'world' };
}

Key Differences

  • Fastify is JavaScript-first, while Foal is TypeScript-first
  • Foal provides a more complete MVC framework structure out of the box
  • Fastify focuses on high performance and low overhead
  • Foal offers built-in features like authentication and ORM integration

Use Cases

  • Choose Fastify for high-performance microservices or APIs
  • Opt for Foal when building full-stack TypeScript applications with a structured approach

Both frameworks are actively maintained and have their strengths. The choice depends on project requirements, team expertise, and performance needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


https://foalts.org

License: MIT Known Vulnerabilities Commit activity Last commit

What is Foal?

Foal (or FoalTS) is a Node.JS framework for creating web applications.

It provides a set of ready-to-use components so you don't have to reinvent the wheel every time. In one single place, you have a complete environment to build web applications. This includes a CLI, testing tools, frontend utilities, scripts, advanced authentication, ORM, deployment environments, GraphQL and Swagger API, AWS utilities, and more. You no longer need to get lost on npm searching for packages and making them work together. All is provided.

But while offering all these features, the framework remains simple. Complexity and unnecessary abstractions are put aside to provide the most intuitive and expressive syntax. We believe that concise and elegant code is the best way to develop an application and maintain it in the future. It also allows you to spend more time coding rather than trying to understand how the framework works.

Finally, the framework is entirely written in TypeScript. The language brings you optional static type-checking along with the latest ECMAScript features. This allows you to detect most silly errors during compilation and improve the quality of your code. It also offers you autocompletion and a well documented API.

Screenshot

Development Policy

Thousands of Tests

Testing FoalTS is put on a very high priority. Providing a reliable product is really important to us. As of December 2020, the framework is covered by more than 2100 tests.

Documentation

New features, no matter what they offer, are useless if they are not well documented. Maintaining complete and quality documentation is key to the framework. If you think something is missing or unclear, feel free to open an issue on Github!

Product Stability

Great attention is paid to the stability of the product. You can find out more by consulting our dependency policy, semantic versioning rules and long-term support policy.

:city_sunrise: Get started

First install Node.Js and npm.

Create a new app

npx @foal/cli createapp my-app
cd my-app
npm run dev

The development server is started! Go to http://localhost:3001 and find our welcoming page!

:point_right: Continue with the tutorial :seedling:

Backers

backers

Community Chat

You can join the community chat here.

Contributing

See the contribution guidelines.

License

MIT

NPM DownloadsLast 30 Days