Platformatic v0.17.0 - Config file changes, a Schema Store, and a new upgrade command

Platformatic v0.17.0 - Config file changes, a Schema Store, and a new upgrade command

Hi Folks,

We are shipping Platformatic v0.17.0 this week with a significant update: we are streamlining our configuration files to better support custom plugins.

Full Changelog: github.com/platformatic/platformatic/releas..

New plugins configuration option

We have greatly streamlined the plugin option and reduced the number of possible variations. Before this could be a string, an array or an object:

{
  "plugin": {
    "path": "plugin.ts",
    "typescript": {
      "outDir": "dist"
    }
  }
}

The new plugins option only supports an object, like so:

{
  "plugins": {
    "paths": ["plugin.ts"],
    "typescript": true
  }
}

paths could also be an array if you need to specify options for the plugin:

{
  "plugins": {
    "paths": [{
      "path": "plugin.ts"
      "options": { "foo": "bar" }
    }],
    "typescript": true
  }
}

Note that the output directory is loaded from tsconfig.json directly.

This feature was implemented in #727.

Schema Store

If you ever used the create-platformatic utility to start a new project, it would have added a $schema property at the top of the JSON file to be used for autocompletion:

{
  "$schema": "./platformatic.db.schema.json",
 ...
}

Then, you could have run a local command to generate that file (and to keep it up-to-date). Now, this is not needed anymore as all configuration schemas are available online at:

{
  "$schema": "https://platformatic.dev/schemas/v0.17.0/db"
 ...
}

This file is automatically published to the web by our GitHub actions automation.

This change was implemented in #742 and #744.

plt upgrade

We have added a new command: platformatic upgrade (or plt upgrade with the shortcut). This new command automatically brings the configuration of your project to the latest version.

Use this command to upgrade from Platformatic v0.16.0 to v0.17.0.

This change was implemented on #753.

New Guide: how to use Prisma and Platformatic together

@ruheni contributed a guide on how to combine Prisma with Platformatic in #682. In fact, it's possible to use Prisma to create custom routes too:

const prismaPlugin = requrie("@sabinthedev/fastify-prisma")
module.exports = async (app) => {
  app.log.info('plugin loaded')

  app.register(prismaPlugin)

  /** 
   * Plugin logic
   */
  app.put('/post/:id/views', async (req, reply) => {
    const { id } = req.params

    const post = await app.prisma.post.update({
      where: {
        id: Number(id)
      },
      data: {
        viewCount: {
          increment: 1
        }
      }
    })

    return post
  })
}

License check

One of the most crucial things in an Open Source project is licensing. Platformatic is released licensed as Apache-2.0. However what about its dependencies? We can now guarantee that all its production dependencies are licensed as Apache-2.0, MIT, ISC, or BSD-2-Clause.

Ths automation was added in #750 via the old-but-faithful license-checker module.

Under pressure

  • Expose the all options from @fastify/under-pressure in the Platformatic configuration by @salesh in #725

Bug fixes