Skip to content

Add missing types for FastifySessionObject function isSaved #312

@EagleLizard

Description

@EagleLizard

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

The documentation describes the isSaved() function, and this is implemented in the plugin. The types for this are currently not included

Motivation

Enable usage in Typescript of the isSaved function without additional project configuration.

Example

A request is made that depends on new session information being in the datastore, and the datastore has constraints on a new field added by a custom SessionStore:

fastify.post('/myroute', async function(req, rep) {
  const someRes = await checkSomething(req.body.val);
  if(someRes.doUpdate) {
     if(!req.session.isSaved()) {
       await req.session.save();
     }
     await dbOpThatDependsOnSessionTable(someRes);
  }
  rep.status(200).send()
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions