mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
add server to monorepo.
This commit is contained in:
18
packages/server/src/api/middleware/FeatureActivationGuard.ts
Normal file
18
packages/server/src/api/middleware/FeatureActivationGuard.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { Features } from '@/interfaces';
|
||||
|
||||
export const FeatureActivationGuard =
|
||||
(feature: Features) => (req: Request, res: Response, next: Function) => {
|
||||
const { settings } = req;
|
||||
|
||||
const isActivated = settings.get({ group: 'features', key: feature });
|
||||
|
||||
if (!isActivated) {
|
||||
return res.status(400).send({
|
||||
errors: [
|
||||
{ type: 'FEATURE_NOT_ACTIVATED', code: 20, payload: { feature } },
|
||||
],
|
||||
});
|
||||
}
|
||||
next();
|
||||
};
|
||||
Reference in New Issue
Block a user