Releases: FoalTS/foal
v5.0.1
v5.0.0
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 theresolvers
property, you need to add thedeclare
keyword before the property name:export class ApiController extends GraphQLController { schema = // ... @dependency declare resolvers: RootResolverService; }
TypeORM upgrade
-
The minimum required version of TypeORM is v0.3.24.
npm install [email protected]
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 configurationsettings.loggerFormat: 'none'
withsettings.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 ofServiceManager
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 theLogger
service in a custom@Hook
instead. -
The command alias
npx foal run-script
has been removed. Usenpx foal run
instead. -
The deprecated method
AbstractProvider.redirect
has been removed. UseAbstractProvider.createHttpResponseWithConsentPageUrl({ isRedirection: true })
instead.// Version 4 return this.googleProvider.redirect(); // Version 5 return this.googleProvider.createHttpResponseWithConsentPageUrl({ isRedirection: true });
Dependencies
@foal/cli
node-fetch
removed
@foal/graphql
glob@11
@foal/social
node-fetch
removed
@foal/typeorm
[email protected]
(peer dependency)
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/jwks-rsa
@foal/socket.io
@foal/swagger
PR
v4.6.0
v4.5.1
Features
Some security vulnerabilities were showing up with npm audit
. This version updates Foal's dependencies to get rid of them.
Dependencies
@foal/acceptance-tests
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/core
@foal/examples
@foal/redis
v4.5.0
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
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/cli
@foal/core
@foal/graphql
[email protected]
[email protected]
(peer dependency)
@foal/mongodb
v4.4.0
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
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/core
@foal/swagger
Contributions
Thanks to Lucho for reporting this vulnerability in the first place!
v4.3.0
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
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/cli
@foal/core
@foal/jwks-rsa
@foal/social
@foal/socket.io
@foal/swagger
v4.2.0
Features
v4.1.0
v4.0.0
Overview and goals
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 ofmongodb
. You can use version 5 ofmongodb
dependency. - If you use
@foal/socket.io
with redis, installsocket.io-adapter
. - Support for
better-sqlite
driver has been dropped. Use thesqlite3
driver instead. In DB configuration, usetype: 'sqlite'
instead oftype: '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';
toimport { ObjectId } from 'typeorm';
Dependencies
@foal/aws-s3
@aws-sdk/[email protected]
@aws-sdk/[email protected]
@foal/cli
@foal/graphiql
@foal/graphql
[email protected]
graphql@^16.8
(peer dependency)
@foal/jwks-rsa
@foal/mongodb
@foal/redis
@foal/socket.io
@foal/swagger
@foal/typeorm
[email protected]
(peer dependency)[email protected]
(dev dependency / driver)[email protected]
(dev dependency / driver)
@foal/typestack
[email protected]
(peer dependency)