Version 2
Updated on June 19, 2020.
This issue provides an overview of the next version of Foal TS. It will be released between June and August 2020.
The purpose of this release is not to add many new features, which are regularly added in minor versions, but to fix issues and hacks that require some break changes. It will also remove unused and deprecated components and make parts of the framework simpler and more intuitive.
Changes & New Features
:white_check_mark: = Implemented
1. Developper experience (CLI) :white_check_mark:
Migrations and shell scripts are not developper friendly when developping (#494). There are too many CLI commands and it is not intuitive to know which one to use and in which order.
In version 2, the files tsconfig.migrations.json
and tsconfig.scripts.json
will be removed and the CLI commands will be reduced and simplified.
More details here: #684.
Examples
Build, make and run migrations
# Version 1
npm run build:app
npm run migration:generate -- -n my_migration
npm run build:migrations
npm run migration:run
# Version 2
npm run makemigrations
npm run migrations
Build migrations, scripts and the app
# Version 1
npm run build:app
npm run build:scripts
npm run build:migrations
# Version 2
npm run build
2. Authentication with sessions :white_check_mark:
Authentication with sessions is complicated and requires a lot of code. Current implementation also prevents the framework from adding new features (#525, #521, #510).
In version 2, the authentication system with sessions will be greatly simplified.
See #799.
3. Schema references in validation hooks :white_check_mark:
It is not possible to use references (especially OpenAPI references) in validation hooks.
In version 2, this will be fixed.
More details here: #552.
Example
const productSchema = {
// ...
}
@ApiDefineSchema('product', productSchema)
@ValidateBody({
$ref: '#/components/schemas/product'
})
4. Service initialization :white_check_mark:
Services can be initialized using their boot
method. For this to work, we currently need to call ServicesManager.boot()
in src/index.ts
.
In version 2, this feature will be enabled by default. No need to call ServicesManager.boot()
anymore.
5. Accessing file metadata during uploading :white_check_mark:
When uploading a file, we have only access to its content (#673).
In version 2, we will also have access to its file size, mime type and original file name.
6. Safer configuration :white_check_mark:
Current Config.get
function has several faults (#496).
In version 2, it will be replaced with the new Config.get2
added in v1.7.
// Version 1
const port = Config.get<number>('settings.port', 3000);
const port = Config.get<number>('settings.port');
// Version 2
const port = Config.get('settings.port', 'number', 3000);
const port = Config.getOrThrow('settings.port', 'number')
7. Improve the naming of JWT settings :white_check_mark:
Version 1: settings.jwt.secretOrPublicKey
Version 2: settings.jwt.secret
, settings.jwt.publicKey
8. Remove support of Mongoose :white_check_mark:
Mongoose brought many problems in the past while maintaining the framework. It takes time to maintain it and it is also not typed and does not seem to be used by FoalTS users: https://www.npmjs.com/package/@foal/mongoose.
FoalTS will no longer provide Mongoose tools starting from v2 (i.e. CLI code generation and the fetchUser
function). Users will still be able to use it "by hand" if they wish.
9. Improve the configuration system :white_check_mark:
See #805, #497.
10. Simplify the management of custom errors thrown in controllers and hooks :white_check_mark:
See https://github.com/FoalTS/foal/issues/638#issuecomment-673915802.
Cleanup :white_check_mark:
- Remove the outdated and useless security headers.
- Remove the
PermissionDenied
and ObjectDoesNotExist
which are unused and do not appear in the documentation.
- Remove the object
ValidationError
and the function validate
which are unused and do not bring value to the framework.
- Remove the deprecated function
createHttpResponseFile
and use Disk.createHttpResponseFile
instead. Once done, remove the package mime
from @foal/core
dependencies.
- Remove the package
@foal/formidable
and use the @ValidateMultipartFormDataBody
hook instead.
- Remove the deprecated
legacy
option of the functions hashPassword
and verifyPassword
. This option was used in very old versions of Foal when no one was using the framework.
- Remove the deprecated package
@foal/ejs
and the possibility to create FoalTS template engines. Only Express templates engines will be allowed (Twig, EJS, pug, etc).
- Drop the support of Node 8 and run tests on Node 12 and 14. Version 8 of Node is not maintained anymore. Uninstall
pump
in @foal/core
, @foal/storage
and @foal/aws-s3
and use the pipeline
function from the standard library (added in Node 10).
- Remove the unused command
foal g sub-app
.
- Check if password hashing needs an update (OWASP).
- Make
createApp
return a promise and remove createAndInitApp
. The function createAndInitApp
was introduced because we needed to return a promise.
// Before
const app = createApp();
const app = await createAndInitApp();
// After
const app = await createApp();
- Only allow one way to pass a custom express instance to
createApp
.
// Before
const expressInstance = express();
const app = createApp(expressInstance);
// OR
const app = createApp({ expressInstance });
// After
const expressInstance = express();
const app = createApp({ expressInstance });
Upgrading Dependencies
help wanted good first issue