How to use the @foal/jwt.JWTOptional function in @foal/jwt

To help you get started, we’ve selected a few @foal/jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FoalTS / foal / packages / acceptance-tests / src / openapi.hooks.spec.ts View on Github external
const yamlDocument = readFileSync(join(__dirname, './assets/openapi.hooks.yml'), 'utf8');
    const expectedDocument = parse(yamlDocument);

    const actualDocument = createOpenApiDocument(ApiController);

    deepStrictEqual(actualDocument, expectedDocument);

    // Test hook conflicts (Two calls of @JWT).

    @ApiInfo({
      title: 'My API',
      version: '1.0.0'
    })
    class ApiController2 {
      @Get('/products')
      @JWTOptional()
      readProducts() {}

      @Post('/products')
      @JWTRequired()
      @ValidateBody({
        properties: {
          name: { type: 'string' }
        },
        type: 'object',
      })
      createProduct() {}
    }

    const yamlDocument2 = readFileSync(join(__dirname, './assets/openapi.hooks2.yml'), 'utf8');
    const expectedDocument2 = parse(yamlDocument2);

@foal/jwt

Authentication with JWT for FoalTS

MIT
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis