Skip to content

@LoicPoullain LoicPoullain released this Feb 16, 2019 · 35 commits to master since this release

Features

  • [@foal/mongoose] Add support for Mongoose (MongoDB) (issue: #277) (PR: #342).
  • [@foal/cli] Add CLI commands to quickly connect a Vue/React/Angular frontend to the backend (dev & prod) (issue: #279) (PR: #348).
  • Add a type to Context.request (issue: #318) (PR: #337).
  • Automatically parse cookies (issue: #333) (PR: #334).
  • Let the JWT hooks retrieve the token from a cookie (issue: #335) (PR: #336).
  • Let the developer generate a script from anywhere in the project (terminal) (issue: #340) (PR: #349).
  • Simplify the Config system and support YAML (issue: #338) (PR: #351).
  • Remove legacy deprecated components (PR: #353).

How to migrate

npm install -g @foal/cli
npm install @foal/core@0.8 # and @foal/jwt@0.8, @foal/jwt@0.8, etc if relevant.

The new configuration system should be the only breaking change in the February release. Feel free to submit an issue if you are having trouble migrating.

  • New versions of Foal uses by default the port 3001 to not conflict with a running React server. You can still keep the port 3000 if you want.

  • Update all the Config.get calls in your code:

// Before
Config.get('mongodb', 'uri');
Config.get('settings', 'staticUrl', 'public/') as string;

// After
Config.get('mongodb.uri');
Config.get<string>('settings.staticUrl', 'public/');
  • Merge all your config files as follows:
Before:
- mongodb.e2e.json
- mongodb.development.json
- settings.development.json
- settings.json

After:
- e2e.json
- development.json
- default.json
// ***********
// Before
// ***********
// mongodb.development.json
{
  "uri": "my_uri"
}
// settings.development.json
{
  "debug": true
}

// ***********
// After
// ***********
// development.json
{
  "mongodb": {
    "uri": "my_uri"
  },
  "settings": {
    "debug": false
  }
}
  • If you're using the @foal/jwt package, replace the env variables JWT_WHATEVER with SETTINGS_JWT_WHATEVER and update your config files as follows:
// incorrect
{
  "jwt": {
    "secret": "xxx"
  },
  "settings": {
    ...
  }
}

// correct
{
  "settings": {
    "jwt": {
      "secret": "xxx"
    },
    ...
  }
}

The settings section now encompasses all the configuration of the official Foal packages.

  • If you customized the AJV instance (validation & sanitization), replace the env variables AJV_WHATEVER with SETTINGS_AJV_WHATEVER and update your config files as follows:
// incorrect
{
  "ajv": {
    "coerceTypes": true
  },
  "settings": {
    ...
  }
}

// correct
{
  "settings": {
    "ajv": {
      "coerceTypes": true
    },
    ...
  }
}

The settings section now encompasses all the configuration of the official Foal packages.

  • Divide the session keys into nested objects:
// Before
{
  "sessionResave": false,
  "sessionSaveUninitialized": false,
  "sessionSecret": "my-secret",
  "sessionCookieHttpOnly": true,
  "sessionCookieMaxAge": 1000,
  "sessionCookieSameSite": "lax",
  "sessionCookieSecure": true,
  "sessionName": "id"
}

// After
{
  "settings": {
    "session": {
      "resave": false,
      "saveUninitialized": false,
      "secret": "my-secret",
      "cookie": {
        "httpOnly": true,
        "maxAge": 3600000,
        "sameSite": "lax",
        "secure": true
      },
      "name": "id"
    }
  }
}

Here's are examples of config files using the new system:

You'll find more information here on how the new configuration system works.

Assets 2
You can’t perform that action at this time.