How to use the @foal/core.controller function in @foal/core

To help you get started, we’ve selected a few @foal/core 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 / cli / src / generate / mocks / controller / app.module.no-empty-property.ts View on Github external
// 3p
import { controller } from '@foal/core';

export class MyModule {
  controllers = [
    controller('/', MyController),
    controller('/', MyController2)
  ];
}
github FoalTS / foal / packages / typeorm / e2e / rest.spec.ts View on Github external
@LoginRequired({ user: fetchUser(User) })
  class OrgController extends RestController {
    @dependency
    collection: OrgCollection;
  }

  class AuthController extends LoginController {
    strategies = [
      strategy('login', Authenticator, {})
    ];
  }

  class AppController {
    subControllers = [
      controller('/users', UserController),
      controller('/orgs', OrgController),
      controller('', AuthController),
    ];
  }

  const app = createApp(AppController);

  /* Create orgs, perms, groups and users */

  await createConnection({
    database: 'e2e_db.sqlite',
    dropSchema: true,
    entities: [ User, Permission, Group, Org ],
    name: 'create-connection',
    synchronize: true,
    type: 'sqlite',
  });
github FoalTS / foal / packages / cli / src / generate / specs / controller / app.module.no-empty-property.ts View on Github external
// 3p
import { controller } from '@foal/core';
import { TestFooBarController } from './controllers';

export class MyModule {
  controllers = [
    controller('/', MyController),
    controller('/', MyController2),
    controller('/', TestFooBarController)
  ];
}
github FoalTS / foal / packages / cli / src / generate / mocks / controller / app.module.no-empty-property.ts View on Github external
// 3p
import { controller } from '@foal/core';

export class MyModule {
  controllers = [
    controller('/', MyController),
    controller('/', MyController2)
  ];
}
github FoalTS / foal / packages / cli / src / generate / specs / controller / app.module.no-empty-property.ts View on Github external
// 3p
import { controller } from '@foal/core';
import { TestFooBarController } from './controllers';

export class MyModule {
  controllers = [
    controller('/', MyController),
    controller('/', MyController2),
    controller('/', TestFooBarController)
  ];
}
github FoalTS / foal / packages / acceptance-tests / src / authentication / jwt.token.spec.ts View on Github external
return reject(err);
          }
          resolve(value);
        });
      });

      return new HttpResponseOK({
        token
      });
    }
  }

  class AppController {
    subControllers = [
      AuthController,
      controller('/api', ApiController),
    ];
  }

  before(async () => {
    process.env.SETTINGS_JWT_SECRET_OR_PUBLIC_KEY = 'session-secret';
    await createConnection({
      database: 'e2e_db.sqlite',
      dropSchema: true,
      entities: [ User ],
      synchronize: true,
      type: 'sqlite',
    });

    blackList = [];

    app = createApp(AppController);
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
scopes: {
          'read:pets': 'read your pets',
          'write:pets': 'modify pets in your account',
        }
      }
    },
    type: 'oauth2',
  })
  @ApiDefineSecurityScheme('api_key', {
    in: 'header',
    name: 'api_key',
    type: 'apiKey',
  })
  class ApiController {
    subControllers = [
      controller('/pet', PetController),
      controller('/store', StoreController),
      controller('/user', UserController),
    ];
  }

  @ApiUseTag('pet')
  @ApiDefineSchema('Category', {
    properties: {
      id: {
        format: 'int64',
        type: 'integer',
      },
      name: { type: 'string' }
    },
    type: 'object',
    xml: { name: 'Category' }
github FoalTS / foal / packages / acceptance-tests / src / csrf / spa-and-api.stateful.spec.ts View on Github external
@TokenRequired({
    cookie: true,
    store: TypeORMStore,
  })
  @CsrfTokenRequired()
  class ApiController {
    @Post('/products')
    createProduct() {
      return new HttpResponseCreated();
    }
  }

  class AppController {
    subControllers = [
      AuthController,
      controller('/api', ApiController),
    ];
  }

  before(async () => {
    process.env.SETTINGS_SESSION_SECRET = 'session-secret';
    await createConnection({
      database: 'e2e_db.sqlite',
      dropSchema: true,
      synchronize: true,
      type: 'sqlite',
    });

    app = createApp(AppController);
  });

  after(async () => {
github FoalTS / foal / packages / acceptance-tests / src / authentication / session-token.cookie.spec.ts View on Github external
cookie: true,
      extendLifeTimeOrUpdate: false,
      store: TypeORMStore,
    })
    async logout(ctx: Context) {
      await this.store.destroy(ctx.session.sessionID);
      const response = new HttpResponseNoContent();
      removeSessionCookie(response);
      return response;
    }
  }

  class AppController {
    subControllers = [
      AuthController,
      controller('/api', ApiController),
    ];
  }

  before(async () => {
    process.env.SETTINGS_SESSION_SECRET = 'session-secret';
    await createConnection({
      database: 'e2e_db.sqlite',
      dropSchema: true,
      entities: [ User ],
      synchronize: true,
      type: 'sqlite',
    });

    app = createApp(AppController);
  });
github FoalTS / foal / packages / examples / src / app / sub-modules / authentication / auth.module.ts View on Github external
import { controller, IModule, Module } from '@foal/core';

import { AuthController } from './controllers/auth.controller';
import { ViewController } from './controllers/view.controller';

@Module()
export class AuthModule implements IModule {
  controllers = [
    controller('', AuthController),
    controller('', ViewController),
  ];
}