Skip to content

Releases: FoalTS/foal

v5.0.1

27 May 15:11
Compare
Choose a tag to compare

Fixes

  • Make create-userscript generated with createapp work with MongoDB (PR: #1314)

v5.0.0

27 May 14:24
Compare
Choose a tag to compare

Supported versions of Node and TypeScript

  • Support for Node 18 and Node 20 has been dropped and support for Node 22 has been added. Foal code is now compiled to ES2023.

  • The minimum supported version of TypeScript is version 5.5. Update your package.json file accordingly.

    npm install [email protected]

    If you're using the GraphQLController with the resolvers property, you need to add the declare keyword before the property name:

    export class ApiController extends GraphQLController {
      schema = // ...
    
      @dependency
      declare resolvers: RootResolverService;
    }

TypeORM upgrade

Better typing

  • The default type of Context.state is now {}. This way, you'll get a compilation error if you forget to specify a type for the state.

    // Version 4
    class MyController {
      @Get('/foobar')
      foobar(ctx: Context) {
        // Does not throw.
        console.log(ctx.state.shoppingCart);
      }
    }
    
    // Version 5
    class MyController {
      @Get('/foobar')
      foobar(ctx: Context) {
        // Throws a compilation error: Property 'shoppingCart' does not exist on type '{}'.ts(2339)
        console.log(ctx.state.shoppingCart);
      }
    }
    
    // Version 5 (without error)
    class MyController {
      @Get('/foobar')
      foobar(ctx: Context<any, { shoppingCart: object }>) {
        console.log(ctx.state.shoppingCart);
      }
    }
  • The return value of the social services getUserInfoFromTokens method is now typed.

Controller parameters

To facilitate the typing of the request body, path parameters and request parameters in controllers, the request object is now passed as a second argument to controller methods.

    interface MyQuery {
      // ...
    }

    interface MyBody {
      // ...
    }

    interface MyParams {
      // ...
    }

    // Version 4
    class MyController {
      @Get('/foobar')
      foobar(ctx: Context) {
        const query = ctx.request.query as MyQuery;
        const body = ctx.request.body as MyQuery;
        const params = ctx.request.params as MyParams;

        // Do something
      }
      // OR
      @Get('/foobar')
      foobar(ctx: Context, params: MyParams, body: MyBody) {
        const query = ctx.request.query as MyQuery;

        // Do something
      }
    }

    // Version 5
    class MyController {
      @Get('/foobar')
      foobar(ctx: Context, { query, body, params }: { query: MyQuery, body: MyBody, params: MyParams }) {
        // Do something
      }
    }

Logging

  • The Logger.addLogContext(key, value) method now accepts a record as parameter: Logger.addLogContext(context). This makes the function's signature more consistent with other logging methods (info, warn, etc.) and allows multiple keys/values to be passed at once.

    // Version 4
    this.logger.addLogContext('foo', 'bar');
    this.logger.addLogContext('barfoo', 'foobar');
    
    // Version 5
    this.logger.addLogContext({
      foo: 'bar',
      barfoo: 'foobar',
    });
  • The deprecated settings.loggerFormat configuration has been removed. If you want to disable HTTP logging, replace configuration settings.loggerFormat: 'none' with settings.logger.logHttpRequests: false.

    // Version 4
    {
      "settings": {
        "loggerFormat": "none"
      }
    }
    
    // Version 5
    {
      "settings": {
        "logger": {
          "logHttpRequests": false
        }
      }
    }
    
    // Version 4
    {
      "settings": {
        "loggerFormat": "any other value than 'none'"
      }
    }
    
    // Version 5
    {
      "settings": {}
    }

Shell scripts

  • The main function of shell scripts now receives an instance of ServiceManager as second argument and the logger as third argument:

    // Version 4
    export async function main(args: any) {
      // ...
    }
    
    // Version 5
    export async function main(args: any, services: ServiceManager, logger: Logger) {
      // ...
    }
  • Log context are supported.

  • When running a script, the script name as well as a script ID are added to the log context.

  • At the end of script execution, as with an HTTP request, a log is printed to indicate whether the execution was successful or unsuccessful.

  • Any error thrown in the main function is now logged with the framework logger.

    // Version 4
    export async function main() {
      const services = new ServiceManager();
      const logger = services.get(Logger);
    
      try {
        // ...
        throw new Error('Hello world');
      } catch(error) {
        logger.error(error.message { error });
      }
    }
    
    // Version 5
    export async function main() {
      // ...
      throw new Error('Hello world');
    }

Removal of deprecated components

  • The deprecated hook @Log has been removed. Use the Logger service in a custom @Hook instead.

  • The command alias npx foal run-script has been removed. Use npx foal run instead.

  • The deprecated method AbstractProvider.redirect has been removed. Use AbstractProvider.createHttpResponseWithConsentPageUrl({ isRedirection: true }) instead.

    // Version 4
    return this.googleProvider.redirect();
    
    // Version 5
    return this.googleProvider.createHttpResponseWithConsentPageUrl({ isRedirection: true });

Dependencies

PR

#1280

v4.6.0

26 May 11:24
Compare
Choose a tag to compare

Features

  • Remove deprecated security header X-XSS-Protection (issue: #1305, PR: #1311)

v4.5.1

14 Sep 18:38
Compare
Choose a tag to compare

Features

Some security vulnerabilities were showing up with npm audit. This version updates Foal's dependencies to get rid of them.

Dependencies

v4.5.0

22 Aug 12:16
Compare
Choose a tag to compare

Features

  • [Internal] Upgrade to lerna v8 (PR: #1259)
  • Deprecate use of CLI globally (PR: #1273)
  • Fix foal connect react and support build output dir (PR: #1274)
  • Make logging more suitable for log monitoring softwares (PR: #1275)
  • Allow to run async tasks and catch and log them appropriately on failure (PR: #1276)
  • Improve GoogleProvider types (PR: #1277)
  • Improve social auth for SPA (PR: #1277)
  • Remove the link to the official site from the index.html of new applications to avoid polluting the traffic analytics of foalts.org (PR: #1278)

Dependencies

v4.4.0

25 Apr 06:44
Compare
Choose a tag to compare

Features

This release updates Foal's sub-dependencies, including the express library, which presents a moderate vulnerability in versions prior to 4.19.2.

Dependencies

Contributions

Thanks to Lucho for reporting this vulnerability in the first place!

v4.3.0

16 Apr 12:05
Compare
Choose a tag to compare

Features / improvements / fixes

  • [Internal] Use fs native API with promises (PR: #1243)
  • [Bug] Fix HTTP logger error when the client request is aborted (issue: #1247) (PRs: #1249, #1252)
  • [CLI] Display all errors when the validation of script arguments fails (PR: #1251)

Dependencies

#1250

v4.2.0

29 Oct 19:41
Compare
Choose a tag to compare

Features

  • [Bug] Fix "foal connect angular" to support latest versions of Angular (issue: #1197) (PR: #1236)
  • Allow to disable AJV strict mode (issue: #1206) (PR: #1239)
  • Possibility to pass cacheControl option to static middleware (issue: #1221) (PR: #1241 )
  • Logs added to socket.io controllers (PR: #1240)

v4.1.0

24 Oct 10:01
Compare
Choose a tag to compare

Features

  • Add request ID (PR: #1234)
  • Add Foal logger (PR: #1234)
  • Support XML requests (issue: #1203) (PR: #1231)

Dependencies

Contributors

@paoloevan

v4.0.0

06 Sep 18:29
Compare
Choose a tag to compare

Overview and goals

#1223

Migration guide

  • Run npx foal upgrade.
  • Version 16 of Node is not supported anymore. Upgrade to version 18 or version 20.
  • Support of MariaDB has been dropped.
  • If you use any of these dependencies, upgrade typeorm to v0.3.17, graphql to v16, type-graphql to v2, class-validator to v0.14, mongodb to v5 and @socket.io/redis-adapter to v8.
  • If you use both TypeORM and MongoDBStore, there is no need anymore to maintain two versions of mongodb. You can use version 5 of mongodb dependency.
  • If you use @foal/socket.io with redis, install socket.io-adapter.
  • Support for better-sqlite driver has been dropped. Use the sqlite3 driver instead. In DB configuration, use type: 'sqlite' instead of type: 'better-sqlite3'.
  • In your project dependencies, upgrade @types/node to v18.11.9.
  • If you use TypeORM with MongoDB, for the entities definitions, rename import { ObjectID } from 'typeorm'; to import { ObjectId } from 'typeorm';

Dependencies