mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: Design with inversion dependency injection architecture. feat: Prettier http middleware. feat: Re-write items categories with preferred accounts.
13 lines
388 B
TypeScript
13 lines
388 B
TypeScript
import { Request, Response } from 'express';
|
|
import { Container } from 'typedi';
|
|
|
|
export default async (req: Request, res: Response, next: Function) => {
|
|
const { organizationId, knex } = req;
|
|
|
|
if (!organizationId || !knex) {
|
|
throw new Error('Should load `TenancyMiddleware` before this middleware.');
|
|
}
|
|
Container.of(`tenant-${organizationId}`).set('knex', knex);
|
|
|
|
next();
|
|
}; |