Hi Folks,
We are shipping another Platformatic release this week with a few new features and plenty of bugfixes!
Generate getSchema()
definitions
getSchema()
is a useful utility to a reusable schema of an object. In Platformatic DB, we use this technique to share the schemas of all our entities. In #700, @rozzilla extended our typescript generator to include the types of those schemas.
declare module 'fastify' {
interface FastifyInstance {
getSchema(schemaId: 'Movie'): {
'$id': string,
title: string,
description: string,
type: string,
properties: object,
required: string[]
};
}
}
add request.platformaticContext decorator
We added a new platformaticContext
request decorator to help create an object with the right structure for the authorization plugin. Use it in this way in your custom plugins:
app.get('/all-pages', async (req, reply) => {
// Optionally get the platformatic context.
// Passing this to all sql-mapper functions allow to apply
// authorization rules to the database queries (amongst other things).
const ctx = req.platformaticContext
// Will return all rows from 'pages' table
const res = await app.platformatic.entities.page.find()
const res = await app.platformatic.entities.page.find({ ctx })
return res
})
This new feature was added in github.com/platformatic/platformatic/pull/697.
hot reload setting CLI flag
Platformatic hot reload functionality might crash on your system. We are working on it, but it requires some new features in Node.js core to be implemented. In the meanwhile, you can disable it from the command line:
plt db start --hot-reload false
This feature was added by @salesh in github.com/platformatic/platformatic/pull/679
What's Changed
- docs(schema-type): Movie quotes tutorial update by @rozzilla in github.com/platformatic/platformatic/pull/708
- Fix nested transaction support in insertOne in github.com/platformatic/platformatic/pull/711
- chore(package.json): Update template by @rozzilla in github.com/platformatic/platformatic/pull/710
- Use platformatic bin in create-platformatic to support pnpm and yarn in github.com/platformatic/platformatic/pull/713
- fix(create-platformatic): create default migrations only when requested (#690) by @marcelom97 in github.com/platformatic/platformatic/pull/712
- Adds minimum supported versions for databases by @Marcellofabrizio in github.com/platformatic/platformatic/pull/715
- Fix createdAt date formatting in Movie Quotes App tutorial by @simonplend in github.com/platformatic/platformatic/pull/717
- Creates the GH action in the project folder by @marcopiraccini in github.com/platformatic/platformatic/pull/718
- fixes #636 by @malforsaja in github.com/platformatic/platformatic/pull/720
- Start platformatic from another folder with typescript enabled in github.com/platformatic/platformatic/pull/724